Wrapper for a value that can be streamed to an output stream.
- Template Parameters
-
T | The type of the value to be wrapped. Must satisfy Streamable (i.e. it can be inserted into a std::ostream ). |
Implementation Details:
- Private Data Members:
value_
– the value of the metric
is_fail_
– indicates if the metric has failed
valid_
– indicates if the metric is valid. (eg. invalid if size mismatch between 2 vectors)
err_msg_
– is an error message if the metric is invalid. (eg. outputs "size mismatch" if the size of 2 vectors is different)
operator<<
:
- Copies the current formatting state of the stream with copyfmt
- Streams the value
value_
into a temporary std::ostringstream
- If the metric is valid and not failed, writes the value to the original stream. If the metric is valid but failed, writes the value in red color to the original stream. If the metric is invalid, writes the error message in red color to the original stream.
- Restores the saved formatting state