fork download
  1. #include <iostream>
  2.  
  3. template <typename X, typename Y = typename X::template rebind<int>>
  4. struct has_rebind : std::false_type {};
  5.  
  6. template <typename X>
  7. struct has_rebind<X, typename X::template rebind<int>> : std::true_type {};
  8.  
  9. struct A { };
  10. struct B { template <typename > struct rebind { }; };
  11.  
  12. int main() {
  13. std::cout << has_rebind<A>::value << std::endl;
  14. std::cout << has_rebind<B>::value << std::endl;
  15. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In function 'int main()':
prog.cpp:13:30: error: no class template named 'rebind' in 'struct A'
     std::cout << has_rebind<A>::value << std::endl;
                              ^
prog.cpp:13:30: error: template argument 2 is invalid
stdout
Standard output is empty