fork download
  1. #include <iostream>
  2. #include <type_traits>
  3.  
  4. template <typename T> struct CSizex {};
  5.  
  6. struct CSize : public CSizex<int> {};
  7.  
  8. struct Logger
  9. {
  10. template <typename T>
  11. Logger& operator<<(const CSizex<T>& size)
  12. {
  13. std::cout << __PRETTY_FUNCTION__ << '\n';
  14. return *this;
  15. }
  16.  
  17. template <typename T>
  18. typename std::enable_if<std::is_arithmetic<T>::value
  19. || std::is_integral<T>::value
  20. || std::is_enum<T>::value, Logger&>::type
  21. operator<<(const T& value)
  22. {
  23. std::cout << __PRETTY_FUNCTION__ << '\n';
  24. return *this;
  25. }
  26. };
  27.  
  28. int main()
  29. {
  30. CSize size;
  31. Logger() << size;
  32. Logger() << CSize();
  33. Logger() << CSizex<float>();
  34. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
Logger& Logger::operator<<(const CSizex<T>&) [with T = int]
Logger& Logger::operator<<(const CSizex<T>&) [with T = int]
Logger& Logger::operator<<(const CSizex<T>&) [with T = float]