fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. template<size_t aa, size_t bb>
  5. class C {
  6. public:
  7. C() {
  8. static_assert(aa > 0, "aa must be > 0");
  9. static_assert(bb > 0, "bb must be > 0");
  10. static_assert((aa + bb) <= 10, "aa + bb must be <= 10");
  11. }
  12. };
  13.  
  14. int main() {
  15. C<1, 2> c1; // OK
  16. C<5, 6> c2; // error
  17. return 0;
  18. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp: In instantiation of ‘C<aa, bb>::C() [with long unsigned int aa = 5; long unsigned int bb = 6]’:
prog.cpp:16:10:   required from here
prog.cpp:10:30: error: static assertion failed: aa + bb must be <= 10
      static_assert((aa + bb) <= 10, "aa + bb must be <= 10");
                    ~~~~~~~~~~^~~~~
stdout
Standard output is empty