
Le 10/01/13 19:13, Andrey Semashev a écrit :
On Thu, Jan 10, 2013 at 9:06 PM, Vicente J. Botet Escriba <vicente.botet@wanadoo.fr> wrote:
Have you tried declaring arr as a constexpr? It doesn't make any difference, the error is the same.
The constructor for array must be declared constexpr as well. The following works with clang 3.1, 3.2 and gcc 4.7.1, 4.7.2. I have no access to other C++11 compilers now. Could you try it? Best, Vicente // Note the comments //******** template< typename T, unsigned int n > struct array { constexpr array() {}; // *************** constexpr T at(unsigned int i) const { return i < n ? T() : throw 0; } }; template< int m > struct check { static int get() { return m; } }; int main(int, char*[]) { constexpr array< int, 5 > arr; // *************** check< arr.at(3) > a; return a.get(); // *************** }