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

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

asp.net - In javascript how to find the height and width -

c# - DataTable to EnumerableRowCollection -