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 at (size_type); // constexpr in C++17
16 #ifndef TEST_HAS_NO_EXCEPTIONS
20 #include "test_macros.h"
22 TEST_CONSTEXPR_CXX17
bool tests()
26 typedef std::array
<T
, 3> C
;
28 typename
C::reference r1
= c
.at(0);
33 typename
C::reference r2
= c
.at(2);
41 void test_exceptions()
43 #ifndef TEST_HAS_NO_EXCEPTIONS
45 std::array
<int, 4> array
= {1, 2, 3, 4};
48 TEST_IGNORE_NODISCARD array
.at(4);
50 } catch (std::out_of_range
const&) {
57 TEST_IGNORE_NODISCARD array
.at(5);
59 } catch (std::out_of_range
const&) {
66 TEST_IGNORE_NODISCARD array
.at(6);
68 } catch (std::out_of_range
const&) {
75 using size_type
= decltype(array
)::size_type
;
76 TEST_IGNORE_NODISCARD array
.at(static_cast<size_type
>(-1));
78 } catch (std::out_of_range
const&) {
86 std::array
<int, 0> array
= {};
89 TEST_IGNORE_NODISCARD array
.at(0);
91 } catch (std::out_of_range
const&) {
100 int main(int, char**)
105 #if TEST_STD_VER >= 17
106 static_assert(tests(), "");