pstade

PrevUpHomeNext

Output Iterators

any_output_iterator
applier
eater
stream_writer
streambuf_writer
std_stream_writer

Oven provides some useful Output Iterators.

Description

any_output_iterator is an Output Iterator to which any Output Iterator can be assigned.

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

Valid expression

Semantics

any_output_iterator<V>(_outit)

An Output Iterator whose iterator operations are forwarded to _outit.

Preconditions
  • V specifies a (possibly reference) type which is outputted to _outit.
Example
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;
any_output_iterator<int> o1, o2;
o1 = filterer(regular(bll::_1 % 2 == 0)) |= std::back_inserter(out);
o2 = transformer(regular(bll::_1 * 3)) |= o1;
copy(in,  o2);
BOOST_CHECK( equals(out, answer) );
See also
Description

applier returns an Output Iterator which passes each item assigned as an argument to the unary function.

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

Valid expression

Semantics

applier(_fun)

T(_fun)

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

eater returns an Output Iterator which ignores inputs.

Header
  • <pstade/oven/eater.hpp>
Model of
Notation
  • f_ is an imaginary Function Object which behaves as if it were v -> (void)v.
Valid expressions

Valid expression

Semantics

eater()

applier(f_)

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

stream_writer returns an Output Iterator which is a shorthand version of std::ostream_iterator. It needs no explicit template parameter to specify the value_type to output, but one extra precondition below must be met. It can be easily guaranteed by using converter, though.

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

Valid expression

Semantics

stream_writer(s, d)

T(s, d)

stream_writer(s)

stream_writer(s, 0)

[Note] Note

stream_writer doesn't write an extra delimiter after the last element.

Preconditions
  • T is hamigaki::ostream_iterator<unspecified, _typeof(s)::char_type, _typeof(s)::traits_type> such that T(s, d) is a valid expressin.
  • An object which is passed to _typeof(stream_writer(s))::operator= is Output Streamable.
Example
std::vector<std::string> sample
    = initial_values("hello", "oven", "stream_writer");

{
    std::ofstream fout("read.txt");
    copy(sample, stream_writer(fout, " "));
}

{
    std::ifstream fin("read.txt");
    BOOST_CHECK( equals(
        oven::stream_read<std::string>(fin),
        sample
    ) );
}
See also
Description

streambuf_writer is the object generator of std::ostreambuf_iterator.

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

Valid expression

Semantics

streambuf_writer(s)

T(s)

streambuf_writer(p)

U(p)

Preconditions
  • T is std::ostreambuf_iterator<typeof(s)::char_type, typeof(s)::traits_type> such that T(s) is a valid expression.
  • U is std::ostreambuf_iterator<typeof(*p)::char_type, typeof(*p)::traits_type> such that U(p) is a valid expression.
Example
See also
Description

std_stream_writer returns an Output Iterator which behaves as if it were std::ostream_iterator.

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

Valid expression

Semantics

std_stream_writer(s, d)

stream_writer(s, d) but it outputs a trailing delimiter d.

std_stream_writer(s)

stream_writer(s)

Preconditions
  • The corresponding semantics is a valid expression.
[Note] Note

std_stream_writer doesn't take a template parameter for output value_type. Use converter when you want to specify it.

Example
See also
Copyright © 2005 -2007 Shunsuke Sogame

PrevUpHomeNext