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