123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523 |
- // -*- C++ -*-
- //===----------------------------------------------------------------------===//
- //
- // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
- // See https://llvm.org/LICENSE.txt for license information.
- // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
- //
- //===----------------------------------------------------------------------===//
- #ifndef _LIBCPP_ARRAY
- #define _LIBCPP_ARRAY
- /*
- array synopsis
- namespace std
- {
- template <class T, size_t N >
- struct array
- {
- // types:
- typedef T & reference;
- typedef const T & const_reference;
- typedef implementation defined iterator;
- typedef implementation defined const_iterator;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef T value_type;
- typedef T* pointer;
- typedef const T* const_pointer;
- typedef std::reverse_iterator<iterator> reverse_iterator;
- typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
- // No explicit construct/copy/destroy for aggregate type
- void fill(const T& u); // constexpr in C++20
- void swap(array& a) noexcept(is_nothrow_swappable_v<T>); // constexpr in C++20
- // iterators:
- iterator begin() noexcept; // constexpr in C++17
- const_iterator begin() const noexcept; // constexpr in C++17
- iterator end() noexcept; // constexpr in C++17
- const_iterator end() const noexcept; // constexpr in C++17
- reverse_iterator rbegin() noexcept; // constexpr in C++17
- const_reverse_iterator rbegin() const noexcept; // constexpr in C++17
- reverse_iterator rend() noexcept; // constexpr in C++17
- const_reverse_iterator rend() const noexcept; // constexpr in C++17
- const_iterator cbegin() const noexcept; // constexpr in C++17
- const_iterator cend() const noexcept; // constexpr in C++17
- const_reverse_iterator crbegin() const noexcept; // constexpr in C++17
- const_reverse_iterator crend() const noexcept; // constexpr in C++17
- // capacity:
- constexpr size_type size() const noexcept;
- constexpr size_type max_size() const noexcept;
- constexpr bool empty() const noexcept;
- // element access:
- reference operator[](size_type n); // constexpr in C++17
- const_reference operator[](size_type n) const; // constexpr in C++14
- reference at(size_type n); // constexpr in C++17
- const_reference at(size_type n) const; // constexpr in C++14
- reference front(); // constexpr in C++17
- const_reference front() const; // constexpr in C++14
- reference back(); // constexpr in C++17
- const_reference back() const; // constexpr in C++14
- T* data() noexcept; // constexpr in C++17
- const T* data() const noexcept; // constexpr in C++17
- };
- template <class T, class... U>
- array(T, U...) -> array<T, 1 + sizeof...(U)>; // C++17
- template <class T, size_t N>
- bool operator==(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20
- template <class T, size_t N>
- bool operator!=(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20
- template <class T, size_t N>
- bool operator<(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20
- template <class T, size_t N>
- bool operator>(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20
- template <class T, size_t N>
- bool operator<=(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20
- template <class T, size_t N>
- bool operator>=(const array<T,N>& x, const array<T,N>& y); // constexpr in C++20
- template <class T, size_t N >
- void swap(array<T,N>& x, array<T,N>& y) noexcept(noexcept(x.swap(y))); // constexpr in C++20
- template <class T, size_t N>
- constexpr array<remove_cv_t<T>, N> to_array(T (&a)[N]); // C++20
- template <class T, size_t N>
- constexpr array<remove_cv_t<T>, N> to_array(T (&&a)[N]); // C++20
- template <class T> struct tuple_size;
- template <size_t I, class T> struct tuple_element;
- template <class T, size_t N> struct tuple_size<array<T, N>>;
- template <size_t I, class T, size_t N> struct tuple_element<I, array<T, N>>;
- template <size_t I, class T, size_t N> T& get(array<T, N>&) noexcept; // constexpr in C++14
- template <size_t I, class T, size_t N> const T& get(const array<T, N>&) noexcept; // constexpr in C++14
- template <size_t I, class T, size_t N> T&& get(array<T, N>&&) noexcept; // constexpr in C++14
- template <size_t I, class T, size_t N> const T&& get(const array<T, N>&&) noexcept; // constexpr in C++14
- } // std
- */
- #include <__algorithm/equal.h>
- #include <__algorithm/fill_n.h>
- #include <__algorithm/lexicographical_compare.h>
- #include <__algorithm/swap_ranges.h>
- #include <__assert>
- #include <__config>
- #include <__tuple>
- #include <__utility/unreachable.h>
- #include <iterator>
- #include <stdexcept>
- #include <type_traits>
- #include <utility>
- #include <version>
- #if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
- # pragma GCC system_header
- #endif
- _LIBCPP_BEGIN_NAMESPACE_STD
- template <class _Tp, size_t _Size>
- struct _LIBCPP_TEMPLATE_VIS array
- {
- // types:
- typedef array __self;
- typedef _Tp value_type;
- typedef value_type& reference;
- typedef const value_type& const_reference;
- typedef value_type* iterator;
- typedef const value_type* const_iterator;
- typedef value_type* pointer;
- typedef const value_type* const_pointer;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
- typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
- _Tp __elems_[_Size];
- // No explicit construct/copy/destroy for aggregate type
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- void fill(const value_type& __u) {
- _VSTD::fill_n(data(), _Size, __u);
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- void swap(array& __a) _NOEXCEPT_(__is_nothrow_swappable<_Tp>::value) {
- _VSTD::swap_ranges(data(), data() + _Size, __a.data());
- }
- // iterators:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- iterator begin() _NOEXCEPT {return iterator(data());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- iterator end() _NOEXCEPT {return iterator(data() + _Size);}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- const_iterator end() const _NOEXCEPT {return const_iterator(data() + _Size);}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- const_iterator cbegin() const _NOEXCEPT {return begin();}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- const_iterator cend() const _NOEXCEPT {return end();}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- const_reverse_iterator crend() const _NOEXCEPT {return rend();}
- // capacity:
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return _Size;}
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return _Size;}
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return _Size == 0;}
- // element access:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reference operator[](size_type __n) _NOEXCEPT {
- _LIBCPP_ASSERT(__n < _Size, "out-of-bounds access in std::array<T, N>");
- return __elems_[__n];
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- const_reference operator[](size_type __n) const _NOEXCEPT {
- _LIBCPP_ASSERT(__n < _Size, "out-of-bounds access in std::array<T, N>");
- return __elems_[__n];
- }
- _LIBCPP_CONSTEXPR_AFTER_CXX14 reference at(size_type __n)
- {
- if (__n >= _Size)
- __throw_out_of_range("array::at");
- return __elems_[__n];
- }
- _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference at(size_type __n) const
- {
- if (__n >= _Size)
- __throw_out_of_range("array::at");
- return __elems_[__n];
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference front() _NOEXCEPT {return (*this)[0];}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference front() const _NOEXCEPT {return (*this)[0];}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14 reference back() _NOEXCEPT {return (*this)[_Size - 1];}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11 const_reference back() const _NOEXCEPT {return (*this)[_Size - 1];}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- value_type* data() _NOEXCEPT {return __elems_;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- const value_type* data() const _NOEXCEPT {return __elems_;}
- };
- template <class _Tp>
- struct _LIBCPP_TEMPLATE_VIS array<_Tp, 0>
- {
- // types:
- typedef array __self;
- typedef _Tp value_type;
- typedef value_type& reference;
- typedef const value_type& const_reference;
- typedef value_type* iterator;
- typedef const value_type* const_iterator;
- typedef value_type* pointer;
- typedef const value_type* const_pointer;
- typedef size_t size_type;
- typedef ptrdiff_t difference_type;
- typedef _VSTD::reverse_iterator<iterator> reverse_iterator;
- typedef _VSTD::reverse_iterator<const_iterator> const_reverse_iterator;
- typedef typename conditional<is_const<_Tp>::value, const char,
- char>::type _CharType;
- struct _ArrayInStructT { _Tp __data_[1]; };
- _ALIGNAS_TYPE(_ArrayInStructT) _CharType __elems_[sizeof(_ArrayInStructT)];
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- value_type* data() _NOEXCEPT {return nullptr;}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- const value_type* data() const _NOEXCEPT {return nullptr;}
- // No explicit construct/copy/destroy for aggregate type
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- void fill(const value_type&) {
- static_assert(!is_const<_Tp>::value,
- "cannot fill zero-sized array of type 'const T'");
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- void swap(array&) _NOEXCEPT {
- static_assert(!is_const<_Tp>::value,
- "cannot swap zero-sized array of type 'const T'");
- }
- // iterators:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- iterator begin() _NOEXCEPT {return iterator(data());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- const_iterator begin() const _NOEXCEPT {return const_iterator(data());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- iterator end() _NOEXCEPT {return iterator(data());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- const_iterator end() const _NOEXCEPT {return const_iterator(data());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator rbegin() _NOEXCEPT {return reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- const_reverse_iterator rbegin() const _NOEXCEPT {return const_reverse_iterator(end());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reverse_iterator rend() _NOEXCEPT {return reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- const_reverse_iterator rend() const _NOEXCEPT {return const_reverse_iterator(begin());}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- const_iterator cbegin() const _NOEXCEPT {return begin();}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- const_iterator cend() const _NOEXCEPT {return end();}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- const_reverse_iterator crbegin() const _NOEXCEPT {return rbegin();}
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- const_reverse_iterator crend() const _NOEXCEPT {return rend();}
- // capacity:
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR size_type size() const _NOEXCEPT {return 0; }
- _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR size_type max_size() const _NOEXCEPT {return 0;}
- _LIBCPP_NODISCARD_AFTER_CXX17 _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR bool empty() const _NOEXCEPT {return true;}
- // element access:
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reference operator[](size_type) _NOEXCEPT {
- _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
- __libcpp_unreachable();
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- const_reference operator[](size_type) const _NOEXCEPT {
- _LIBCPP_ASSERT(false, "cannot call array<T, 0>::operator[] on a zero-sized array");
- __libcpp_unreachable();
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reference at(size_type) {
- __throw_out_of_range("array<T, 0>::at");
- __libcpp_unreachable();
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- const_reference at(size_type) const {
- __throw_out_of_range("array<T, 0>::at");
- __libcpp_unreachable();
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reference front() _NOEXCEPT {
- _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
- __libcpp_unreachable();
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- const_reference front() const _NOEXCEPT {
- _LIBCPP_ASSERT(false, "cannot call array<T, 0>::front() on a zero-sized array");
- __libcpp_unreachable();
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX14
- reference back() _NOEXCEPT {
- _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
- __libcpp_unreachable();
- }
- _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- const_reference back() const _NOEXCEPT {
- _LIBCPP_ASSERT(false, "cannot call array<T, 0>::back() on a zero-sized array");
- __libcpp_unreachable();
- }
- };
- #if _LIBCPP_STD_VER > 14
- template<class _Tp, class... _Args,
- class = enable_if_t<__all<_IsSame<_Tp, _Args>::value...>::value>
- >
- array(_Tp, _Args...)
- -> array<_Tp, 1 + sizeof...(_Args)>;
- #endif
- template <class _Tp, size_t _Size>
- inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
- operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
- {
- return _VSTD::equal(__x.begin(), __x.end(), __y.begin());
- }
- template <class _Tp, size_t _Size>
- inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
- operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
- {
- return !(__x == __y);
- }
- template <class _Tp, size_t _Size>
- inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
- operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
- {
- return _VSTD::lexicographical_compare(__x.begin(), __x.end(),
- __y.begin(), __y.end());
- }
- template <class _Tp, size_t _Size>
- inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
- operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
- {
- return __y < __x;
- }
- template <class _Tp, size_t _Size>
- inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
- operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
- {
- return !(__y < __x);
- }
- template <class _Tp, size_t _Size>
- inline _LIBCPP_INLINE_VISIBILITY
- _LIBCPP_CONSTEXPR_AFTER_CXX17 bool
- operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y)
- {
- return !(__x < __y);
- }
- template <class _Tp, size_t _Size>
- inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX17
- typename enable_if
- <
- _Size == 0 ||
- __is_swappable<_Tp>::value,
- void
- >::type
- swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
- _NOEXCEPT_(noexcept(__x.swap(__y)))
- {
- __x.swap(__y);
- }
- template <class _Tp, size_t _Size>
- struct _LIBCPP_TEMPLATE_VIS tuple_size<array<_Tp, _Size> >
- : public integral_constant<size_t, _Size> {};
- template <size_t _Ip, class _Tp, size_t _Size>
- struct _LIBCPP_TEMPLATE_VIS tuple_element<_Ip, array<_Tp, _Size> >
- {
- static_assert(_Ip < _Size, "Index out of bounds in std::tuple_element<> (std::array)");
- typedef _Tp type;
- };
- template <size_t _Ip, class _Tp, size_t _Size>
- inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- _Tp&
- get(array<_Tp, _Size>& __a) _NOEXCEPT
- {
- static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array)");
- return __a.__elems_[_Ip];
- }
- template <size_t _Ip, class _Tp, size_t _Size>
- inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- const _Tp&
- get(const array<_Tp, _Size>& __a) _NOEXCEPT
- {
- static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array)");
- return __a.__elems_[_Ip];
- }
- template <size_t _Ip, class _Tp, size_t _Size>
- inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- _Tp&&
- get(array<_Tp, _Size>&& __a) _NOEXCEPT
- {
- static_assert(_Ip < _Size, "Index out of bounds in std::get<> (std::array &&)");
- return _VSTD::move(__a.__elems_[_Ip]);
- }
- template <size_t _Ip, class _Tp, size_t _Size>
- inline _LIBCPP_INLINE_VISIBILITY _LIBCPP_CONSTEXPR_AFTER_CXX11
- const _Tp&&
- get(const array<_Tp, _Size>&& __a) _NOEXCEPT
- {
- static_assert(_Ip < _Size, "Index out of bounds in std::get<> (const std::array &&)");
- return _VSTD::move(__a.__elems_[_Ip]);
- }
- #if _LIBCPP_STD_VER > 17
- template <typename _Tp, size_t _Size, size_t... _Index>
- _LIBCPP_INLINE_VISIBILITY constexpr array<remove_cv_t<_Tp>, _Size>
- __to_array_lvalue_impl(_Tp (&__arr)[_Size], index_sequence<_Index...>) {
- return {{__arr[_Index]...}};
- }
- template <typename _Tp, size_t _Size, size_t... _Index>
- _LIBCPP_INLINE_VISIBILITY constexpr array<remove_cv_t<_Tp>, _Size>
- __to_array_rvalue_impl(_Tp(&&__arr)[_Size], index_sequence<_Index...>) {
- return {{_VSTD::move(__arr[_Index])...}};
- }
- template <typename _Tp, size_t _Size>
- _LIBCPP_INLINE_VISIBILITY constexpr array<remove_cv_t<_Tp>, _Size>
- to_array(_Tp (&__arr)[_Size]) noexcept(is_nothrow_constructible_v<_Tp, _Tp&>) {
- static_assert(
- !is_array_v<_Tp>,
- "[array.creation]/1: to_array does not accept multidimensional arrays.");
- static_assert(
- is_constructible_v<_Tp, _Tp&>,
- "[array.creation]/1: to_array requires copy constructible elements.");
- return _VSTD::__to_array_lvalue_impl(__arr, make_index_sequence<_Size>());
- }
- template <typename _Tp, size_t _Size>
- _LIBCPP_INLINE_VISIBILITY constexpr array<remove_cv_t<_Tp>, _Size>
- to_array(_Tp(&&__arr)[_Size]) noexcept(is_nothrow_move_constructible_v<_Tp>) {
- static_assert(
- !is_array_v<_Tp>,
- "[array.creation]/4: to_array does not accept multidimensional arrays.");
- static_assert(
- is_move_constructible_v<_Tp>,
- "[array.creation]/4: to_array requires move constructible elements.");
- return _VSTD::__to_array_rvalue_impl(_VSTD::move(__arr),
- make_index_sequence<_Size>());
- }
- #endif // _LIBCPP_STD_VER > 17
- _LIBCPP_END_NAMESPACE_STD
- #endif // _LIBCPP_ARRAY
|