#include <iostream>
#include <stdexcept>
constexpr int foo(int a)
{
return (a >= 0) ? a : throw std::invalid_argument("Negative!");
}
template <int n>
struct Foo
{
};
int main()
{
Foo<foo(1)> f1();
//Foo<foo(-1)> f2(); compile time error
foo(1);
try
{
foo(-1);
}
catch ( ... )
{
}
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RkZXhjZXB0PgoKY29uc3RleHByIGludCBmb28oaW50IGEpCnsKCXJldHVybiAoYSA+PSAwKSA/IGEgOiB0aHJvdyBzdGQ6OmludmFsaWRfYXJndW1lbnQoIk5lZ2F0aXZlISIpOwp9Cgp0ZW1wbGF0ZSA8aW50IG4+CnN0cnVjdCBGb28Kewp9OwoKaW50IG1haW4oKQp7CglGb288Zm9vKDEpPiBmMSgpOwoJLy9Gb288Zm9vKC0xKT4gZjIoKTsgY29tcGlsZSB0aW1lIGVycm9yCglmb28oMSk7Cgl0cnkKCXsKCQlmb28oLTEpOwoJfQoJY2F0Y2ggKCAuLi4gKQoJewoJfQoJcmV0dXJuIDA7Cn0K