Boost logo

Boost :

From: Samuel Krempp (krempp_at_[hidden])
Date: 2003-09-09 22:30:47


le Samedi 6 Septembre 2003 10:24, gennadiy.rozental_at_[hidden] écrivit :

> Library add endl itself at the end of log entry. To add an extra empty
> line you could use '\n'. I am not sure why endl failing, but it seems
> pointless to use it.

it fails for other manipulators too.
that's because you cant pass functions by const reference.

It could be made to work :

1. either with a T const& / T& overload :

template <class T>
inline wrap_stringstream&
operator<<( wrap_stringstream& targ, T const& t )
{
    targ.stream() << t;
    return targ;
}

template <class T>
inline wrap_stringstream&
operator<<( wrap_stringstream& targ, T& t )
{ // same code..

but this kind of overload is not supported by compilers like MSVC6.

2. or by overloading it for the 3 following types to catch all 3 kinds of
manipulators :

ios_base& (*pfn)(ios_base&)
basic_ostream<Elem,Tr> & (*pfn)(basic_ostream<Elem, Tr>&)
basic_ios<Elem, Tr>& (*pfn)(basic_ios<Elem, Tr>&)

(just like std::basic_ostream :: operator<< 's overloads)

-- 
Samuel

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