Why is calling a constexpr function with a member array not a constant expression?
I have the following helper function: template<typename T, std::size_t N> constexpr std::size_t Length(const T(&)[N]) { return N; } Which returns the length of a static array. In the past this always has worked but when I do this: struct Foo { unsigned int temp1[3]; void Bar() { constexpr std::size_t t = Length(temp1); // Error here } }; I get an error when using MSVS 2017: error C2131: expression did not evaluate to a constant note: failure was caused by a read of a variable outside its lifetime note: see usage of 'this' I was hoping someone can shed light on what I'm doing wrong. Rakete1111