13e519524SHoward Hinnant// -*- C++ -*- 23e519524SHoward Hinnant//===---------------------------- array -----------------------------------===// 33e519524SHoward Hinnant// 45b08a8a4SHoward Hinnant// The LLVM Compiler Infrastructure 53e519524SHoward Hinnant// 6412dbebeSHoward Hinnant// This file is dual licensed under the MIT and the University of Illinois Open 7412dbebeSHoward Hinnant// Source Licenses. See LICENSE.TXT for details. 83e519524SHoward Hinnant// 93e519524SHoward Hinnant//===----------------------------------------------------------------------===// 103e519524SHoward Hinnant 113e519524SHoward Hinnant#ifndef _LIBCPP_ARRAY 123e519524SHoward Hinnant#define _LIBCPP_ARRAY 133e519524SHoward Hinnant 143e519524SHoward Hinnant/* 153e519524SHoward Hinnant array synopsis 163e519524SHoward Hinnant 173e519524SHoward Hinnantnamespace std 183e519524SHoward Hinnant{ 193e519524SHoward Hinnanttemplate <class T, size_t N > 203e519524SHoward Hinnantstruct array 213e519524SHoward Hinnant{ 223e519524SHoward Hinnant // types: 233e519524SHoward Hinnant typedef T & reference; 243e519524SHoward Hinnant typedef const T & const_reference; 253e519524SHoward Hinnant typedef implementation defined iterator; 263e519524SHoward Hinnant typedef implementation defined const_iterator; 273e519524SHoward Hinnant typedef size_t size_type; 283e519524SHoward Hinnant typedef ptrdiff_t difference_type; 293e519524SHoward Hinnant typedef T value_type; 303e519524SHoward Hinnant typedef T* pointer; 313e519524SHoward Hinnant typedef const T* const_pointer; 323e519524SHoward Hinnant typedef std::reverse_iterator<iterator> reverse_iterator; 333e519524SHoward Hinnant typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 343e519524SHoward Hinnant 353e519524SHoward Hinnant // No explicit construct/copy/destroy for aggregate type 363e519524SHoward Hinnant void fill(const T& u); 37f07dd8d0SEric Fiselier void swap(array& a) noexcept(is_nothrow_swappable_v<T>); 383e519524SHoward Hinnant 393e519524SHoward Hinnant // iterators: 408f0cd597SHoward Hinnant iterator begin() noexcept; 418f0cd597SHoward Hinnant const_iterator begin() const noexcept; 428f0cd597SHoward Hinnant iterator end() noexcept; 438f0cd597SHoward Hinnant const_iterator end() const noexcept; 443e519524SHoward Hinnant 458f0cd597SHoward Hinnant reverse_iterator rbegin() noexcept; 468f0cd597SHoward Hinnant const_reverse_iterator rbegin() const noexcept; 478f0cd597SHoward Hinnant reverse_iterator rend() noexcept; 488f0cd597SHoward Hinnant const_reverse_iterator rend() const noexcept; 493e519524SHoward Hinnant 508f0cd597SHoward Hinnant const_iterator cbegin() const noexcept; 518f0cd597SHoward Hinnant const_iterator cend() const noexcept; 528f0cd597SHoward Hinnant const_reverse_iterator crbegin() const noexcept; 538f0cd597SHoward Hinnant const_reverse_iterator crend() const noexcept; 543e519524SHoward Hinnant 553e519524SHoward Hinnant // capacity: 568f0cd597SHoward Hinnant constexpr size_type size() const noexcept; 578f0cd597SHoward Hinnant constexpr size_type max_size() const noexcept; 58397717b7SHoward Hinnant constexpr bool empty() const noexcept; 593e519524SHoward Hinnant 603e519524SHoward Hinnant // element access: 613e519524SHoward Hinnant reference operator[](size_type n); 628bf1f08aSMarshall Clow const_reference operator[](size_type n) const; // constexpr in C++14 638bf1f08aSMarshall Clow const_reference at(size_type n) const; // constexpr in C++14 643e519524SHoward Hinnant reference at(size_type n); 653e519524SHoward Hinnant 663e519524SHoward Hinnant reference front(); 678bf1f08aSMarshall Clow const_reference front() const; // constexpr in C++14 683e519524SHoward Hinnant reference back(); 698bf1f08aSMarshall Clow const_reference back() const; // constexpr in C++14 703e519524SHoward Hinnant 718f0cd597SHoward Hinnant T* data() noexcept; 728f0cd597SHoward Hinnant const T* data() const noexcept; 733e519524SHoward Hinnant}; 743e519524SHoward Hinnant 753e519524SHoward Hinnanttemplate <class T, size_t N> 763e519524SHoward Hinnant bool operator==(const array<T,N>& x, const array<T,N>& y); 773e519524SHoward Hinnanttemplate <class T, size_t N> 783e519524SHoward Hinnant bool operator!=(const array<T,N>& x, const array<T,N>& y); 793e519524SHoward Hinnanttemplate <class T, size_t N> 803e519524SHoward Hinnant bool operator<(const array<T,N>& x, const array<T,N>& y); 813e519524SHoward Hinnanttemplate <class T, size_t N> 823e519524SHoward Hinnant bool operator>(const array<T,N>& x, const array<T,N>& y); 833e519524SHoward Hinnanttemplate <class T, size_t N> 843e519524SHoward Hinnant bool operator<=(const array<T,N>& x, const array<T,N>& y); 853e519524SHoward Hinnanttemplate <class T, size_t N> 863e519524SHoward Hinnant bool operator>=(const array<T,N>& x, const array<T,N>& y); 873e519524SHoward Hinnant 883e519524SHoward Hinnanttemplate <class T, size_t N > 898f0cd597SHoward Hinnant void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y))); 903e519524SHoward Hinnant 913e519524SHoward Hinnanttemplate <class T> class tuple_size; 925fcc8169SMarshall Clowtemplate <size_t I, class T> class tuple_element; 933e519524SHoward Hinnanttemplate <class T, size_t N> struct tuple_size<array<T, N>>; 945fcc8169SMarshall Clowtemplate <size_t I, class T, size_t N> struct tuple_element<I, array<T, N>>; 955fcc8169SMarshall Clowtemplate <size_t I, class T, size_t N> T& get(array<T, N>&) noexcept; // constexpr in C++14 965fcc8169SMarshall Clowtemplate <size_t I, class T, size_t N> const T& get(const array<T, N>&) noexcept; // constexpr in C++14 975fcc8169SMarshall Clowtemplate <size_t I, class T, size_t N> T&& get(array<T, N>&&) noexcept; // constexpr in C++14 98545b8861SEric Fiseliertemplate <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexcept; // constexpr in C++14 993e519524SHoward Hinnant 1003e519524SHoward Hinnant} // std 1013e519524SHoward Hinnant 1023e519524SHoward Hinnant*/ 1033e519524SHoward Hinnant 1043e519524SHoward Hinnant#include <__config> 1053e519524SHoward Hinnant#include <__tuple> 1063e519524SHoward Hinnant#include <type_traits> 1073e519524SHoward Hinnant#include <utility> 1083e519524SHoward Hinnant#include <iterator> 1093e519524SHoward Hinnant#include <algorithm> 1103e519524SHoward Hinnant#include <stdexcept> 111*59cdf90aSEric Fiselier#include <cstdlib> // for _LIBCPP_UNREACHABLE 112*59cdf90aSEric Fiselier#include <__debug> 1133e519524SHoward Hinnant 114073458b1SHoward Hinnant#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 1153e519524SHoward Hinnant#pragma GCC system_header 116073458b1SHoward Hinnant#endif 1173e519524SHoward Hinnant 118a016efb1SEric Fiselier 119a016efb1SEric Fiselier 1203e519524SHoward Hinnant_LIBCPP_BEGIN_NAMESPACE_STD 1213e519524SHoward Hinnant 122*59cdf90aSEric Fiselier 1233e519524SHoward Hinnanttemplate <class _Tp, size_t _Size> 124e2f2d1edSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS array 1253e519524SHoward Hinnant{ 1263e519524SHoward Hinnant // types: 1273e519524SHoward Hinnant typedef array __self; 1283e519524SHoward Hinnant typedef _Tp value_type; 1293e519524SHoward Hinnant typedef value_type& reference; 1303e519524SHoward Hinnant typedef const value_type& const_reference; 1313e519524SHoward Hinnant typedef value_type* iterator; 1323e519524SHoward Hinnant typedef const value_type* const_iterator; 1333e519524SHoward Hinnant typedef value_type* pointer; 1343e519524SHoward Hinnant typedef const value_type* const_pointer; 1353e519524SHoward Hinnant typedef size_t size_type; 1363e519524SHoward Hinnant typedef ptrdiff_t difference_type; 1373e519524SHoward Hinnant typedef std::reverse_iterator<iterator> reverse_iterator; 1383e519524SHoward Hinnant typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 1393e519524SHoward Hinnant 140*59cdf90aSEric Fiselier _Tp __elems_[_Size]; 1413e519524SHoward Hinnant 1423e519524SHoward Hinnant // No explicit construct/copy/destroy for aggregate type 143*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY void fill(const value_type& __u) { 144*59cdf90aSEric Fiselier _VSTD::fill_n(__elems_, _Size, __u); 145*59cdf90aSEric Fiselier } 146afeda5c2SEric Fiselier 1478f0cd597SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 148*59cdf90aSEric Fiselier void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) { 149*59cdf90aSEric Fiselier std::swap_ranges(__elems_, __elems_ + _Size, __a.__elems_); 150*59cdf90aSEric Fiselier } 1513e519524SHoward Hinnant 1523e519524SHoward Hinnant // iterators: 153020b623aSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 154*59cdf90aSEric Fiselier iterator begin() _NOEXCEPT {return iterator(data());} 155020b623aSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 156*59cdf90aSEric Fiselier const_iterator begin() const _NOEXCEPT {return const_iterator(data());} 157020b623aSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 158*59cdf90aSEric Fiselier iterator end() _NOEXCEPT {return iterator(data() + _Size);} 159020b623aSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 160*59cdf90aSEric Fiselier const_iterator end() const _NOEXCEPT {return const_iterator(data() + _Size);} 1613e519524SHoward Hinnant 162020b623aSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1638f0cd597SHoward Hinnant reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} 164020b623aSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1658f0cd597SHoward Hinnant const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());} 166020b623aSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1678f0cd597SHoward Hinnant reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());} 168020b623aSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1698f0cd597SHoward Hinnant const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());} 1703e519524SHoward Hinnant 171020b623aSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1728f0cd597SHoward Hinnant const_iterator cbegin() const _NOEXCEPT {return begin();} 173020b623aSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1748f0cd597SHoward Hinnant const_iterator cend() const _NOEXCEPT {return end();} 175020b623aSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1768f0cd597SHoward Hinnant const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} 177020b623aSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 1788f0cd597SHoward Hinnant const_reverse_iterator crend() const _NOEXCEPT {return rend();} 1793e519524SHoward Hinnant 1803e519524SHoward Hinnant // capacity: 1818f0cd597SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 182397717b7SHoward Hinnant _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return _Size;} 1838f0cd597SHoward Hinnant _LIBCPP_INLINE_VISIBILITY 184397717b7SHoward Hinnant _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return _Size;} 18572c8fad4SMarshall Clow _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 186*59cdf90aSEric Fiselier _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return false; } 1873e519524SHoward Hinnant 1883e519524SHoward Hinnant // element access: 189e7826950SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 190e7826950SMarshall Clow reference operator[](size_type __n) {return __elems_[__n];} 191e7826950SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 192e7826950SMarshall Clow const_reference operator[](size_type __n) const {return __elems_[__n];} 193e7826950SMarshall Clow 194e7826950SMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX14 reference at(size_type __n); 1958bf1f08aSMarshall Clow _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const; 1963e519524SHoward Hinnant 197e7826950SMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front() {return __elems_[0];} 1988bf1f08aSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const {return __elems_[0];} 199*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back() {return __elems_[_Size - 1];} 200*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const {return __elems_[_Size - 1];} 2013e519524SHoward Hinnant 202020b623aSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 203936ff584SNirav Dave value_type* data() _NOEXCEPT {return __elems_;} 204020b623aSMarshall Clow _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 205936ff584SNirav Dave const value_type* data() const _NOEXCEPT {return __elems_;} 2063e519524SHoward Hinnant}; 2073e519524SHoward Hinnant 208*59cdf90aSEric Fiselier 2093e519524SHoward Hinnanttemplate <class _Tp, size_t _Size> 210e7826950SMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX14 2113e519524SHoward Hinnanttypename array<_Tp, _Size>::reference 2123e519524SHoward Hinnantarray<_Tp, _Size>::at(size_type __n) 2133e519524SHoward Hinnant{ 2143e519524SHoward Hinnant if (__n >= _Size) 215d437fa5cSMarshall Clow __throw_out_of_range("array::at"); 216d437fa5cSMarshall Clow 2173e519524SHoward Hinnant return __elems_[__n]; 2183e519524SHoward Hinnant} 2193e519524SHoward Hinnant 2203e519524SHoward Hinnanttemplate <class _Tp, size_t _Size> 2218bf1f08aSMarshall Clow_LIBCPP_CONSTEXPR_AFTER_CXX11 2223e519524SHoward Hinnanttypename array<_Tp, _Size>::const_reference 2233e519524SHoward Hinnantarray<_Tp, _Size>::at(size_type __n) const 2243e519524SHoward Hinnant{ 2253e519524SHoward Hinnant if (__n >= _Size) 226d437fa5cSMarshall Clow __throw_out_of_range("array::at"); 2273e519524SHoward Hinnant return __elems_[__n]; 2283e519524SHoward Hinnant} 2293e519524SHoward Hinnant 230*59cdf90aSEric Fiseliertemplate <class _Tp> 231*59cdf90aSEric Fiselierstruct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> 232*59cdf90aSEric Fiselier{ 233*59cdf90aSEric Fiselier // types: 234*59cdf90aSEric Fiselier typedef array __self; 235*59cdf90aSEric Fiselier typedef _Tp value_type; 236*59cdf90aSEric Fiselier typedef value_type& reference; 237*59cdf90aSEric Fiselier typedef const value_type& const_reference; 238*59cdf90aSEric Fiselier typedef value_type* iterator; 239*59cdf90aSEric Fiselier typedef const value_type* const_iterator; 240*59cdf90aSEric Fiselier typedef value_type* pointer; 241*59cdf90aSEric Fiselier typedef const value_type* const_pointer; 242*59cdf90aSEric Fiselier typedef size_t size_type; 243*59cdf90aSEric Fiselier typedef ptrdiff_t difference_type; 244*59cdf90aSEric Fiselier typedef std::reverse_iterator<iterator> reverse_iterator; 245*59cdf90aSEric Fiselier typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 246*59cdf90aSEric Fiselier 247*59cdf90aSEric Fiselier 248*59cdf90aSEric Fiselier typedef typename conditional<is_const<_Tp>::value, const char, 249*59cdf90aSEric Fiselier char>::type _CharType; 250*59cdf90aSEric Fiselier _ALIGNAS(alignment_of<_Tp[1]>::value) _CharType __elems_[sizeof(_Tp[1])]; 251*59cdf90aSEric Fiselier 252*59cdf90aSEric Fiselier // No explicit construct/copy/destroy for aggregate type 253*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY void fill(const value_type&) { 254*59cdf90aSEric Fiselier static_assert(!is_const<_Tp>::value, 255*59cdf90aSEric Fiselier "cannot fill zero-sized array of type 'const T'"); 256*59cdf90aSEric Fiselier } 257*59cdf90aSEric Fiselier 258*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 259*59cdf90aSEric Fiselier void swap(array&) _NOEXCEPT { 260*59cdf90aSEric Fiselier static_assert(!is_const<_Tp>::value, 261*59cdf90aSEric Fiselier "cannot swap zero-sized array of type 'const T'"); 262*59cdf90aSEric Fiselier } 263*59cdf90aSEric Fiselier 264*59cdf90aSEric Fiselier // iterators: 265*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 266*59cdf90aSEric Fiselier iterator begin() _NOEXCEPT {return iterator(data());} 267*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 268*59cdf90aSEric Fiselier const_iterator begin() const _NOEXCEPT {return const_iterator(data());} 269*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 270*59cdf90aSEric Fiselier iterator end() _NOEXCEPT {return iterator(data());} 271*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 272*59cdf90aSEric Fiselier const_iterator end() const _NOEXCEPT {return const_iterator(data());} 273*59cdf90aSEric Fiselier 274*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 275*59cdf90aSEric Fiselier reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());} 276*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 277*59cdf90aSEric Fiselier const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());} 278*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 279*59cdf90aSEric Fiselier reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());} 280*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 281*59cdf90aSEric Fiselier const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());} 282*59cdf90aSEric Fiselier 283*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 284*59cdf90aSEric Fiselier const_iterator cbegin() const _NOEXCEPT {return begin();} 285*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 286*59cdf90aSEric Fiselier const_iterator cend() const _NOEXCEPT {return end();} 287*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 288*59cdf90aSEric Fiselier const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();} 289*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 290*59cdf90aSEric Fiselier const_reverse_iterator crend() const _NOEXCEPT {return rend();} 291*59cdf90aSEric Fiselier 292*59cdf90aSEric Fiselier // capacity: 293*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 294*59cdf90aSEric Fiselier _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return 0; } 295*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 296*59cdf90aSEric Fiselier _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return 0;} 297*59cdf90aSEric Fiselier _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY 298*59cdf90aSEric Fiselier _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return true;} 299*59cdf90aSEric Fiselier 300*59cdf90aSEric Fiselier // element access: 301*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 302*59cdf90aSEric Fiselier reference operator[](size_type) { 303*59cdf90aSEric Fiselier _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array"); 304*59cdf90aSEric Fiselier _LIBCPP_UNREACHABLE(); 305*59cdf90aSEric Fiselier } 306*59cdf90aSEric Fiselier 307*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 308*59cdf90aSEric Fiselier const_reference operator[](size_type) const { 309*59cdf90aSEric Fiselier _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array"); 310*59cdf90aSEric Fiselier _LIBCPP_UNREACHABLE(); 311*59cdf90aSEric Fiselier } 312*59cdf90aSEric Fiselier 313*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 314*59cdf90aSEric Fiselier reference at(size_type) { 315*59cdf90aSEric Fiselier __throw_out_of_range("array<T, 0>::at"); 316*59cdf90aSEric Fiselier _LIBCPP_UNREACHABLE(); 317*59cdf90aSEric Fiselier } 318*59cdf90aSEric Fiselier 319*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 320*59cdf90aSEric Fiselier const_reference at(size_type) const { 321*59cdf90aSEric Fiselier __throw_out_of_range("array<T, 0>::at"); 322*59cdf90aSEric Fiselier _LIBCPP_UNREACHABLE(); 323*59cdf90aSEric Fiselier } 324*59cdf90aSEric Fiselier 325*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 326*59cdf90aSEric Fiselier reference front() { 327*59cdf90aSEric Fiselier _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array"); 328*59cdf90aSEric Fiselier _LIBCPP_UNREACHABLE(); 329*59cdf90aSEric Fiselier } 330*59cdf90aSEric Fiselier 331*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 332*59cdf90aSEric Fiselier const_reference front() const { 333*59cdf90aSEric Fiselier _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array"); 334*59cdf90aSEric Fiselier _LIBCPP_UNREACHABLE(); 335*59cdf90aSEric Fiselier } 336*59cdf90aSEric Fiselier 337*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 338*59cdf90aSEric Fiselier reference back() { 339*59cdf90aSEric Fiselier _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array"); 340*59cdf90aSEric Fiselier _LIBCPP_UNREACHABLE(); 341*59cdf90aSEric Fiselier } 342*59cdf90aSEric Fiselier 343*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 344*59cdf90aSEric Fiselier const_reference back() const { 345*59cdf90aSEric Fiselier _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array"); 346*59cdf90aSEric Fiselier _LIBCPP_UNREACHABLE(); 347*59cdf90aSEric Fiselier } 348*59cdf90aSEric Fiselier 349*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 350*59cdf90aSEric Fiselier value_type* data() _NOEXCEPT {return reinterpret_cast<value_type*>(__elems_);} 351*59cdf90aSEric Fiselier _LIBCPP_INLINE_VISIBILITY 352*59cdf90aSEric Fiselier const value_type* data() const _NOEXCEPT {return reinterpret_cast<const value_type*>(__elems_);} 353*59cdf90aSEric Fiselier}; 354*59cdf90aSEric Fiselier 355*59cdf90aSEric Fiselier 3563e519524SHoward Hinnanttemplate <class _Tp, size_t _Size> 3573af48ef7SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 3583e519524SHoward Hinnantbool 3593e519524SHoward Hinnantoperator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) 3603e519524SHoward Hinnant{ 361*59cdf90aSEric Fiselier return _VSTD::equal(__x.begin(), __x.end(), __y.begin()); 3623e519524SHoward Hinnant} 3633e519524SHoward Hinnant 3643e519524SHoward Hinnanttemplate <class _Tp, size_t _Size> 3653af48ef7SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 3663e519524SHoward Hinnantbool 3673e519524SHoward Hinnantoperator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) 3683e519524SHoward Hinnant{ 3693e519524SHoward Hinnant return !(__x == __y); 3703e519524SHoward Hinnant} 3713e519524SHoward Hinnant 3723e519524SHoward Hinnanttemplate <class _Tp, size_t _Size> 3733af48ef7SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 3743e519524SHoward Hinnantbool 3753e519524SHoward Hinnantoperator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) 3763e519524SHoward Hinnant{ 377*59cdf90aSEric Fiselier return _VSTD::lexicographical_compare(__x.begin(), __x.end(), 378*59cdf90aSEric Fiselier __y.begin(), __y.end()); 3793e519524SHoward Hinnant} 3803e519524SHoward Hinnant 3813e519524SHoward Hinnanttemplate <class _Tp, size_t _Size> 3823af48ef7SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 3833e519524SHoward Hinnantbool 3843e519524SHoward Hinnantoperator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) 3853e519524SHoward Hinnant{ 3863e519524SHoward Hinnant return __y < __x; 3873e519524SHoward Hinnant} 3883e519524SHoward Hinnant 3893e519524SHoward Hinnanttemplate <class _Tp, size_t _Size> 3903af48ef7SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 3913e519524SHoward Hinnantbool 3923e519524SHoward Hinnantoperator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) 3933e519524SHoward Hinnant{ 3943e519524SHoward Hinnant return !(__y < __x); 3953e519524SHoward Hinnant} 3963e519524SHoward Hinnant 3973e519524SHoward Hinnanttemplate <class _Tp, size_t _Size> 3983af48ef7SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 3993e519524SHoward Hinnantbool 4003e519524SHoward Hinnantoperator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) 4013e519524SHoward Hinnant{ 4023e519524SHoward Hinnant return !(__x < __y); 4033e519524SHoward Hinnant} 4043e519524SHoward Hinnant 4053e519524SHoward Hinnanttemplate <class _Tp, size_t _Size> 4063af48ef7SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY 407bc95cf0dSHoward Hinnanttypename enable_if 408bc95cf0dSHoward Hinnant< 409f07dd8d0SEric Fiselier _Size == 0 || 410bc95cf0dSHoward Hinnant __is_swappable<_Tp>::value, 4113e519524SHoward Hinnant void 412bc95cf0dSHoward Hinnant>::type 413ee66eb13SMarshall Clowswap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y) 414f07dd8d0SEric Fiselier _NOEXCEPT_(noexcept(__x.swap(__y))) 4153e519524SHoward Hinnant{ 4163e519524SHoward Hinnant __x.swap(__y); 4173e519524SHoward Hinnant} 4183e519524SHoward Hinnant 4193e519524SHoward Hinnanttemplate <class _Tp, size_t _Size> 420e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> > 421f5ab703fSHoward Hinnant : public integral_constant<size_t, _Size> {}; 4223e519524SHoward Hinnant 4233e519524SHoward Hinnanttemplate <size_t _Ip, class _Tp, size_t _Size> 424e2f2d1edSEric Fiselierclass _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> > 4253e519524SHoward Hinnant{ 4266db379a2SMarshall Clow static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)"); 4273e519524SHoward Hinnantpublic: 4283e519524SHoward Hinnant typedef _Tp type; 4293e519524SHoward Hinnant}; 4303e519524SHoward Hinnant 4313e519524SHoward Hinnanttemplate <size_t _Ip, class _Tp, size_t _Size> 4323af48ef7SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 4333e519524SHoward Hinnant_Tp& 4348f0cd597SHoward Hinnantget(array<_Tp, _Size>& __a) _NOEXCEPT 4353e519524SHoward Hinnant{ 43636a60721SMarshall Clow static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array)"); 4378bf1f08aSMarshall Clow return __a.__elems_[_Ip]; 4383e519524SHoward Hinnant} 4393e519524SHoward Hinnant 4403e519524SHoward Hinnanttemplate <size_t _Ip, class _Tp, size_t _Size> 4413af48ef7SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 4423e519524SHoward Hinnantconst _Tp& 4438f0cd597SHoward Hinnantget(const array<_Tp, _Size>& __a) _NOEXCEPT 4443e519524SHoward Hinnant{ 44536a60721SMarshall Clow static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array)"); 4468bf1f08aSMarshall Clow return __a.__elems_[_Ip]; 4473e519524SHoward Hinnant} 4483e519524SHoward Hinnant 449208156e8SEric Fiselier#ifndef _LIBCPP_CXX03_LANG 450601afb30SHoward Hinnant 451601afb30SHoward Hinnanttemplate <size_t _Ip, class _Tp, size_t _Size> 4523af48ef7SHoward Hinnantinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 453601afb30SHoward Hinnant_Tp&& 4548f0cd597SHoward Hinnantget(array<_Tp, _Size>&& __a) _NOEXCEPT 455601afb30SHoward Hinnant{ 45636a60721SMarshall Clow static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array &&)"); 4578bf1f08aSMarshall Clow return _VSTD::move(__a.__elems_[_Ip]); 458601afb30SHoward Hinnant} 459601afb30SHoward Hinnant 460545b8861SEric Fiseliertemplate <size_t _Ip, class _Tp, size_t _Size> 461545b8861SEric Fiselierinline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 462545b8861SEric Fiselierconst _Tp&& 463545b8861SEric Fiselierget(const array<_Tp, _Size>&& __a) _NOEXCEPT 464545b8861SEric Fiselier{ 465545b8861SEric Fiselier static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array &&)"); 466545b8861SEric Fiselier return _VSTD::move(__a.__elems_[_Ip]); 467545b8861SEric Fiselier} 468545b8861SEric Fiselier 469208156e8SEric Fiselier#endif // !_LIBCPP_CXX03_LANG 470601afb30SHoward Hinnant 4713e519524SHoward Hinnant_LIBCPP_END_NAMESPACE_STD 4723e519524SHoward Hinnant 4733e519524SHoward Hinnant#endif // _LIBCPP_ARRAY 474