5#ifndef INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_TUPLE_HPP_
6#define INCLUDE_GUARD_ARENE_BASE_STDLIB_INCLUDE_STDLIB_DETAIL_TUPLE_HPP_
57template <
class... Types>
65template <
size_t I,
class... Types>
68 static_assert(I <
sizeof...(Types),
"index out of range for the given tuple");
80template <
class... Types>
81constexpr auto tie(Types&... args)
noexcept ->
tuple<Types&...> {
82 return tuple<Types&...>{args...};
104template <
size_t I,
class... Types>
108 return __get_tuple_impl<I>(tup).value();
116template <
size_t I,
class... Types>
123 return __get_tuple_impl<I>(
const_cast<tuple<Types...
>&>(tup)).value();
136template <
size_t I,
class... Types>
141 return static_cast<return_type
>(__get_tuple_impl<I>(tup).value());
152template <
size_t I,
class... Types>
160 return static_cast<return_type
>(__get_tuple_impl<I>(
const_cast<tuple<Types...
>&>(tup)).value());
173template <
class T,
class... Types>
174constexpr auto get(tuple<Types...>& tup)
noexcept -> T& {
178 first_idx == last_idx,
179 "Type-based std::get<T>(std::tuple<Types...>) can only be used if T appears exactly once in Types, but it "
180 "appears multiple times"
194template <
class T,
class... Types>
199 first_idx == last_idx,
200 "Type-based std::get<T>(std::tuple<Types...>) can only be used if T appears exactly once in Types, but it "
201 "appears multiple times"
215template <
class T,
class... Types>
220 first_idx == last_idx,
221 "Type-based std::get<T>(std::tuple<Types...>) can only be used if T appears exactly once in Types, but it "
222 "appears multiple times"
236template <
class T,
class... Types>
241 first_idx == last_idx,
242 "Type-based std::get<T>(std::tuple<Types...>) can only be used if T appears exactly once in Types, but it "
243 "appears multiple times"
257template <
class T,
class =
void>
288 return static_cast<T
>(
value);
299template <
size_t I,
class T,
class = arene::base::constra
ints<>>
314 constexpr auto value() &
noexcept -> T& {
return this->
get_value(base_tag_type{}); }
320 constexpr auto value() const& noexcept -> T const& {
return this->
get_value(base_tag_type{}); }
332template <
class Indices,
class Types>
338template <std::
size_t I,
class Tuple>
349template <
class Dest,
class Source,
std::size_t... Indices>
360template <
class Lhs,
class Rhs,
std::size_t... Indices>
377template <
template <
class...>
class Trait,
class TupleTypeList,
class List,
class =
void>
388template <
template <
class...>
class Trait,
class... T,
class... U>
391 arene::base::type_list<T...>,
403template <
size_t... I,
class... T>
414 template <
template <
class...>
class Trait,
class... U>
415 static constexpr bool are_all_arguments_v{
456 size_t N =
sizeof...(T),
481 (
sizeof...(UTypes) != 0U) &&
482 are_all_arguments_v<is_constructible, UTypes&&...>
510 (
sizeof...(UTypes) != 0U) &&
511 are_all_arguments_v<is_constructible, UTypes const&...>
535 (
sizeof...(UTypes) != 0U) &&
600template <
class LTuple,
class RTuple>
606template <
class... LTypes,
class... RTypes>
613template <
class LTuple,
class RTuple>
619template <
class... LTypes,
class... RTypes>
632template <
std::size_t Idx,
class... LTypes,
class... RTypes,
646template <
std::size_t Idx,
class... LTypes,
class... RTypes,
660template <
std::size_t Idx,
class... LTypes,
class... RTypes,
674template <
std::size_t Idx,
class... LTypes,
class... RTypes,
684 return ::std::tuple_detail::elements_less<Idx + 1UL>(left, right);
694template <
class... Types>
725 using impl_type::impl_type;
736 template <
template <
class...>
class Trait,
class... U>
737 static constexpr bool are_all_arguments_v{
765 (
sizeof...(UTypes) != 0U) &&
766 are_all_arguments_v<is_assignable, UTypes const&...>
790 (
sizeof...(UTypes) != 0U) &&
791 are_all_arguments_v<is_assignable, UTypes&&...>
813 (
sizeof...(Types) == 2U) &&
814 are_all_arguments_v<is_assignable, U1 const&, U2 const&>
816 auto operator=(pair<U1, U2>
const& other)
noexcept(are_all_arguments_v<is_nothrow_assignable, U1 const&, U2 const&>)
837 (
sizeof...(Types) == 2U) &&
838 are_all_arguments_v<is_assignable, U1&&, U2&&>
840 auto operator=(pair<U1, U2>&& other)
noexcept(are_all_arguments_v<is_nothrow_assignable, U1&&, U2&&>) ->
tuple& {
894template <
class... LTypes,
class... RTypes>
899 static_assert(
sizeof...(LTypes) ==
sizeof...(RTypes),
"Only tuples of the same size can be compared");
900 return ::std::tuple_detail::elements_equal<0UL>(left, right);
909template <
class... LTypes,
class... RTypes>
912 return !(left == right);
921template <
class... LTypes,
class... RTypes>
926 static_assert(
sizeof...(LTypes) ==
sizeof...(RTypes),
"Only tuples of the same size can be compared");
927 return ::std::tuple_detail::elements_less<0UL>(left, right);
936template <
class... LTypes,
class... RTypes>
939 return !(right < left);
948template <
class... LTypes,
class... RTypes>
960template <
class... LTypes,
class... RTypes>
963 return !(left < right);
A class to hold an instance of a type that is likely to be empty, such as a comparator or allocator,...
Definition ebo_holder.hpp:42
constexpr ebo_holder() noexcept(std::is_nothrow_default_constructible< T >::value)
Definition ebo_holder.hpp:57
constexpr auto get_value(integral_constant< size_t, I >) const &noexcept -> value_type const &
Definition ebo_holder.hpp:89
A backport of the C++20 std::identity function object. It returns its input unchanged.
Definition identity.hpp:21
A helper class to represent a compile-time constant with the specified type and value....
Definition integral_constant.hpp:23
Type trait to detect if a type is constructible from arguments of the specified types.
Definition is_constructible.hpp:29
Type trait to detect if an instance of To is assignable to from arguments of From without throwing.
Definition is_assignable.hpp:78
Type trait to detect if a type is constructible from arguments of the specified types and is noexcept...
Definition is_constructible.hpp:84
determine if a trait predicate is true for all pairs of T... and U...
Definition tuple.hpp:378
constexpr auto operator()(U &&value) noexcept -> T
convert the given value to T&
Definition tuple.hpp:287
handles reference binding when initializing a reference from a forwarded argument
Definition tuple.hpp:258
constexpr tuple_impl() noexcept(arene::base::all_of_v< is_nothrow_default_constructible_v< T >... >)
default constructor
Definition tuple.hpp:434
constexpr tuple_impl(pair< UTypes... > const &other) noexcept(are_all_arguments_v< is_nothrow_constructible, UTypes const &... >)
copy-from-pair constructor
Definition tuple.hpp:562
constexpr tuple_impl(tuple< UTypes... > const &other) noexcept(are_all_arguments_v< is_nothrow_constructible, UTypes const &... >)
copy-from-other-tuple constructor
Definition tuple.hpp:513
constexpr tuple_impl(pair< UTypes... > &&other) noexcept(are_all_arguments_v< is_nothrow_constructible, UTypes &&... >)
move-from-pair constructor
Definition tuple.hpp:584
constexpr tuple_impl(tuple< UTypes... > &&other) noexcept(are_all_arguments_v< is_nothrow_constructible, UTypes &&... >)
move-from-other-tuple constructor
Definition tuple.hpp:538
constexpr tuple_impl(T const &... args) noexcept(arene::base::all_of_v< is_nothrow_copy_constructible_v< T >... >)
direct constructor
Definition tuple.hpp:459
constexpr tuple_impl(UTypes &&... args) noexcept(are_all_arguments_v< is_nothrow_constructible, UTypes &&... >)
converting constructor
Definition tuple.hpp:484
helper used in the implementation of a tuple
Definition tuple.hpp:333
contains a single element of a tuple
Definition tuple.hpp:300
constexpr auto value() const &noexcept -> T const &
obtain the value contained in this leaf
Definition tuple.hpp:320
constexpr auto value() &noexcept -> T &
obtain the value contained in this leaf
Definition tuple.hpp:314
arene::base::type_lists::at_t< arene::base::type_list< Types... >, I > type
the element type at index I
Definition tuple.hpp:71
obtains the type of the specified element
Definition tuple_element.hpp:28
obtain the number of elements in a tuple-like type
Definition tuple_size.hpp:22
a heterogeneous, fixed-size collection of values
Definition tuple.hpp:695
friend constexpr auto __get_tuple_impl(Tuple &tup) noexcept -> tuple_detail::tuple_leaf_t< I, Tuple > &
obtain the tuple_leaf element at a specified index
Definition tuple.hpp:718
auto swap(tuple &rhs) noexcept(arene::base::all_of_v< arene::base::is_nothrow_swappable_v< Types >... >) -> void
swap with another tuple
Definition tuple.hpp:860
Public export header for the constraints subpackage.
typename at< L0, Index >::type at_t
Get the n-th element from a type list.
Definition at.hpp:113
constexpr auto last_index_of_v
Template meta-function for querying the last 0-based index of 'T' within a list of types,...
constexpr void consume_values(std::initializer_list< consume_values_detail::anything > const &) noexcept
Consume a list of values and discard them. Must be called with an extra pair of braces around the exp...
Definition consume_values.hpp:73
constexpr bool all_of_v
Trait which tests if every value in a parameter pack is true .
constexpr bool is_nothrow_equality_comparable_v
constexpr auto index_of_v
Template meta-function for querying the 0-based index of 'T' within a list of types,...
typename constraints_impl::constraints< EnableIfs... >::type constraints
Helper used to express template constraints in a consistent way using std::enable_if_t.
Definition constraints.hpp:51
Definition accumulate.hpp:36
constexpr auto elements_less(tuple< LTypes... > const &, tuple< RTypes... > const &) noexcept -> bool
Check if the left tuple is less than the right tuple, starting at Idx and counting up.
Definition tuple.hpp:662
constexpr bool all_elements_nothrow_equality_comparable_v
A type trait to determine the noexcept specification of elementwise equality comparison.
Definition tuple.hpp:601
auto __get_tuple_impl() -> void=delete
poison pill declaration of __get_tuple_impl
constexpr bool all_elements_nothrow_less_than_comparable_v
A type trait to determine the noexcept specification of elementwise less-than comparison.
Definition tuple.hpp:614
void memberwise_forward_assign(Dest &dest, Source &&source, index_sequence< Indices... >)
helper used to implement move assignment
Definition tuple.hpp:350
tuple_leaf< I, tuple_element_t< I, Tuple > > tuple_leaf_t
alias to the tuple leaf type at index I of a tuple
Definition tuple.hpp:339
void memberwise_swap(Lhs &lhs, Rhs &&rhs, index_sequence< Indices... >)
helper used to implement swap
Definition tuple.hpp:361
constexpr auto elements_equal(tuple< LTypes... > const &, tuple< RTypes... > const &) noexcept -> bool
Check if element Idx and all subsequent elements of the two tuples are equal.
Definition tuple.hpp:634
constexpr Type integral_constant< Type, Value >::value
Out-of-line definition for the value constant.
Definition integral_constant.hpp:64
auto operator<=(move_iterator< Iterator1 > const &lhs, move_iterator< Iterator2 > const &rhs) -> bool
Check if one iterator is less than or equal to another.
Definition move_iterator.hpp:294
void swap(pair< T1, T2 > &lhs, pair< T1, T2 > &rhs) noexcept(arene::base::is_nothrow_swappable_v< T1 > &&arene::base::is_nothrow_swappable_v< T2 >)
Swap a pair with another instance of the same type. Swaps lhs.first with rhs.first and swaps lhs....
Definition pair.hpp:448
auto operator>=(move_iterator< Iterator1 > const &lhs, move_iterator< Iterator2 > const &rhs) -> bool
Check if one iterator is greater than or equal to another.
Definition move_iterator.hpp:316
bool_constant< false > false_type
An alias for bool_constant<false>
Definition integral_constant.hpp:79
constexpr auto move(T &&value) noexcept -> remove_reference_t< T > &&
Cast a value to an rvalue.
Definition move.hpp:30
integral_constant< bool, Value > bool_constant
An alias for integral_constant<bool,Value>
Definition integral_constant.hpp:71
auto operator!=(move_iterator< Iterator1 > const &lhs, move_iterator< Iterator2 > const &rhs) -> bool
Check if two iterators are not equal.
Definition move_iterator.hpp:271
integer_sequence< size_t, Ints... > index_sequence
A helper alias template for integer_sequence<size_t, Ints>
Definition integer_sequence.hpp:218
::size_t size_t
A type suitable for holding the size of an object.
Definition cstddef.hpp:29
typename enable_if< Condition, Type >::type enable_if_t
Type alias to support constraining templates. Is an alias for the specified type if the Condition is ...
Definition enable_if.hpp:41
auto declval() noexcept -> T &&
A dummy function that is declared but not defined, with a user-specified return type,...
auto operator<(move_iterator< Iterator1 > const &lhs, move_iterator< Iterator2 > const &rhs) -> bool
Check if one iterator is less than another.
Definition move_iterator.hpp:283
auto operator==(move_iterator< Iterator1 > const &lhs, move_iterator< Iterator2 > const &rhs) -> bool
Check if two iterators are equal.
Definition move_iterator.hpp:258
constexpr auto tie(Types &... args) noexcept -> tuple< Types &... >
Constructs a tuple of references to the given arguments.
Definition tuple.hpp:81
constexpr bool is_reference_v
Check if the supplied template argument is a reference or not. The value is true if so,...
typename tuple_element< I, T >::type tuple_element_t
obtains the type of the specified element
Definition tuple_element.hpp:68
constexpr auto get(pair< T1, T2 > &values) noexcept -> tuple_element_t< I, pair< T1, T2 > > &
access an element of a pair
Definition pair.hpp:665
make_index_sequence< sizeof...(Types)> index_sequence_for
A helper alias template convert any type parameter pack into an index sequence of the same length.
Definition integer_sequence.hpp:230
constexpr bool is_nothrow_default_constructible_v
Type trait to detect if an instance of T is default constructible without throwing.
typename remove_const< Type >::type remove_const_t
remove const from the provided type. An alias for the modified type.
Definition remove_const.hpp:36
constexpr auto forward(remove_reference_t< T > &value) noexcept -> T &&
Cast a value to an rvalue if T is an rvalue or rvalue reference, otherwise forward an lvalue referenc...
Definition forward.hpp:24
auto operator>(move_iterator< Iterator1 > const &lhs, move_iterator< Iterator2 > const &rhs) -> bool
Check if one iterator is greater than another.
Definition move_iterator.hpp:305
an empty struct that is a list of types - cheaper to instantiate than tuple
Definition type_list.hpp:19
Provides the all_of_v<bool...> trait.