fork(1) download
  1. #include <iostream>
  2. #include <type_traits>
  3. using namespace std;
  4.  
  5. struct A {
  6. A(int) {}
  7. };
  8.  
  9. struct B {
  10. B() {}
  11. };
  12.  
  13. template <typename T, typename = typename enable_if<is_constructible<T, int>::value>::type>
  14. bool foo(){
  15. return true;
  16. }
  17.  
  18. template <typename T, typename = typename enable_if<!is_constructible<T, int>::value>::type>
  19. bool foo(...) {
  20. return false;
  21. }
  22.  
  23. int main() {
  24. std::cout << foo<A>() << '\n';
  25. std::cout << foo<B>() << '\n';
  26. return 0;
  27. }
Success #stdin #stdout 0s 3140KB
stdin
Standard input is empty
stdout
1
0