fork(4) download
  1. // enabl.cc -*- mode:c++, compile-command:"g++ -Wall -Wextra -pedantic -std=c++0x enabl.cc -o enabl && ./enabl" -*-
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <vector>
  5.  
  6. template <bool R, bool W>
  7. struct X {
  8. template <bool Enabled = R,
  9. typename = typename std::enable_if<Enabled>::type>
  10. void read() {}
  11. template <bool Enabled = W,
  12. typename = typename std::enable_if<Enabled>::type>
  13. void write() {}
  14. bool is_open() const {};
  15. };
  16.  
  17. int main()
  18. {
  19. { X<true, true> x; x.read(); x.write(); }
  20. { X<false, true> x; x.write(); }
  21. { X<true, false> x; x.read(); }
  22. { X<false, false> x; }
  23. }
  24.  
  25.  
Success #stdin #stdout 0s 2880KB
stdin
Standard input is empty
stdout
Standard output is empty