fork(12) download
  1. #include <iostream>
  2. #include <stdexcept>
  3.  
  4. constexpr int foo(int a)
  5. {
  6. return (a >= 0) ? a : throw std::invalid_argument("Negative!");
  7. }
  8.  
  9. template <int n>
  10. struct Foo
  11. {
  12. };
  13.  
  14. int main()
  15. {
  16. Foo<foo(1)> f1();
  17. //Foo<foo(-1)> f2(); compile time error
  18. foo(1);
  19. try
  20. {
  21. foo(-1);
  22. }
  23. catch ( ... )
  24. {
  25. }
  26. return 0;
  27. }
  28.  
Success #stdin #stdout 0s 3424KB
stdin
Standard input is empty
stdout
Standard output is empty