Why is std::array::size constexpr with simple types (int, double, …) but not std::vector (GCC)?

会有一股神秘感。 提交于 2019-11-30 17:24:36

I think this is a related to CWG issue 1684. Previously, the constexpr requirements included:

The class of which a constexpr function is a member shall be a literal type

And std::array<std::vector<int>, 4> is not a literal type, and hence its size() member function would not be constexpr. However, the new wording allows for a constexpr non-static member functions for non-literal types, assuming those functions meet all the other requirements of constexpr (which array<T,N>::size() clearly does).

Per the new wording, this is a gcc bug. Previously filed as 66297.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!