fork download
  1. #include <iostream>
  2.  
  3. template<typename T>
  4. struct to_void
  5. {
  6. typedef void type;
  7. };
  8.  
  9. class Foo
  10. {
  11. friend struct Checker;
  12.  
  13. typedef int TD;
  14. };
  15.  
  16. struct Checker
  17. {
  18. template <typename T, typename dummy = void>
  19. struct has_TD : std::false_type {};
  20.  
  21. template <typename T>
  22. struct has_TD<T, typename to_void<typename T::TD>::type > : std::true_type{};
  23. };
  24.  
  25. int main()
  26. {
  27. std::cout << std::boolalpha << Checker::has_TD<Foo>::value << std::endl;
  28. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:13:14: error: 'typedef int Foo::TD' is private
  typedef int TD;
              ^
prog.cpp:27:33: error: within this context
  std::cout << std::boolalpha << Checker::has_TD<Foo>::value << std::endl;
                                 ^
stdout
Standard output is empty