1//===----------------------------------------------------------------------===// 2// 3// The LLVM Compiler Infrastructure 4// 5// This file is dual licensed under the MIT and the University of Illinois Open 6// Source Licenses. See LICENSE.TXT for details. 7// 8//===----------------------------------------------------------------------===// 9 10// <array> 11 12// reference front(); 13// reference back(); 14// const_reference front(); // constexpr in C++14 15// const_reference back(); // constexpr in C++14 16 17#include <array> 18#include <cassert> 19 20int main() 21{ 22 { 23 typedef double T; 24 typedef std::array<T, 3> C; 25 C c = {1, 2, 3.5}; 26 27 C::reference r1 = c.front(); 28 assert(r1 == 1); 29 r1 = 5.5; 30 assert(c[0] == 5.5); 31 32 C::reference r2 = c.back(); 33 assert(r2 == 3.5); 34 r2 = 7.5; 35 assert(c[2] == 7.5); 36 } 37 { 38 typedef double T; 39 typedef std::array<T, 3> C; 40 const C c = {1, 2, 3.5}; 41 C::const_reference r1 = c.front(); 42 assert(r1 == 1); 43 44 C::const_reference r2 = c.back(); 45 assert(r2 == 3.5); 46 } 47 48#if _LIBCPP_STD_VER > 11 49 { 50 typedef double T; 51 typedef std::array<T, 3> C; 52 constexpr C c = {1, 2, 3.5}; 53 54 constexpr T t1 = c.front(); 55 static_assert (t1 == 1, ""); 56 57 constexpr T t2 = c.back(); 58 static_assert (t2 == 3.5, ""); 59 } 60#endif 61 62} 63