Кажется, мне не хватает чего-то довольно фундаментального. Я пытаюсь использовать члены массива const во время компиляции.
const int list[3] = { 2, 5, 7 };
const int a = list[2]; // this doesn't error?
template
struct tmax {
enum { value = ((N1 > N2) ? N1 : N2) };
};
const int b = tmax<2,4>::value;
const int c = tmax::value; // error is here
int main()
{
return 0;
}
Ошибки:
prog.cpp:10:24: error: 'list' cannot appear in a constant-expression
prog.cpp:10:30: error: an array reference cannot appear in a constant-expression
Вот соответствующая ссылка на IDEOne
Так почему же это не работает? Что мне не хватает? Что мне делать по-другому?