15a83710eSEric Fiselier //===----------------------------------------------------------------------===// 25a83710eSEric Fiselier // 35a83710eSEric Fiselier // The LLVM Compiler Infrastructure 45a83710eSEric Fiselier // 55a83710eSEric Fiselier // This file is dual licensed under the MIT and the University of Illinois Open 65a83710eSEric Fiselier // Source Licenses. See LICENSE.TXT for details. 75a83710eSEric Fiselier // 85a83710eSEric Fiselier //===----------------------------------------------------------------------===// 95a83710eSEric Fiselier 105a83710eSEric Fiselier // <array> 115a83710eSEric Fiselier 125a83710eSEric Fiselier // template <size_t I, class T, size_t N> T& get(array<T, N>& a); 135a83710eSEric Fiselier 142decfad7SEric Fiselier // Prevent -Warray-bounds from issuing a diagnostic when testing with clang verify. 152decfad7SEric Fiselier #if defined(__clang__) 162decfad7SEric Fiselier #pragma clang diagnostic ignored "-Warray-bounds" 172decfad7SEric Fiselier #endif 182decfad7SEric Fiselier 195a83710eSEric Fiselier #include <array> 205a83710eSEric Fiselier #include <cassert> 215a83710eSEric Fiselier 22b4e2e7a2SEric Fiselier 23b4e2e7a2SEric Fiselier // std::array is explicitly allowed to be initialized with A a = { init-list };. 24b4e2e7a2SEric Fiselier // Disable the missing braces warning for this reason. 25b4e2e7a2SEric Fiselier #include "disable_missing_braces_warning.h" 262decfad7SEric Fiselier 275a83710eSEric Fiselier int main() 285a83710eSEric Fiselier { 295a83710eSEric Fiselier { 305a83710eSEric Fiselier typedef double T; 315a83710eSEric Fiselier typedef std::array<T, 3> C; 325a83710eSEric Fiselier C c = {1, 2, 3.5}; 33abd52cadSEric Fiselier std::get<3>(c) = 5.5; // expected-note {{requested here}} 34*241c73b1SEric Fiselier // expected-error-re@array:* {{static_assert failed{{( due to requirement '3U[L]{0,2} < 3U[L]{0,2}')?}} "Index out of bounds in std::get<> (std::array)"}} 355a83710eSEric Fiselier } 365a83710eSEric Fiselier } 37