Boost logo

Boost :

From: Lars Gullik Bjønnes (larsbj_at_[hidden])
Date: 2003-09-25 06:47:42

"Jeff Garland" <jeff_at_[hidden]> writes:

| My approach was a bit different in that I didn't bother with the buffer at
| all, but created the ostream interface directly in hope that the compiler
| could obviously optimize out any calls to the stream output. This would allow
| me to insert tracing in time sensitive code and expect that when I replace it
| will null ostream the code would be totally optimized away -- costing nothing
| in space or time.

But if you are going to compile anyway, then you could use other
methods as well (pre-processor).
| //The essence of the idea...
| //no char templates for simplicity of illustration
| class null_ostream : public std::ostream {
| public:
| null_ostream() {};
| //various required overloads...
| null_ostream& operator <<(bool)
| {
| return *this;
| }
| null_ostream& operator <<(short)
| {
| return *this;
| }
| //... and many more ....

How will this behave for user defined types?
Do I have to add a operator<< for both ostream and null_ostream?


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