I'm using a class meant to be used like this:
Output() << "Hello.\n";
In its operator<<
I explicitely use std::cout
, but I'd like to have a static class member that resolves to `std::cout´ so I can do stuff like this:
copy(some_string_set.begin(), some_string_set.end(), ostream_iterator<string>(Output::m_stream, ", "));
or something similar (I can't fix the bottom line until I get the static data member fixed.
I even tried auto
, but GCC threw a
error: 'std::cout' cannot appear in a constant-expression
at me. How can I do what I want? (the point is not having to use std::cout
all through my code, but have all output go through the Output class)
static
? – TelemotorOutput
class will constantly have temporaries created (each time the first line of code is used), I don't want to initialize it every time, plus the fact that the second code line needs a static member. – Genie:s
– Geniecout
,cin
, ... are globals)? By the way, the type should bestd::ostream &
. – TelemotorQDebug
... – Genie