This is the mail archive of the
libstdc++@sources.redhat.com
mailing list for the libstdc++ project.
Re: About endl...
- To: Benjamin Kosnik <bkoz at redhat dot com>
- Subject: Re: About endl...
- From: Jean-Marc Valin <valj01 at gel dot usherb dot ca>
- Date: Mon, 27 Nov 2000 19:40:09 -0500
- Cc: libstdc++ at sources dot redhat dot com
- Organization: Universite de Sherbrooke
- References: <200011272301.eARN1wH16966@fillmore.constant.com>
> <ostream> declares endl to be:
>
> // 27.6.2.7 Standard basic_ostream manipulators
> template<typename _CharT, typename _Traits>
> basic_ostream<_CharT, _Traits>&
> endl(basic_ostream<_CharT, _Traits>& __os)
> { return flush(__os.put(__os.widen('\n'))); }
I saw that in the headers, but I don't understand why is breaks the original
function I posted:
template <class T>
void output(T val) {
cout << val;
}
Is there a workaround? How can I implement an (template) output method that
could accept endl as argument. Also, from the header definition, I don't
understand why typeid(endl) doesn't work either. Can anyone enlighten me?
BTW, the real code I use that for is a Stream wrapper class that derives from a
base Object class:
class Stream : public Object
{
protected:
ios *int_stream;
public:
Stream(ios *_str)
: int_stream(_str)
{}
...
template <class T>
Stream &operator << (T &obj) {*dynamic_cast<ostream *> (int_stream) << obj;
return *this;}
};
In this case, the problem is with operator << (...). Any idea how to fix my code
to comply with the new libstdc++?
Jean-Marc
--
Jean-Marc Valin
Universite de Sherbrooke - Genie Electrique
valj01@gel.usherb.ca