1*700637cbSDimitry Andric// -*- C++ -*- 2*700637cbSDimitry Andric//===----------------------------------------------------------------------===// 3*700637cbSDimitry Andric// 4*700637cbSDimitry Andric// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. 5*700637cbSDimitry Andric// See https://llvm.org/LICENSE.txt for license information. 6*700637cbSDimitry Andric// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception 7*700637cbSDimitry Andric// 8*700637cbSDimitry Andric//===----------------------------------------------------------------------===// 9*700637cbSDimitry Andric 10*700637cbSDimitry Andric#ifndef _LIBCPP___CXX03_ARRAY 11*700637cbSDimitry Andric#define _LIBCPP___CXX03_ARRAY 12*700637cbSDimitry Andric 13*700637cbSDimitry Andric/* 14*700637cbSDimitry Andric array synopsis 15*700637cbSDimitry Andric 16*700637cbSDimitry Andricnamespace std 17*700637cbSDimitry Andric{ 18*700637cbSDimitry Andrictemplate <class T, size_t N > 19*700637cbSDimitry Andricstruct array 20*700637cbSDimitry Andric{ 21*700637cbSDimitry Andric // types: 22*700637cbSDimitry Andric typedef T & reference; 23*700637cbSDimitry Andric typedef const T & const_reference; 24*700637cbSDimitry Andric typedef implementation defined iterator; 25*700637cbSDimitry Andric typedef implementation defined const_iterator; 26*700637cbSDimitry Andric typedef size_t size_type; 27*700637cbSDimitry Andric typedef ptrdiff_t difference_type; 28*700637cbSDimitry Andric typedef T value_type; 29*700637cbSDimitry Andric typedef T* pointer; 30*700637cbSDimitry Andric typedef const T* const_pointer; 31*700637cbSDimitry Andric typedef std::reverse_iterator<iterator> reverse_iterator; 32*700637cbSDimitry Andric typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 33*700637cbSDimitry Andric 34*700637cbSDimitry Andric // No explicit construct/copy/destroy for aggregate type 35*700637cbSDimitry Andric void fill(const T& u); // constexpr in C++20 36*700637cbSDimitry Andric void swap(array& a) noexcept(is_nothrow_swappable_v<T>); // constexpr in C++20 37*700637cbSDimitry Andric 38*700637cbSDimitry Andric // iterators: 39*700637cbSDimitry Andric iterator begin() noexcept; // constexpr in C++17 40*700637cbSDimitry Andric const_iterator begin() const noexcept; // constexpr in C++17 41*700637cbSDimitry Andric iterator end() noexcept; // constexpr in C++17 42*700637cbSDimitry Andric const_iterator end() const noexcept; // constexpr in C++17 43*700637cbSDimitry Andric 44*700637cbSDimitry Andric reverse_iterator rbegin() noexcept; // constexpr in C++17 45*700637cbSDimitry Andric const_reverse_iterator rbegin() const noexcept; // constexpr in C++17 46*700637cbSDimitry Andric reverse_iterator rend() noexcept; // constexpr in C++17 47*700637cbSDimitry Andric const_reverse_iterator rend() const noexcept; // constexpr in C++17 48*700637cbSDimitry Andric 49*700637cbSDimitry Andric const_iterator cbegin() const noexcept; // constexpr in C++17 50*700637cbSDimitry Andric const_iterator cend() const noexcept; // constexpr in C++17 51*700637cbSDimitry Andric const_reverse_iterator crbegin() const noexcept; // constexpr in C++17 52*700637cbSDimitry Andric const_reverse_iterator crend() const noexcept; // constexpr in C++17 53*700637cbSDimitry Andric 54*700637cbSDimitry Andric // capacity: 55*700637cbSDimitry Andric constexpr size_type size() const noexcept; 56*700637cbSDimitry Andric constexpr size_type max_size() const noexcept; 57*700637cbSDimitry Andric constexpr bool empty() const noexcept; 58*700637cbSDimitry Andric 59*700637cbSDimitry Andric // element access: 60*700637cbSDimitry Andric reference operator[](size_type n); // constexpr in C++17 61*700637cbSDimitry Andric const_reference operator[](size_type n) const; // constexpr in C++14 62*700637cbSDimitry Andric reference at(size_type n); // constexpr in C++17 63*700637cbSDimitry Andric const_reference at(size_type n) const; // constexpr in C++14 64*700637cbSDimitry Andric 65*700637cbSDimitry Andric reference front(); // constexpr in C++17 66*700637cbSDimitry Andric const_reference front() const; // constexpr in C++14 67*700637cbSDimitry Andric reference back(); // constexpr in C++17 68*700637cbSDimitry Andric const_reference back() const; // constexpr in C++14 69*700637cbSDimitry Andric 70*700637cbSDimitry Andric T* data() noexcept; // constexpr in C++17 71*700637cbSDimitry Andric const T* data() const noexcept; // constexpr in C++17 72*700637cbSDimitry Andric}; 73*700637cbSDimitry Andric 74*700637cbSDimitry Andrictemplate <class T, class... U> 75*700637cbSDimitry Andric array(T, U...) -> array<T, 1 + sizeof...(U)>; // C++17 76*700637cbSDimitry Andric 77*700637cbSDimitry Andrictemplate <class T, size_t N> 78*700637cbSDimitry Andric bool operator==(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20 79*700637cbSDimitry Andrictemplate <class T, size_t N> 80*700637cbSDimitry Andric bool operator!=(const array<T,N>& x, const array<T,N>& y); // removed in C++20 81*700637cbSDimitry Andrictemplate <class T, size_t N> 82*700637cbSDimitry Andric bool operator<(const array<T,N>& x, const array<T,N>& y); // removed in C++20 83*700637cbSDimitry Andrictemplate <class T, size_t N> 84*700637cbSDimitry Andric bool operator>(const array<T,N>& x, const array<T,N>& y); // removed in C++20 85*700637cbSDimitry Andrictemplate <class T, size_t N> 86*700637cbSDimitry Andric bool operator<=(const array<T,N>& x, const array<T,N>& y); // removed in C++20 87*700637cbSDimitry Andrictemplate <class T, size_t N> 88*700637cbSDimitry Andric bool operator>=(const array<T,N>& x, const array<T,N>& y); // removed in C++20 89*700637cbSDimitry Andrictemplate<class T, size_t N> 90*700637cbSDimitry Andric constexpr synth-three-way-result<T> 91*700637cbSDimitry Andric operator<=>(const array<T, N>& x, const array<T, N>& y); // since C++20 92*700637cbSDimitry Andric 93*700637cbSDimitry Andrictemplate <class T, size_t N > 94*700637cbSDimitry Andric void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y))); // constexpr in C++20 95*700637cbSDimitry Andric 96*700637cbSDimitry Andrictemplate <class T, size_t N> 97*700637cbSDimitry Andric constexpr array<remove_cv_t<T>, N> to_array(T (&a)[N]); // C++20 98*700637cbSDimitry Andrictemplate <class T, size_t N> 99*700637cbSDimitry Andric constexpr array<remove_cv_t<T>, N> to_array(T (&&a)[N]); // C++20 100*700637cbSDimitry Andric 101*700637cbSDimitry Andrictemplate <class T> struct tuple_size; 102*700637cbSDimitry Andrictemplate <size_t I, class T> struct tuple_element; 103*700637cbSDimitry Andrictemplate <class T, size_t N> struct tuple_size<array<T, N>>; 104*700637cbSDimitry Andrictemplate <size_t I, class T, size_t N> struct tuple_element<I, array<T, N>>; 105*700637cbSDimitry Andrictemplate <size_t I, class T, size_t N> T& get(array<T, N>&) noexcept; // constexpr in C++14 106*700637cbSDimitry Andrictemplate <size_t I, class T, size_t N> const T& get(const array<T, N>&) noexcept; // constexpr in C++14 107*700637cbSDimitry Andrictemplate <size_t I, class T, size_t N> T&& get(array<T, N>&&) noexcept; // constexpr in C++14 108*700637cbSDimitry Andrictemplate <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexcept; // constexpr in C++14 109*700637cbSDimitry Andric 110*700637cbSDimitry Andric} // std 111*700637cbSDimitry Andric 112*700637cbSDimitry Andric*/ 113*700637cbSDimitry Andric 114*700637cbSDimitry Andric#include <__cxx03/__algorithm/equal.h> 115*700637cbSDimitry Andric#include <__cxx03/__algorithm/fill_n.h> 116*700637cbSDimitry Andric#include <__cxx03/__algorithm/lexicographical_compare.h> 117*700637cbSDimitry Andric#include <__cxx03/__algorithm/swap_ranges.h> 118*700637cbSDimitry Andric#include <__cxx03/__assert> 119*700637cbSDimitry Andric#include <__cxx03/__config> 120*700637cbSDimitry Andric#include <__cxx03/__fwd/array.h> 121*700637cbSDimitry Andric#include <__cxx03/__iterator/reverse_iterator.h> 122*700637cbSDimitry Andric#include <__cxx03/__iterator/wrap_iter.h> 123*700637cbSDimitry Andric#include <__cxx03/__tuple/sfinae_helpers.h> 124*700637cbSDimitry Andric#include <__cxx03/__type_traits/conditional.h> 125*700637cbSDimitry Andric#include <__cxx03/__type_traits/conjunction.h> 126*700637cbSDimitry Andric#include <__cxx03/__type_traits/is_array.h> 127*700637cbSDimitry Andric#include <__cxx03/__type_traits/is_const.h> 128*700637cbSDimitry Andric#include <__cxx03/__type_traits/is_constructible.h> 129*700637cbSDimitry Andric#include <__cxx03/__type_traits/is_nothrow_constructible.h> 130*700637cbSDimitry Andric#include <__cxx03/__type_traits/is_same.h> 131*700637cbSDimitry Andric#include <__cxx03/__type_traits/is_swappable.h> 132*700637cbSDimitry Andric#include <__cxx03/__type_traits/is_trivially_relocatable.h> 133*700637cbSDimitry Andric#include <__cxx03/__type_traits/remove_cv.h> 134*700637cbSDimitry Andric#include <__cxx03/__utility/empty.h> 135*700637cbSDimitry Andric#include <__cxx03/__utility/integer_sequence.h> 136*700637cbSDimitry Andric#include <__cxx03/__utility/move.h> 137*700637cbSDimitry Andric#include <__cxx03/__utility/unreachable.h> 138*700637cbSDimitry Andric#include <__cxx03/stdexcept> 139*700637cbSDimitry Andric#include <__cxx03/version> 140*700637cbSDimitry Andric 141*700637cbSDimitry Andric// standard-mandated includes 142*700637cbSDimitry Andric 143*700637cbSDimitry Andric// [iterator.range] 144*700637cbSDimitry Andric#include <__cxx03/__iterator/access.h> 145*700637cbSDimitry Andric 146*700637cbSDimitry Andric// [tuple.helper] 147*700637cbSDimitry Andric#include <__cxx03/__tuple/tuple_element.h> 148*700637cbSDimitry Andric#include <__cxx03/__tuple/tuple_size.h> 149*700637cbSDimitry Andric 150*700637cbSDimitry Andric#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) 151*700637cbSDimitry Andric# pragma GCC system_header 152*700637cbSDimitry Andric#endif 153*700637cbSDimitry Andric 154*700637cbSDimitry Andric_LIBCPP_PUSH_MACROS 155*700637cbSDimitry Andric#include <__cxx03/__undef_macros> 156*700637cbSDimitry Andric 157*700637cbSDimitry Andric_LIBCPP_BEGIN_NAMESPACE_STD 158*700637cbSDimitry Andric 159*700637cbSDimitry Andrictemplate <class _Tp, size_t _Size> 160*700637cbSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS array { 161*700637cbSDimitry Andric using __trivially_relocatable = __conditional_t<__libcpp_is_trivially_relocatable<_Tp>::value, array, void>; 162*700637cbSDimitry Andric 163*700637cbSDimitry Andric // types: 164*700637cbSDimitry Andric using __self = array; 165*700637cbSDimitry Andric using value_type = _Tp; 166*700637cbSDimitry Andric using reference = value_type&; 167*700637cbSDimitry Andric using const_reference = const value_type&; 168*700637cbSDimitry Andric using pointer = value_type*; 169*700637cbSDimitry Andric using const_pointer = const value_type*; 170*700637cbSDimitry Andric#if defined(_LIBCPP_ABI_USE_WRAP_ITER_IN_STD_ARRAY) 171*700637cbSDimitry Andric using iterator = __wrap_iter<pointer>; 172*700637cbSDimitry Andric using const_iterator = __wrap_iter<const_pointer>; 173*700637cbSDimitry Andric#else 174*700637cbSDimitry Andric using iterator = pointer; 175*700637cbSDimitry Andric using const_iterator = const_pointer; 176*700637cbSDimitry Andric#endif 177*700637cbSDimitry Andric using size_type = size_t; 178*700637cbSDimitry Andric using difference_type = ptrdiff_t; 179*700637cbSDimitry Andric using reverse_iterator = std::reverse_iterator<iterator>; 180*700637cbSDimitry Andric using const_reverse_iterator = std::reverse_iterator<const_iterator>; 181*700637cbSDimitry Andric 182*700637cbSDimitry Andric _Tp __elems_[_Size]; 183*700637cbSDimitry Andric 184*700637cbSDimitry Andric // No explicit construct/copy/destroy for aggregate type 185*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void fill(const value_type& __u) { std::fill_n(data(), _Size, __u); } 186*700637cbSDimitry Andric 187*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void swap(array& __a) { std::swap_ranges(data(), data() + _Size, __a.data()); } 188*700637cbSDimitry Andric 189*700637cbSDimitry Andric // iterators: 190*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(data()); } 191*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return const_iterator(data()); } 192*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(data() + _Size); } 193*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(data() + _Size); } 194*700637cbSDimitry Andric 195*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); } 196*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); } 197*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); } 198*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(begin()); } 199*700637cbSDimitry Andric 200*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); } 201*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); } 202*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } 203*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } 204*700637cbSDimitry Andric 205*700637cbSDimitry Andric // capacity: 206*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return _Size; } 207*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return _Size; } 208*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return _Size == 0; } 209*700637cbSDimitry Andric 210*700637cbSDimitry Andric // element access: 211*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reference operator[](size_type __n) _NOEXCEPT { 212*700637cbSDimitry Andric _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < _Size, "out-of-bounds access in std::array<T, N>"); 213*700637cbSDimitry Andric return __elems_[__n]; 214*700637cbSDimitry Andric } 215*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type __n) const _NOEXCEPT { 216*700637cbSDimitry Andric _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(__n < _Size, "out-of-bounds access in std::array<T, N>"); 217*700637cbSDimitry Andric return __elems_[__n]; 218*700637cbSDimitry Andric } 219*700637cbSDimitry Andric 220*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reference at(size_type __n) { 221*700637cbSDimitry Andric if (__n >= _Size) 222*700637cbSDimitry Andric __throw_out_of_range("array::at"); 223*700637cbSDimitry Andric return __elems_[__n]; 224*700637cbSDimitry Andric } 225*700637cbSDimitry Andric 226*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reference at(size_type __n) const { 227*700637cbSDimitry Andric if (__n >= _Size) 228*700637cbSDimitry Andric __throw_out_of_range("array::at"); 229*700637cbSDimitry Andric return __elems_[__n]; 230*700637cbSDimitry Andric } 231*700637cbSDimitry Andric 232*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reference front() _NOEXCEPT { return (*this)[0]; } 233*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT { return (*this)[0]; } 234*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reference back() _NOEXCEPT { return (*this)[_Size - 1]; } 235*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT { return (*this)[_Size - 1]; } 236*700637cbSDimitry Andric 237*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI value_type* data() _NOEXCEPT { return __elems_; } 238*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const value_type* data() const _NOEXCEPT { return __elems_; } 239*700637cbSDimitry Andric}; 240*700637cbSDimitry Andric 241*700637cbSDimitry Andrictemplate <class _Tp> 242*700637cbSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS array<_Tp, 0> { 243*700637cbSDimitry Andric // types: 244*700637cbSDimitry Andric typedef array __self; 245*700637cbSDimitry Andric typedef _Tp value_type; 246*700637cbSDimitry Andric typedef value_type& reference; 247*700637cbSDimitry Andric typedef const value_type& const_reference; 248*700637cbSDimitry Andric typedef value_type* iterator; 249*700637cbSDimitry Andric typedef const value_type* const_iterator; 250*700637cbSDimitry Andric typedef value_type* pointer; 251*700637cbSDimitry Andric typedef const value_type* const_pointer; 252*700637cbSDimitry Andric typedef size_t size_type; 253*700637cbSDimitry Andric typedef ptrdiff_t difference_type; 254*700637cbSDimitry Andric typedef std::reverse_iterator<iterator> reverse_iterator; 255*700637cbSDimitry Andric typedef std::reverse_iterator<const_iterator> const_reverse_iterator; 256*700637cbSDimitry Andric 257*700637cbSDimitry Andric typedef __conditional_t<is_const<_Tp>::value, const __empty, __empty> _EmptyType; 258*700637cbSDimitry Andric 259*700637cbSDimitry Andric struct _ArrayInStructT { 260*700637cbSDimitry Andric _Tp __data_[1]; 261*700637cbSDimitry Andric }; 262*700637cbSDimitry Andric _ALIGNAS_TYPE(_ArrayInStructT) _EmptyType __elems_[sizeof(_ArrayInStructT)]; 263*700637cbSDimitry Andric 264*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI value_type* data() _NOEXCEPT { return nullptr; } 265*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const value_type* data() const _NOEXCEPT { return nullptr; } 266*700637cbSDimitry Andric 267*700637cbSDimitry Andric // No explicit construct/copy/destroy for aggregate type 268*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void fill(const value_type&) { 269*700637cbSDimitry Andric static_assert(!is_const<_Tp>::value, "cannot fill zero-sized array of type 'const T'"); 270*700637cbSDimitry Andric } 271*700637cbSDimitry Andric 272*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI void swap(array&) _NOEXCEPT { 273*700637cbSDimitry Andric static_assert(!is_const<_Tp>::value, "cannot swap zero-sized array of type 'const T'"); 274*700637cbSDimitry Andric } 275*700637cbSDimitry Andric 276*700637cbSDimitry Andric // iterators: 277*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator begin() _NOEXCEPT { return iterator(data()); } 278*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator begin() const _NOEXCEPT { return const_iterator(data()); } 279*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI iterator end() _NOEXCEPT { return iterator(data()); } 280*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator end() const _NOEXCEPT { return const_iterator(data()); } 281*700637cbSDimitry Andric 282*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reverse_iterator rbegin() _NOEXCEPT { return reverse_iterator(end()); } 283*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rbegin() const _NOEXCEPT { return const_reverse_iterator(end()); } 284*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reverse_iterator rend() _NOEXCEPT { return reverse_iterator(begin()); } 285*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reverse_iterator rend() const _NOEXCEPT { return const_reverse_iterator(begin()); } 286*700637cbSDimitry Andric 287*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator cbegin() const _NOEXCEPT { return begin(); } 288*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_iterator cend() const _NOEXCEPT { return end(); } 289*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crbegin() const _NOEXCEPT { return rbegin(); } 290*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reverse_iterator crend() const _NOEXCEPT { return rend(); } 291*700637cbSDimitry Andric 292*700637cbSDimitry Andric // capacity: 293*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type size() const _NOEXCEPT { return 0; } 294*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI size_type max_size() const _NOEXCEPT { return 0; } 295*700637cbSDimitry Andric _LIBCPP_NODISCARD _LIBCPP_HIDE_FROM_ABI bool empty() const _NOEXCEPT { return true; } 296*700637cbSDimitry Andric 297*700637cbSDimitry Andric // element access: 298*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reference operator[](size_type) _NOEXCEPT { 299*700637cbSDimitry Andric _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::operator[] on a zero-sized array"); 300*700637cbSDimitry Andric __libcpp_unreachable(); 301*700637cbSDimitry Andric } 302*700637cbSDimitry Andric 303*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reference operator[](size_type) const _NOEXCEPT { 304*700637cbSDimitry Andric _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::operator[] on a zero-sized array"); 305*700637cbSDimitry Andric __libcpp_unreachable(); 306*700637cbSDimitry Andric } 307*700637cbSDimitry Andric 308*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reference at(size_type) { 309*700637cbSDimitry Andric __throw_out_of_range("array<T, 0>::at"); 310*700637cbSDimitry Andric __libcpp_unreachable(); 311*700637cbSDimitry Andric } 312*700637cbSDimitry Andric 313*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reference at(size_type) const { 314*700637cbSDimitry Andric __throw_out_of_range("array<T, 0>::at"); 315*700637cbSDimitry Andric __libcpp_unreachable(); 316*700637cbSDimitry Andric } 317*700637cbSDimitry Andric 318*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reference front() _NOEXCEPT { 319*700637cbSDimitry Andric _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::front() on a zero-sized array"); 320*700637cbSDimitry Andric __libcpp_unreachable(); 321*700637cbSDimitry Andric } 322*700637cbSDimitry Andric 323*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reference front() const _NOEXCEPT { 324*700637cbSDimitry Andric _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::front() on a zero-sized array"); 325*700637cbSDimitry Andric __libcpp_unreachable(); 326*700637cbSDimitry Andric } 327*700637cbSDimitry Andric 328*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI reference back() _NOEXCEPT { 329*700637cbSDimitry Andric _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::back() on a zero-sized array"); 330*700637cbSDimitry Andric __libcpp_unreachable(); 331*700637cbSDimitry Andric } 332*700637cbSDimitry Andric 333*700637cbSDimitry Andric _LIBCPP_HIDE_FROM_ABI const_reference back() const _NOEXCEPT { 334*700637cbSDimitry Andric _LIBCPP_ASSERT_VALID_ELEMENT_ACCESS(false, "cannot call array<T, 0>::back() on a zero-sized array"); 335*700637cbSDimitry Andric __libcpp_unreachable(); 336*700637cbSDimitry Andric } 337*700637cbSDimitry Andric}; 338*700637cbSDimitry Andric 339*700637cbSDimitry Andrictemplate <class _Tp, size_t _Size> 340*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { 341*700637cbSDimitry Andric return std::equal(__x.begin(), __x.end(), __y.begin()); 342*700637cbSDimitry Andric} 343*700637cbSDimitry Andric 344*700637cbSDimitry Andrictemplate <class _Tp, size_t _Size> 345*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { 346*700637cbSDimitry Andric return !(__x == __y); 347*700637cbSDimitry Andric} 348*700637cbSDimitry Andric 349*700637cbSDimitry Andrictemplate <class _Tp, size_t _Size> 350*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { 351*700637cbSDimitry Andric return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end()); 352*700637cbSDimitry Andric} 353*700637cbSDimitry Andric 354*700637cbSDimitry Andrictemplate <class _Tp, size_t _Size> 355*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { 356*700637cbSDimitry Andric return __y < __x; 357*700637cbSDimitry Andric} 358*700637cbSDimitry Andric 359*700637cbSDimitry Andrictemplate <class _Tp, size_t _Size> 360*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { 361*700637cbSDimitry Andric return !(__y < __x); 362*700637cbSDimitry Andric} 363*700637cbSDimitry Andric 364*700637cbSDimitry Andrictemplate <class _Tp, size_t _Size> 365*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI bool operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) { 366*700637cbSDimitry Andric return !(__x < __y); 367*700637cbSDimitry Andric} 368*700637cbSDimitry Andric 369*700637cbSDimitry Andrictemplate <class _Tp, size_t _Size, __enable_if_t<_Size == 0 || __is_swappable_v<_Tp>, int> = 0> 370*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI void swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y) { 371*700637cbSDimitry Andric __x.swap(__y); 372*700637cbSDimitry Andric} 373*700637cbSDimitry Andric 374*700637cbSDimitry Andrictemplate <class _Tp, size_t _Size> 375*700637cbSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> > : public integral_constant<size_t, _Size> {}; 376*700637cbSDimitry Andric 377*700637cbSDimitry Andrictemplate <size_t _Ip, class _Tp, size_t _Size> 378*700637cbSDimitry Andricstruct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> > { 379*700637cbSDimitry Andric static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)"); 380*700637cbSDimitry Andric typedef _Tp type; 381*700637cbSDimitry Andric}; 382*700637cbSDimitry Andric 383*700637cbSDimitry Andrictemplate <size_t _Ip, class _Tp, size_t _Size> 384*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI _Tp& get(array<_Tp, _Size>& __a) _NOEXCEPT { 385*700637cbSDimitry Andric static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array)"); 386*700637cbSDimitry Andric return __a.__elems_[_Ip]; 387*700637cbSDimitry Andric} 388*700637cbSDimitry Andric 389*700637cbSDimitry Andrictemplate <size_t _Ip, class _Tp, size_t _Size> 390*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI const _Tp& get(const array<_Tp, _Size>& __a) _NOEXCEPT { 391*700637cbSDimitry Andric static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array)"); 392*700637cbSDimitry Andric return __a.__elems_[_Ip]; 393*700637cbSDimitry Andric} 394*700637cbSDimitry Andric 395*700637cbSDimitry Andrictemplate <size_t _Ip, class _Tp, size_t _Size> 396*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI _Tp&& get(array<_Tp, _Size>&& __a) _NOEXCEPT { 397*700637cbSDimitry Andric static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array &&)"); 398*700637cbSDimitry Andric return std::move(__a.__elems_[_Ip]); 399*700637cbSDimitry Andric} 400*700637cbSDimitry Andric 401*700637cbSDimitry Andrictemplate <size_t _Ip, class _Tp, size_t _Size> 402*700637cbSDimitry Andricinline _LIBCPP_HIDE_FROM_ABI const _Tp&& get(const array<_Tp, _Size>&& __a) _NOEXCEPT { 403*700637cbSDimitry Andric static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array &&)"); 404*700637cbSDimitry Andric return std::move(__a.__elems_[_Ip]); 405*700637cbSDimitry Andric} 406*700637cbSDimitry Andric 407*700637cbSDimitry Andric_LIBCPP_END_NAMESPACE_STD 408*700637cbSDimitry Andric 409*700637cbSDimitry Andric_LIBCPP_POP_MACROS 410*700637cbSDimitry Andric 411*700637cbSDimitry Andric#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) 412*700637cbSDimitry Andric# include <__cxx03/algorithm> 413*700637cbSDimitry Andric# include <__cxx03/cstdlib> 414*700637cbSDimitry Andric# include <__cxx03/iterator> 415*700637cbSDimitry Andric# include <__cxx03/type_traits> 416*700637cbSDimitry Andric# include <__cxx03/utility> 417*700637cbSDimitry Andric#endif 418*700637cbSDimitry Andric 419*700637cbSDimitry Andric#endif // _LIBCPP___CXX03_ARRAY 420