constexpr
might run functions at compilation time. Is there a way to force it to compilation time only?
Sample code:
constexpr int BUILD(int i)
{
static_assert(0 == i);
i++;
return i;
}
enum Events
{
FIRST = BUILD(0)
};
The compilation error:
Error[Pe028]: expression must have a constant value
[Edit] Another example to explain the rationale:
constexpr int BUILD(int a, int b, int c, int d)
{
static_assert(a < b);
static_assert(b < c);
static_assert(c < d);
static_assert(d < 10);
return a+b+c+d;
}
enum Events
{
FIRST = BUILD(0, 4, 6, 9), //numbers are defined manually
SECOND = BUILD(2, 3, 7, 8),
THIRD = BUILD(0, 1, 2, 3),
};