|
|
|
@@ -224,6 +224,8 @@ namespace cppcore |
|
|
|
template<typename T> |
|
|
|
struct op_to_stream<T, std::enable_if_t<std::is_enum_v<T>>> |
|
|
|
{ |
|
|
|
static constexpr decltype(auto) enable_streaming = true; |
|
|
|
|
|
|
|
inline void operator()(std::ostream& os, const T& v) const |
|
|
|
{ os << enum_conversion<T>::to_string(v); } |
|
|
|
}; |
|
|
|
@@ -231,6 +233,8 @@ namespace cppcore |
|
|
|
template<typename T> |
|
|
|
struct op_to_stream<T, decltype(std::declval<T>().to_string(std::declval<std::ostream&>()), void())> |
|
|
|
{ |
|
|
|
static constexpr decltype(auto) enable_streaming = true; |
|
|
|
|
|
|
|
inline void operator()(std::ostream& os, const T& v) const |
|
|
|
{ v.to_string(os); } |
|
|
|
}; |
|
|
|
@@ -238,6 +242,8 @@ namespace cppcore |
|
|
|
template<typename T> |
|
|
|
struct op_to_stream<T, decltype(std::declval<T>().to_string(), void())> |
|
|
|
{ |
|
|
|
static constexpr decltype(auto) enable_streaming = true; |
|
|
|
|
|
|
|
inline void operator()(std::ostream& os, const T& v) const |
|
|
|
{ os << v.to_string(); } |
|
|
|
}; |
|
|
|
@@ -246,6 +252,8 @@ namespace cppcore |
|
|
|
template<typename T> |
|
|
|
struct op_to_stream<std::vector<T>, void> |
|
|
|
{ |
|
|
|
static constexpr decltype(auto) enable_streaming = true; |
|
|
|
|
|
|
|
inline void operator()(std::ostream& os, const std::vector<T>& v) const |
|
|
|
{ |
|
|
|
bool first = true; |
|
|
|
@@ -263,6 +271,8 @@ namespace cppcore |
|
|
|
template<typename T> |
|
|
|
struct op_to_stream<std::list<T>, void> |
|
|
|
{ |
|
|
|
static constexpr decltype(auto) enable_streaming = true; |
|
|
|
|
|
|
|
inline void operator()(std::ostream& os, const std::list<T>& v) const |
|
|
|
{ |
|
|
|
bool first = true; |
|
|
|
@@ -420,21 +430,12 @@ namespace std |
|
|
|
|
|
|
|
template<typename T_char, typename T_traits, typename X> |
|
|
|
inline auto operator<<(basic_ostream<T_char, T_traits>& os, X&& x) |
|
|
|
-> decltype( |
|
|
|
std::forward<X>(x).to_string(std::declval<basic_ostream<T_char, T_traits>&>()), |
|
|
|
std::declval<basic_ostream<T_char, T_traits>&>()) |
|
|
|
{ |
|
|
|
std::forward<X>(x).to_string(os); |
|
|
|
return os; |
|
|
|
} |
|
|
|
|
|
|
|
template<typename T_char, typename T_traits, typename X> |
|
|
|
inline auto operator<<(basic_ostream<T_char, T_traits>& os, X&& x) |
|
|
|
-> decltype( |
|
|
|
std::forward<X>(x).to_string(), |
|
|
|
std::declval<basic_ostream<T_char, T_traits>&>()) |
|
|
|
-> std::enable_if_t< |
|
|
|
cppcore::__impl::op_to_stream<std::decay_t<X>>::enable_streaming, |
|
|
|
basic_ostream<T_char, T_traits>&> |
|
|
|
{ |
|
|
|
os << std::forward<X>(x).to_string(); |
|
|
|
using op_type = cppcore::__impl::op_to_stream<std::decay_t<X>>; |
|
|
|
op_type()(os, std::forward<X>(x)); |
|
|
|
return os; |
|
|
|
} |
|
|
|
|
|
|
|
|