diff --git a/include/json.hpp b/include/json.hpp index 41546ae..a3e3505 100644 --- a/include/json.hpp +++ b/include/json.hpp @@ -2528,11 +2528,13 @@ MEOJSON_INLINE const basic_value invalid_value() namespace _serialization_helper { - template + template class has_output_operator { + using ostringstream_t = std::basic_ostringstream, std::allocator>; + template - static auto test(int) -> decltype(std::declval() << std::declval(), std::true_type()); + static auto test(int) -> decltype(std::declval() << std::declval(), std::true_type()); template static std::false_type test(...); @@ -2566,17 +2568,12 @@ namespace _serialization_helper template MEOJSON_INLINE string_t to_stream_string(input_t&& arg) { - if constexpr (has_output_operator::value) { - using char_t = typename string_t::value_type; - using stringstream_t = std::basic_stringstream, std::allocator>; + using char_t = typename string_t::value_type; + using ostringstream_t = std::basic_ostringstream, std::allocator>; - stringstream_t ss; - ss << std::forward(arg); - return std::move(ss).str(); - } - else { - static_assert(!sizeof(input_t), "Unable to convert type to string, there is no operator <<."); - } + ostringstream_t os; + os << std::forward(arg); + return std::move(os).str(); } template