[libc++] Complete overhaul of constexpr support in std::array
This commit adds missing support for constexpr in std::array under all standard modes up to and including C++20. It also transforms the <array> tests to check for constexpr-friendliness under the right standard modes. Fixes https://llvm.org/PR40124 Fixes rdar://57522096 Supersedes https://reviews.llvm.org/D60666 Differential Revision: https://reviews.llvm.org/D80452
This commit is contained in:
@@ -23,7 +23,8 @@
|
||||
#include "test_macros.h"
|
||||
#include "MoveOnly.h"
|
||||
|
||||
int main(int, char**) {
|
||||
constexpr bool tests()
|
||||
{
|
||||
// Test deduced type.
|
||||
{
|
||||
auto arr = std::to_array({1, 2, 3});
|
||||
@@ -110,13 +111,12 @@ int main(int, char**) {
|
||||
assert(arr[0].b == .1);
|
||||
}
|
||||
|
||||
// Test constexpr.
|
||||
{
|
||||
constexpr std::array<int, 3> arr = std::to_array({1, 2, 3});
|
||||
static_assert(arr[0] == 1);
|
||||
static_assert(arr[1] == 2);
|
||||
static_assert(arr[2] == 3);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
int main(int, char**)
|
||||
{
|
||||
tests();
|
||||
static_assert(tests(), "");
|
||||
return 0;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user