Is it valid to use constexpr function as template argument?

Viewed 1607
constexpr int get () { return 5; }
template<int N> struct Test {};

int main ()
{
  int a[get()];  // ok
  Test< get() > obj;  // error:'int get()' cannot appear in a constant-expression
}

I have compiled this code with ideone. And was wondering that why it's giving compilation error. Is constexpr function not allowed as template argument or it's a bug in the compiler ?

Edit: changed const int get() to int get() Moreover, there is one more bug with ideone is that, if you remove constexpr then still declaring an array is allowed!! I think that's a C99 feature.

1 Answers
Related