-
Notifications
You must be signed in to change notification settings - Fork 15.2k
Labels
libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Description
The current implementation of vector<bool>::at() is not marked as constexpr in libc++, violating the C++20 standard, which requires all member functions of std::vector to be constexpr.
#include <vector>
constexpr bool test() {
std::vector<bool> v{true, true, true};
return v.at(0);
}
int main() {
static_assert(test());
return 0;
}The above code fails to compile in libc++, with the following error message:
<source>:9:19: error: static assertion expression is not an integral constant expression
9 | static_assert(test());
| ^~~~~~
<source>:5:14: note: non-constexpr function 'at' cannot be used in a constant expression
5 | return v.at(0);
We should mark the vector<bool>::at() member function as constexpr in libc++ to ensure compliance with the C++20 standard,
Metadata
Metadata
Assignees
Labels
libc++libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.