pstade

PrevUpHomeNext

Output Iterator Adaptors

converter
copier
filterer
indirecter
intercepter
permuter
transformer
range_transformer
utf8_encoder
utf16_encoder

Output Iterator Adaptors adapt the behavior of the underlying Output Iterator. An Output Iterator Adaptor is a Pipable Function Object, so that, by using operator|=, you can "chain" multiple adaptors:

int const in[] = { 1,2,3,4,5,6,7,8,9,10 };
int const answer[] = {2*3,4*3,6*3,8*3,10*3};
std::vector<int> out;
copy(in, filterer(regular(bll::_1 % 2 == 0))
    |= transformer(regular(bll::_1 * 3)) |= std::back_inserter(out) );
BOOST_CHECK( equals(out, answer) );
Description

converter changes an output into specified type.

Header
  • <pstade/oven/converter.hpp>
Model of
  • ...
Notation
  • f_ is an imaginary Function Object which behaves as if it were v -> *_outit++ = boost::implicit_cast<To>(v).
Valid expressions

Valid expression

Semantics

X_make_converter<To>

A Major Function Object type

X_make_converter<To>()(_outit)

applier(f_)

oven::make_converter<To>(_outit)

X_make_converter<To>()(_outit)

converter<To>

A Pipable Function Object type

converter<To>() |= _outit

X_make_converter<To>()(_outit)

Preconditions
  • The corresponding semantics is a valid expression.
Example
See also
Description

copier outputs to another output iterator.

Header
  • <pstade/oven/copier.hpp>
Model of
Notation
  • f_ is an imaginary Function Object which behaves as if it were v -> *_outit0++ = v; *_outit++ = v.
Valid expressions

Valid expression

Semantics

copier(_outit0) |= _outit

applier(f_)

Preconditions
  • The corresponding semantics is a valid expression.
Example
std::vector<int> v1, v2, v3;
int b[] = {1,3,4,5,3,2,5,1,2};

copy(b,
    copier(std::back_inserter(v1)) |= copier(std::back_inserter(v2))
    |= std::back_inserter(v3) );
See also
Description

filterer skips an input which doesn't satify a predicate.

Header
  • <pstade/oven/filterer.hpp>
Model of
Notation
  • f_ is an imaginary Function Object which behaves as if it were v -> if(_prd(*v)) *_outit++ = *v.
Valid expressions

Valid expression

Semantics

filterer(_prd) |= _outit

applier(f_)

Preconditions
  • _prd is Assignable.
  • The corresponding semantics is a valid expression.
Example
See also
Description

indirecter applies an extra dereference in outputting.

Header
  • <pstade/oven/indirecter.hpp>
Model of
Notation
  • f_ is an imaginary Function Object which behaves as if it were v -> *_outit++ = *v.
Valid expressions

Valid expression

Semantics

indirecter |= _outit

applier(f_)

Preconditions
  • The corresponding semantics is a valid expression.
Example
See also
Description

intercepter intercepts inputs.

Header
  • <pstade/oven/intercepter.hpp>
Model of
Notation
Valid expressions

Valid expression

Semantics

intercepter(_outit2) |= _outit

_outit2

intercepter |= _outit

eater

Preconditions
  • ...
Example
See also
Description

permuter outputs permuted values using inputs as indices of a range.

Header
  • <pstade/oven/permuter.hpp>
Model of
Notation
  • f_ is an imaginary Function Object which behaves as if it were v -> *_outit++ = *(_begin(_rndrng)+v).
Valid expressions

Valid expression

Semantics

permuter(_rndrng) |= _outit

applier(f_)

Preconditions
  • The corresponding semantics is a valid expression.
Example
See also
Description

tranformer applies a Function Object to an input.

Header
  • <pstade/oven/transformer.hpp>
Model of
Notation
  • f_ is an imaginary Function Object which behaves as if it were v -> *_outit++ = _fun(v).
Valid expressions

Valid expression

Semantics

transformer(_fun) |= _outit

applier(f_)

Preconditions
  • _fun is Assignable.
  • The corresponding semantics is a valid expression.
Example
See also
Description

range_transformer can turn a Range Adaptor into Output Iterator Adaptor.

Header
  • <pstade/oven/range_transformer.hpp>
Model of
Notation
  • f_ is an imaginary Function Object which behaves as if it were v -> _outit = copy(_fun(single(v)), _outit).
Valid expressions

Valid expression

Semantics

range_transformer(_fun) |= _outit

applier(f_)

Preconditions
  • _fun is Assignable.
  • The corresponding semantics is a valid expression.
Example
file_range<boost::uint8_t> frng("utf8.txt");
std::vector<boost::uint8_t> result;
// Do the same job as utf8_encoder slightly inefficient way.
copy(frng|utf8_decoded, range_transformer(make_utf8_encoded) |= std::back_inserter(result));
See also
Description

Pending...

Header
  • <pstade/oven/utf8_encoder.hpp>
Model of
Valid expressions

Valid expression

Semantics

utf8_encoder |= _outit

T(_outit)

Preconditions
  • T is boost::utf8_output_iterator<typeof(_outit)> such that T(_outit) is a valid expression.
Example
See also
Description

Pending...

Header
  • <pstade/oven/utf16_encoder.hpp>
Model of
Valid expressions

Valid expression

Semantics

utf16_encoder |= _outit

T(_outit)

Preconditions
  • T is boost::utf16_output_iterator<typeof(_outit)> such that T(_outit) is a valid expression.
Example
See also
Copyright 2005 -2007 Shunsuke Sogame

PrevUpHomeNext