Boost logo

Boost :

Subject: Re: [boost] none_t I/O operators
From: Gregory Crosswhite (gcross_at_[hidden])
Date: 2011-06-05 17:16:03

On 6/5/11 1:29 PM, Gregory Crosswhite wrote:
> On a more serious note, though, is there a trick one can use to write
> I/O operators like the ones I defined above without necessarily
> pulling in <iostream>? I am of course aware of the existence of
> forward declarations, but unless my understanding of them is wrong
> (and hopefully it is :-) ) they cause compiler errors when the forward
> declared class has already been actually declared, so using forward
> declarations would break in the case that the user had already pulled
> in <iostream> before the forward declarations appeared.

Doh! It turns out that my misunderstanding came from the fact that the
forward declaration

     class ostream;

is a special case where ostream is a *typedef* rather than a class.
Replacing this with


namespace std {
   template<typename _CharT> class char_traits;
   template<typename _CharT, typename _Traits> class basic_ostream;

std::basic_ostream<char,std::char_traits<char> > ...


seems so far to work like a charm!


Boost list run by bdawes at, gregod at, cpdaniel at, john at