mirror of
https://github.com/llvm-mirror/libcxx.git
synced 2025-10-23 01:18:52 +08:00
Implement the missing constexpr stuff in <array>. Fixes PR#31645.
git-svn-id: https://llvm.org/svn/llvm-project/libcxx/trunk@292091 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -9,10 +9,10 @@
|
||||
|
||||
// <array>
|
||||
|
||||
// reference front();
|
||||
// reference back();
|
||||
// reference front(); // constexpr in C++17
|
||||
// reference back(); // constexpr in C++17
|
||||
// const_reference front(); // constexpr in C++14
|
||||
// const_reference back(); // constexpr in C++14
|
||||
// const_reference back(); // constexpr in C++14
|
||||
|
||||
#include <array>
|
||||
#include <cassert>
|
||||
@@ -23,6 +23,20 @@
|
||||
// Disable the missing braces warning for this reason.
|
||||
#include "disable_missing_braces_warning.h"
|
||||
|
||||
#if TEST_STD_VER > 14
|
||||
constexpr bool check_front( double val )
|
||||
{
|
||||
std::array<double, 3> arr = {1, 2, 3.5};
|
||||
return arr.front() == val;
|
||||
}
|
||||
|
||||
constexpr bool check_back( double val )
|
||||
{
|
||||
std::array<double, 3> arr = {1, 2, 3.5};
|
||||
return arr.back() == val;
|
||||
}
|
||||
#endif
|
||||
|
||||
int main()
|
||||
{
|
||||
{
|
||||
@@ -65,4 +79,10 @@ int main()
|
||||
}
|
||||
#endif
|
||||
|
||||
#if TEST_STD_VER > 14
|
||||
{
|
||||
static_assert (check_front(1), "");
|
||||
static_assert (check_back (3.5), "");
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
Reference in New Issue
Block a user