Why is std::initializer_list<_E>::size not allowable in a static_assert, even though it\'s declared as a constexpr in my libstdc++ (v. 4.6)?
For example, the foll
From my discussion with @Evgeny, I realized that this just works (with gcc 4.8 c++11
) and may as well do the size check by only accepting a compatible size in the initializer list (in main
).
(code link: http://coliru.stacked-crooked.com/a/746e0ae99c518cd6)
#include
template
class Point
{
public:
Point(std::array init)
{
//not needed// static_assert(init.size() == Length, "Wrong number of dimensions");
}
};
int main()
{
Point q({1,2,3}); //ok
// Point q2({1,2,3,4}); //compile error (good!)
Point q2({1,2}); // ok, compiles, same as {1,2,0}, feature?
return 0;
}