I have a constexpr function that looks something like this:
constexpr int foo(int bar)
{
static_assert(bar>arbitrary_number, "Use a lower number please");
return something_const;
}
However, compiling this with GCC 4.6.3 keeps telling me
error: 'bar' cannot appear in a constant-expression
I tried something like
constexpr int foo(constexpr const int bar)
{
static_assert(bar>arbitrary_number, "Use a lower number please");
return something_const;
}
but constexpr can't be used for function arguments.
Is there some simple way to tell the compiler that bar is always a compile time constant?