Boost logo

Boost Users :

From: Roman Perepelitsa (roman.perepelitsa_at_[hidden])
Date: 2007-05-21 02:47:15


Christian Henning <chhenning <at> gmail.com> writes:

>
> Thanks a lot, again.
>
> This is the working code now.
> [cut]

You can use transform + ostream_iterator instead of for_each + print.

transform( m_data.begin()
         , m_data.end()
         , ostream_iterator<string>(cout, "\n")
         , boost::bind( &Base::to_String
                      , _1
                      , indent_value));

And instead of handcrafted loop for indentation you can use constructor of
std::string.

virtual string to_String ( boost::uint32_t indent )
{
    stringstream output;
    output << string(indent, ' ') << m_value;
    return output.str();
}

Roman Perepelitsa.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net