#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;
}
