#include <iomanip> #include <iostream> #include <string> #include <type_traits> template<typename T> struct impl_ostream_operator { template<class U> static auto test(U*) -> decltype(std::declval<std::ostream>() << std::declval<U>()); template<typename> static auto test(...) -> std::false_type; using type = typename std::is_same<std::ostream&, decltype(test<T>(nullptr))>::type; static constexpr bool value = type::value; }; template<typename T> using impl_ostream_operator_t = typename impl_ostream_operator<T>::type; template<typename T> constexpr bool impl_ostream_operator_v = impl_ostream_operator<T>::value; int main() { std::cout << std::boolalpha << impl_ostream_operator_v<double> // true << '\n' << impl_ostream_operator_v<std::string> // false << '\n'; }


ostream 오퍼레이터를 구현했는지 검사하는 템플릿을 만들고 싶은데

double 같은 기본 숫자 타입들은 원하는데로 작동하지만

std::string은 그렇지가 않네요

어디서 잘못되었을까요?