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 TEST_CONSTEXPR_CXX17
bool tests()
23 typedef std::array
<T
, 3> C
;
26 C::reference r1
= c
.front();
31 C::reference r2
= c
.back();
38 typedef std::array
<T
, 0> C
;
40 ASSERT_SAME_TYPE(decltype(c
.back()), C::reference
);
41 LIBCPP_ASSERT_NOEXCEPT(c
.back());
42 ASSERT_SAME_TYPE(decltype(c
.front()), C::reference
);
43 LIBCPP_ASSERT_NOEXCEPT(c
.front());
44 if (c
.size() > (0)) { // always false
45 TEST_IGNORE_NODISCARD c
.front();
46 TEST_IGNORE_NODISCARD c
.back();
51 typedef std::array
<const T
, 0> C
;
53 ASSERT_SAME_TYPE(decltype( c
.back()), C::reference
);
54 LIBCPP_ASSERT_NOEXCEPT( c
.back());
55 ASSERT_SAME_TYPE(decltype( c
.front()), C::reference
);
56 LIBCPP_ASSERT_NOEXCEPT( c
.front());
58 TEST_IGNORE_NODISCARD c
.front();
59 TEST_IGNORE_NODISCARD c
.back();
69 #if TEST_STD_VER >= 17
70 static_assert(tests(), "");