magic_enum::ostream_operators
C++ API reference for the namespace magic_enum::ostream_operators.
Public API
Free Function: operator<<
Canonical path: magic_enum::ostream_operators::operator<<
Declared in: include/magic_enum/magic_enum_iostream.hpp
Signatures
Overload 1
std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& os, E value);
Summary
Output stream operator for writing enum values to a stream.
Behavior
The operator attempts to retrieve the enum name using enum_flags_name for flags or enum_name otherwise; if a name is found, it is written to the stream character by character, otherwise the underlying numeric value is written.
Parameters
- os: The output stream to write to.
- value: The enum value to be written to the stream.
Returns
- Return value 1: A reference to the output stream.
Overload 2
std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& os, optional<E> value);
Summary
Output stream operator for writing optional enum values to a stream.
Behavior
If the optional contains a value, it is written to the stream using the enum's output operator; otherwise, the stream is returned unchanged.
Parameters
- os: The output stream to write to.
- value: The optional enum value to be written.
Returns
- Return value 1: A reference to the output stream.