fork download
  1. #include <iostream>
  2. #include <iomanip>
  3.  
  4. using namespace std;
  5.  
  6. template <typename T, typename = void>
  7. struct SupportsOstreamOperator : std::false_type {};
  8. template <typename T>
  9. struct SupportsOstreamOperator<T,
  10. decltype(void(std::declval<std::ostream>()
  11. << std::declval<T>()))>
  12. : std::true_type {};
  13.  
  14. struct Test{};
  15.  
  16. int main(int argc, char * argv[])
  17. {
  18. cout << SupportsOstreamOperator<int>::value << endl;
  19. cout << SupportsOstreamOperator<Test>::value << endl;
  20. }
  21.  
Success #stdin #stdout 0.01s 5304KB
stdin
Standard input is empty
stdout
1
0