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
Use following syntax:
LIVE DEMO
#include
template
class Point
{
std::initializer_list data;
public:
constexpr Point(std::initializer_list init)
: data
(
init.size() == Length ?
init : throw 0
)
{}
};
int main()
{
constexpr Point a{{1,2,3}};
constexpr Point b{{1,2,3}}; // compile time error
}
Refer following SO.
EDIT: Interesting that works on GCC 4.8.1, but does not work on Clang 3.4. Maybe this is related to constexpr of .size() (afaik, in C++14 it is constexpr).