Cbeam
|
The has_insertion_operator
trait provides static meta-information about whether a type T has overloaded the operator<<
for insertion into an output stream.
More...
#include <string.hpp>
The has_insertion_operator
trait provides static meta-information about whether a type T has overloaded the operator<<
for insertion into an output stream.
This trait is useful for template metaprogramming and generic programming, allowing you to write code that works differently depending on whether a type can be streamed or not.
T
: The type to be checked for the existence of an overload for operator<<
.U
: (optional) An unused template parameter used to enable SFINAE (Substitution Failure Is Not An Error).value
: A static constant bool
member that is true
if and only if T
has an overload for operator<<
, and false
otherwise.std::false_type
, indicating that by default, types do not have an overload for operator<<
.T
for which a valid overload for operator<<
is found. This specialization uses std::void_t<decltype(std::declval<std::ostream&>() << std::declval<T>())>
to ensure that the overload is actually callable.std::ostream
operator<<
std::enable_if
std::declval
std::void_t