Check if ostream object is cout or ofstream, c++ -


is there way in c++ check if ostream object cout or ofstream object?

something like:

ostream& output(ostream& out) {     if (out == cout)         return out;     else     {         out << "something different because not going console" << endl;         return out;     } }

the reason want this, want overload << operator 2 different things depending on type of stream used with.

is possible overload << operator twice each time different type of stream?

updated reflect intention better.

it's possible checking stream's 'identity': if ( &out == &cout ) ....

however, i'm in doubt on usefullness of test. if function can handle output stream, why bother stream using?


Comments

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -