[RISCV] Add MIPS P8700 processor (#119882)
[llvm-project.git] / libcxx / test / std / containers / sequences / array / front_back_const.pass.cpp
blob9204663f0da3cbf91fbef15a6bbf586d79239361
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 // <array>
11 // const_reference front() const; // constexpr in C++14
12 // const_reference back() const; // constexpr in C++14
14 #include <array>
15 #include <cassert>
17 #include "test_macros.h"
19 TEST_CONSTEXPR_CXX14 bool tests()
22 typedef double T;
23 typedef std::array<T, 3> C;
24 C const c = {1, 2, 3.5};
25 C::const_reference r1 = c.front();
26 assert(r1 == 1);
28 C::const_reference r2 = c.back();
29 assert(r2 == 3.5);
32 typedef double T;
33 typedef std::array<T, 0> C;
34 C const c = {};
35 ASSERT_SAME_TYPE(decltype(c.back()), C::const_reference);
36 LIBCPP_ASSERT_NOEXCEPT(c.back());
37 ASSERT_SAME_TYPE(decltype(c.front()), C::const_reference);
38 LIBCPP_ASSERT_NOEXCEPT(c.front());
39 if (c.size() > (0)) { // always false
40 TEST_IGNORE_NODISCARD c.front();
41 TEST_IGNORE_NODISCARD c.back();
45 typedef double T;
46 typedef std::array<const T, 0> C;
47 C const c = {};
48 ASSERT_SAME_TYPE(decltype(c.back()), C::const_reference);
49 LIBCPP_ASSERT_NOEXCEPT(c.back());
50 ASSERT_SAME_TYPE(decltype(c.front()), C::const_reference);
51 LIBCPP_ASSERT_NOEXCEPT(c.front());
52 if (c.size() > (0)) {
53 TEST_IGNORE_NODISCARD c.front();
54 TEST_IGNORE_NODISCARD c.back();
58 return true;
61 int main(int, char**)
63 tests();
64 #if TEST_STD_VER >= 14
65 static_assert(tests(), "");
66 #endif
67 return 0;