49 lines · cpp
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-exception6//7//===----------------------------------------------------------------------===//8 9// <array>10 11// template <size_t I, class T, size_t N> const T& get(const array<T, N>& a);12 13#include <array>14#include <cassert>15 16#include "test_macros.h"17 18TEST_CONSTEXPR_CXX14 bool tests() {19 {20 std::array<double, 1> const array = {3.3};21 assert(std::get<0>(array) == 3.3);22 }23 {24 std::array<double, 2> const array = {3.3, 4.4};25 assert(std::get<0>(array) == 3.3);26 assert(std::get<1>(array) == 4.4);27 }28 {29 std::array<double, 3> const array = {3.3, 4.4, 5.5};30 assert(std::get<0>(array) == 3.3);31 assert(std::get<1>(array) == 4.4);32 assert(std::get<2>(array) == 5.5);33 }34 {35 std::array<double, 1> const array = {3.3};36 static_assert(std::is_same<double const&, decltype(std::get<0>(array))>::value, "");37 }38 39 return true;40}41 42int main(int, char**) {43 tests();44#if TEST_STD_VER >= 1445 static_assert(tests(), "");46#endif47 return 0;48}49