fork(31) download
  1. #include <type_traits>
  2. #include <iostream>
  3.  
  4. template <bool Mode>
  5. class Foo
  6. {
  7. public:
  8.  
  9. template <bool M = Mode, typename std::enable_if<M>::type* = nullptr>
  10. void bar()
  11. {
  12. std::cout << "true" << std::endl;
  13. }
  14.  
  15. template <bool M = Mode, typename std::enable_if<!M>::type* = nullptr>
  16. void bar()
  17. {
  18. std::cout << "false" << std::endl;
  19. }
  20. };
  21.  
  22. int main()
  23. {
  24. Foo<false> f;
  25.  
  26. f.bar();
  27. }
Success #stdin #stdout 0s 2852KB
stdin
Standard input is empty
stdout
false