chromium/third_party/libc++/src/include/array

// -*- 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:
    using value_type             = T;
    using pointer                = T*;
    using const_pointer          = const T*;
    using reference              = T&;
    using const_reference        = const T&;
    using size_type              = size_t;
    using difference_type        = ptrdiff_t;
    using iterator               = implementation-defined;
    using const_iterator         = implementation-defined;
    using reverse_iterator       = std::reverse_iterator<iterator>;
    using const_reverse_iterator = std::reverse_iterator<const_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);    // removed in C++20
template <class T, size_t N>
  bool operator<(const array<T,N>& x, const array<T,N>& y);     // removed in C++20
template <class T, size_t N>
  bool operator>(const array<T,N>& x, const array<T,N>& y);     // removed in C++20
template <class T, size_t N>
  bool operator<=(const array<T,N>& x, const array<T,N>& y);    // removed in C++20
template <class T, size_t N>
  bool operator>=(const array<T,N>& x, const array<T,N>& y);    // removed in C++20
template<class T, size_t N>
  constexpr synth-three-way-result<T>
    operator<=>(const array<T, N>& x, const array<T, N>& y);    // since 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/lexicographical_compare_three_way.h>
#include <__algorithm/swap_ranges.h>
#include <__assert>
#include <__config>
#include <__fwd/array.h>
#include <__iterator/reverse_iterator.h>
#include <__iterator/wrap_iter.h>
#include <__tuple/sfinae_helpers.h>
#include <__type_traits/conditional.h>
#include <__type_traits/conjunction.h>
#include <__type_traits/is_array.h>
#include <__type_traits/is_const.h>
#include <__type_traits/is_constructible.h>
#include <__type_traits/is_nothrow_constructible.h>
#include <__type_traits/is_same.h>
#include <__type_traits/is_swappable.h>
#include <__type_traits/is_trivially_relocatable.h>
#include <__type_traits/remove_cv.h>
#include <__utility/empty.h>
#include <__utility/integer_sequence.h>
#include <__utility/move.h>
#include <__utility/unreachable.h>
#include <stdexcept>
#include <version>

// standard-mandated includes

// [iterator.range]
#include <__iterator/access.h>
#include <__iterator/data.h>
#include <__iterator/empty.h>
#include <__iterator/reverse_access.h>
#include <__iterator/size.h>

// [array.syn]
#include <compare>
#include <initializer_list>

// [tuple.helper]
#include <__tuple/tuple_element.h>
#include <__tuple/tuple_size.h>

#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#  pragma GCC system_header
#endif

_LIBCPP_PUSH_MACROS
#include <__undef_macros>

_LIBCPP_BEGIN_NAMESPACE_STD

template <class _Tp, size_t _Size>
struct _LIBCPP_TEMPLATE_VIS array {};

array<_Tp, 0>;

#if _LIBCPP_STD_VER >= 17
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_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 bool
operator==(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {}

#if _LIBCPP_STD_VER <= 17

template <class _Tp, size_t _Size>
inline _LIBCPP_HIDE_FROM_ABI bool operator!=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
  return !(__x == __y);
}

template <class _Tp, size_t _Size>
inline _LIBCPP_HIDE_FROM_ABI bool operator<(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
  return std::lexicographical_compare(__x.begin(), __x.end(), __y.begin(), __y.end());
}

template <class _Tp, size_t _Size>
inline _LIBCPP_HIDE_FROM_ABI bool operator>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
  return __y < __x;
}

template <class _Tp, size_t _Size>
inline _LIBCPP_HIDE_FROM_ABI bool operator<=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
  return !(__y < __x);
}

template <class _Tp, size_t _Size>
inline _LIBCPP_HIDE_FROM_ABI bool operator>=(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {
  return !(__x < __y);
}

#else // _LIBCPP_STD_VER <= 17

template <class _Tp, size_t _Size>
_LIBCPP_HIDE_FROM_ABI constexpr __synth_three_way_result<_Tp>
operator<=>(const array<_Tp, _Size>& __x, const array<_Tp, _Size>& __y) {}

#endif // _LIBCPP_STD_VER <= 17

template <class _Tp, size_t _Size, __enable_if_t<_Size == 0 || __is_swappable_v<_Tp>, int> = 0>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX20 void swap(array<_Tp, _Size>& __x, array<_Tp, _Size>& __y)
    _NOEXCEPT_(noexcept(__x.swap(__y))) {}

tuple_size<array<_Tp, _Size>>;

tuple_element<_Ip, array<_Tp, _Size>>;

template <size_t _Ip, class _Tp, size_t _Size>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp& get(array<_Tp, _Size>& __a) _NOEXCEPT {}

template <size_t _Ip, class _Tp, size_t _Size>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp& get(const array<_Tp, _Size>& __a) _NOEXCEPT {}

template <size_t _Ip, class _Tp, size_t _Size>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 _Tp&& get(array<_Tp, _Size>&& __a) _NOEXCEPT {}

template <size_t _Ip, class _Tp, size_t _Size>
inline _LIBCPP_HIDE_FROM_ABI _LIBCPP_CONSTEXPR_SINCE_CXX14 const _Tp&& get(const array<_Tp, _Size>&& __a) _NOEXCEPT {}

#if _LIBCPP_STD_VER >= 20

template <typename _Tp, size_t _Size, size_t... _Index>
_LIBCPP_HIDE_FROM_ABI constexpr array<remove_cv_t<_Tp>, _Size>
__to_array_lvalue_impl(_Tp (&__arr)[_Size], index_sequence<_Index...>) {}

template <typename _Tp, size_t _Size, size_t... _Index>
_LIBCPP_HIDE_FROM_ABI constexpr array<remove_cv_t<_Tp>, _Size>
__to_array_rvalue_impl(_Tp (&&__arr)[_Size], index_sequence<_Index...>) {}

template <typename _Tp, size_t _Size>
_LIBCPP_HIDE_FROM_ABI constexpr array<remove_cv_t<_Tp>, _Size>
to_array(_Tp (&__arr)[_Size]) noexcept(is_nothrow_constructible_v<_Tp, _Tp&>) {}

template <typename _Tp, size_t _Size>
_LIBCPP_HIDE_FROM_ABI constexpr array<remove_cv_t<_Tp>, _Size>
to_array(_Tp (&&__arr)[_Size]) noexcept(is_nothrow_move_constructible_v<_Tp>) {}

#endif // _LIBCPP_STD_VER >= 20

_LIBCPP_END_NAMESPACE_STD

_LIBCPP_POP_MACROS

#if !defined(_LIBCPP_REMOVE_TRANSITIVE_INCLUDES) && _LIBCPP_STD_VER <= 20
#  include <algorithm>
#  include <concepts>
#  include <cstdlib>
#  include <iterator>
#  include <type_traits>
#  include <utility>
#endif

#endif // _LIBCPP_ARRAY