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 // const_reference at (size_type) const; // constexpr in C++14
16 #ifndef TEST_HAS_NO_EXCEPTIONS
20 #include "test_macros.h"
22 TEST_CONSTEXPR_CXX14
bool tests()
26 typedef std::array
<T
, 3> C
;
27 C
const c
= {1, 2, 3.5};
28 typename
C::const_reference r1
= c
.at(0);
31 typename
C::const_reference r2
= c
.at(2);
37 void test_exceptions()
39 #ifndef TEST_HAS_NO_EXCEPTIONS
41 std::array
<int, 4> const array
= {1, 2, 3, 4};
44 TEST_IGNORE_NODISCARD array
.at(4);
46 } catch (std::out_of_range
const&) {
53 TEST_IGNORE_NODISCARD array
.at(5);
55 } catch (std::out_of_range
const&) {
62 TEST_IGNORE_NODISCARD array
.at(6);
64 } catch (std::out_of_range
const&) {
71 using size_type
= decltype(array
)::size_type
;
72 TEST_IGNORE_NODISCARD array
.at(static_cast<size_type
>(-1));
74 } catch (std::out_of_range
const&) {
82 std::array
<int, 0> array
= {};
85 TEST_IGNORE_NODISCARD array
.at(0);
87 } catch (std::out_of_range
const&) {
101 #if TEST_STD_VER >= 14
102 static_assert(tests(), "");