fork(2) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<typename T, size_t w = 0, size_t h = 0> struct C
  5. {
  6. void out()
  7. {
  8. static_assert(w > 0 && h > 0, "both w and h are either 0 or > 0");
  9. cout << "instanciated with w = " << w << ", h = " << h << endl;
  10. }
  11. };
  12.  
  13. template<typename T> struct C<T, 0, 0>
  14. {
  15. void out()
  16. {
  17. cout << "no w/h specified" << endl;
  18. }
  19. };
  20.  
  21. int main()
  22. {
  23. C<int> cint;
  24. cint.out();
  25. //C<int, 1> cnum; // fires static_assert, as expected
  26. //cnum.out();
  27. C<int, 1, 1> cnum2;
  28. cnum2.out();
  29. return 0;
  30. }
Success #stdin #stdout 0s 3296KB
stdin
Standard input is empty
stdout
no w/h specified
instanciated with w = 1, h = 1