From: Samuel Krempp (krempp_at_[hidden])
Date: 2003-09-09 23:36:26
le Mercredi 10 Septembre 2003 05:54, lorgon_at_[hidden] écrivit :
>> it fails for other manipulators too.
>> that's because you cant pass functions by const reference.
> Is this the real reason? (see below)
no, you're right about endl. I had forgotten endl was not like the other
this point still holds for other manipulators though (showbase, etc..)
> Does this work? (I confess I have not tried it.) I thought the real
no, not for endl..
> reason for the manipulator failure had to do with the fact that
> is not the name of a C++ object. Rather it's the name of a template
> function, and obscure C++ type system rules allow such a name to be
> coerced into a pointer to a single instance of the template function,
> provided there is sufficient external context information available.
> I have run into this problem in other contexts, and I have never been
> able to capture "endl" using a "template <class T>" parameter.
>> 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)
> I think this is the only way that truly works.
and the mechanism that makes endl instantiate in this context still is
somekind of a mystery to me...
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk