Boost logo

Boost :

From: vonosan (alnsn_at_[hidden])
Date: 2001-12-21 02:25:59


--- In boost_at_y..., Samuel Krempp <krempp_at_c...> wrote:
> string s ="%1"; //or whatever
> cout << format(s) << toto << endf << "continue";
>
> 1. format(s); constructs an object, which basically parses s, and
> prepares internal structures :
> storage for N strings, an internal stringstream (which format state
is
> set equal to cout's)
> 2. operator<<(stream&, const format&) returns a temporary proxy, of
type
> 'ofrstream'.
> This temporary is passed shared pointers to access the internal
> structures of the initial object.
> 3. operator<<(ofrstream&, const T&) is called for ' << toto'

Here may be a problem of passing temporary by non-const reference.

> it dumps toto the internal stringstream, possibly with some
formatting
> options, and puts the result string into one of the prepared
storage.
> It might format toto into a string 20 times, or zero, depending on
the
> format string.
> 4. endf
> its type, ofr_end, is :
> typedef ostream& (*ofr_end)(ofrstream&);
>
> And the class defines
> ostream& ofrstream::operator<<(ofr_end func) {
> return func(*this);
> }
>
> So, when reaching endf, the ofrstream is told to dump all internal
> strings into cout. And cout is returned.

-----------------
Alexander Nasonov


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk