Function get

Synopsis

#include "breeze/stream/stream_equivalent.hpp"

stream_type & get() noexcept

Description

Returns
A reference to a stream equivalent to that passed to the first constructor. This is the stream that must be used to do the actual output.
Warning
Use the stream equivalent to do the actual output but do not return a reference to it from the inserter! Return a reference to the original stream, instead.
Example:
std::ostream &
operator <<( std::ostream & original_stream,
             my_type const & m )
{
    stream_equivalent< std::ostream >
                        equiv( original_stream ) ;
    std::ostream &      os = equiv.get() ;

    /* do output through 'os' */

    // Do not write: return os!
    //
    return original_stream ;
}

Note that this may occur if you "adapt" an existing inserter which didn't use stream_equivalent, by simply renaming the stream parameter from os to original_stream and "reusing" the old parameter name for the stream equivalent: this will also leave the return statement intact, returning a reference to a sub-object of the local variable equiv.

Source

Line 152 in breeze/stream/stream_equivalent.hpp.