1 //===----------------------------------------------------------------------===//
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
11 // reference front(); // constexpr in C++17
12 // reference back(); // constexpr in C++17
17 #include "test_macros.h"
19 // std::array is explicitly allowed to be initialized with A a = { init-list };.
20 // Disable the missing braces warning for this reason.
21 #include "disable_missing_braces_warning.h"
24 TEST_CONSTEXPR_CXX17
bool tests()
28 typedef std::array
<T
, 3> C
;
31 C::reference r1
= c
.front();
36 C::reference r2
= c
.back();
43 typedef std::array
<T
, 0> C
;
45 ASSERT_SAME_TYPE(decltype(c
.back()), C::reference
);
46 LIBCPP_ASSERT_NOEXCEPT(c
.back());
47 ASSERT_SAME_TYPE(decltype(c
.front()), C::reference
);
48 LIBCPP_ASSERT_NOEXCEPT(c
.front());
49 if (c
.size() > (0)) { // always false
50 TEST_IGNORE_NODISCARD c
.front();
51 TEST_IGNORE_NODISCARD c
.back();
56 typedef std::array
<const T
, 0> C
;
58 ASSERT_SAME_TYPE(decltype( c
.back()), C::reference
);
59 LIBCPP_ASSERT_NOEXCEPT( c
.back());
60 ASSERT_SAME_TYPE(decltype( c
.front()), C::reference
);
61 LIBCPP_ASSERT_NOEXCEPT( c
.front());
63 TEST_IGNORE_NODISCARD c
.front();
64 TEST_IGNORE_NODISCARD c
.back();
74 #if TEST_STD_VER >= 17
75 static_assert(tests(), "");