Jamba C++ API 8.0.0
Loading...
Searching...
No Matches
pongasoft::Utils::OstreamWritable Concept Reference

Allows to detect whether a type defines ostream << x at compile time. More...

#include <Metaprogramming.h>

Concept definition

template<typename T>
concept OstreamWritable =
requires(std::ostream& os, T const& t)
{
{ os << t } -> std::same_as<std::ostream&>;
}
Allows to detect whether a type defines ostream << x at compile time.
Definition Metaprogramming.h:103

Detailed Description

Allows to detect whether a type defines ostream << x at compile time.

Example:

if constexpr (Utils::is_operator_write_to_ostream_defined<MyType>) {
// implementation allows to write std::cout << x // (with x of type MyType)
} else {
// no such operator... alternate implementation
}