fork(8) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. struct Logger
  6. {
  7. template<typename Type>
  8. constexpr bool IsRawString()
  9. {
  10. return std::is_same<const char*, Type>::value || std::is_same<char*, Type>::value;
  11. }
  12.  
  13. template<typename Type, typename Enable = void>
  14. struct Traits
  15. {
  16. static const int Index = 1;
  17. };
  18.  
  19. template<typename Type>
  20. struct Traits<Type, std::enable_if_t<IsRawString<Type>()>>
  21. {
  22. static const int Index = 2;
  23. };
  24.  
  25. template<typename Type>
  26. struct Traits<Type, std::enable_if_t<std::is_pointer<Type>::value && !IsRawString<Type>()>>
  27. {
  28. static const int Index = 3;
  29. };
  30.  
  31. };
  32.  
  33. int main()
  34. {
  35. cout << Logger::Traits<int>::Index << endl
  36. << Logger::Traits<char*>::Index << endl
  37. << Logger::Traits<const char*>::Index << endl
  38. << Logger::Traits<void*>::Index << endl;
  39.  
  40.  
  41. return 0;
  42. }
  43.  
Success #stdin #stdout 0s 15224KB
stdin
Standard input is empty
stdout
1
1
1
1