#include <samples/samples_output.hpp>
Public Member Functions | |
| SampleOutput (const SampleOutput &)=default | |
| constexpr | SampleOutput (OS &os) |
| template<typename T, SampleOutputTarget Tgt> | |
| constexpr | SampleOutput (const SampleOutput< T, Tgt > &other) |
| constexpr SampleOutput< OS, SAMPLE_NORMAL_OUTPUT > | out () |
| constexpr auto | normal () |
| constexpr SampleOutput< OS, SAMPLE_TEST_OUTPUT > | expected () |
| constexpr auto | expect () |
| constexpr SampleOutput< OS, SAMPLE_ALWAYS_OUTPUT > | always () |
| constexpr auto | both () |
| template<typename T> | |
| constexpr SampleOutput & | operator<< (T &&v) |
A SampleOutput<T> object wraps a reference to a stream of type T.
If T is either std::ostream or std::wostream then the default constructor will wrap std::cout or std::wcout respectively.
SampleOutput has deduction guides which allow the template parameters to be avoided in most cases.
The wrapper can be used as a stream with the << operator. It also has methods that can return different wrapper objects:
Each of those is a SampleOutput object in its own right, wrapping a reference to the same underlying stream.
When performing the sample program tests, each sample program is built twice, once with the macro UGMISC_SAMPLES_GENERATE_TEST_OUTPUT defined. In the example above, these two programs compile slightly differently:
The normal build is equivalent to this:
The test program is equivalent to:
Then the two programs' outputs are compared.
| OS | The type of output stream to reference. |
Definition at line 127 of file samples_output.hpp.
|
inlineconstexpr |
Definition at line 170 of file samples_output.hpp.
|
inlineconstexpr |
Definition at line 172 of file samples_output.hpp.
|
inlineconstexpr |
A SampleOutput will never try to wrap another SampleOutput as if it would another type of stream. It will always try to take the same underlying reference instead.
If that can't be done due to stream type incompatibility, then the attempt will be an error.
Definition at line 183 of file samples_output.hpp.
|
inlineconstexpr |
Definition at line 194 of file samples_output.hpp.
|
inlineconstexpr |
Definition at line 195 of file samples_output.hpp.
|
inlineconstexpr |
Definition at line 192 of file samples_output.hpp.
|
inlineconstexpr |
Definition at line 191 of file samples_output.hpp.
|
inlineconstexpr |
Definition at line 189 of file samples_output.hpp.
|
inlineconstexpr |
Definition at line 198 of file samples_output.hpp.
|
inlineconstexpr |
Definition at line 188 of file samples_output.hpp.
|
friend |
Definition at line 131 of file samples_output.hpp.