4.6.0
Freundlich's C++ toolkit
Loading...
Searching...
No Matches
fcppt.tuple

Description

Like std::tuple but with a proper constructor.

Classes

class  fcppt::tuple::object< Types >
 Like std::tuple but with a proper constructor. More...
 

Typedefs

template<typename Function , typename... Tuples>
using fcppt::tuple::apply_result
 Result of fcppt::tuple::apply.
 
template<std::size_t I, typename T , typename = fcppt::tuple::is_object<T>>
using fcppt::tuple::element = std::tuple_element_t<I, fcppt::tuple::impl_type<T>>
 The type of the I'th element of a tuple.
 
template<typename Array , typename = std::enable_if_t<fcppt::array::is_object<Array>::value>>
using fcppt::tuple::from_array_result
 Result of fcppt::tuple::from_array.
 
template<typename T >
using fcppt::tuple::is_object = typename fcppt::tuple::detail::is_object<T>::type
 Tests whether a type is a tuple.
 
template<typename Tuple , typename Function >
using fcppt::tuple::map_result
 The result type of fcppt::tuple::map.
 
template<typename Tuple , typename NewElement >
using fcppt::tuple::push_back_result
 The result type of fcppt::tuple::push_back.
 
template<typename T , typename = std::enable_if_t<fcppt::tuple::is_object<T>::value>>
using fcppt::tuple::types_of = typename fcppt::tuple::detail::types_of<T>::type
 The types of a tuple as an mpl::list.
 

Functions

template<typename Function , typename... Tuples>
fcppt::tuple::apply_result< Function, Tuples... > fcppt::tuple::apply (Function const &_function, Tuples &&..._tuples)
 Applies a function to each tuple of elements of multiple tuples and returns a tuple containing the results.
 
template<typename Result , typename Tuple >
requires (fcppt::tuple::is_object<std::remove_cvref_t<Tuple>>::value)
constexpr Result fcppt::tuple::as_struct (Tuple &&_tuple)
 Converts a tuple to a struct.
 
template<typename... Types>
bool fcppt::tuple::operator== (fcppt::tuple::object< Types... > const &a, fcppt::tuple::object< Types... > const &b)
 Compares two tuples for equality.
 
template<typename... Tuples>
requires (std::conjunction_v<fcppt::tuple::is_object<Tuples>...>)
decltype(auto) fcppt::tuple::concat (Tuples &&..._tuples)
 Concatenates multiple tuples.
 
template<typename Array >
requires (fcppt::array::is_object<std::remove_cvref_t<Array>>::value)
fcppt::tuple::from_array_result< std::remove_cvref_t< Array > > fcppt::tuple::from_array (Array &&_source)
 Converts an fcppt::array::object to an fcppt::tuple::object.
 
template<std::size_t I, typename... Types>
requires (std::less<>{}(I, sizeof...(Types)))
constexpr fcppt::tuple::element< I, fcppt::tuple::object< Types... > > & fcppt::tuple::get (fcppt::tuple::object< Types... > &_value) noexcept
 Returns the I'th element of a nonconst tuple.
 
template<std::size_t I, typename... Types>
requires (std::less<>{}(I, sizeof...(Types)))
constexpr fcppt::tuple::element< I, fcppt::tuple::object< Types... > > const & fcppt::tuple::get (fcppt::tuple::object< Types... > const &_value) noexcept
 Returns the I'th element of a const tuple.
 
template<typename Tuple , typename Function >
requires (fcppt::tuple::is_object<Tuple>::value)
Tuple fcppt::tuple::init (Function const &_function)
 Constructs a tuple by calling a function with static indices.
 
template<typename F , typename Tuple >
requires (std::conjunction_v< fcppt::tuple::is_object<std::remove_cvref_t<Tuple>>, fcppt::mpl::is_invocable<F, fcppt::tuple::types_of<std::remove_cvref_t<Tuple>>>>)
constexpr decltype(auto) fcppt::tuple::invoke (F const &_f, Tuple &&_tuple)
 Calls a function with the elements of a tuple.
 
template<typename Tuple , typename Function >
requires (fcppt::tuple::is_object<std::remove_cvref_t<Tuple>>::value)
fcppt::tuple::map_result< Tuple, Function > fcppt::tuple::map (Tuple &&_tuple, Function const &_function)
 Maps over a tuple.
 
template<typename Ch , typename Traits , typename... Types>
std::basic_ostream< Ch, Traits > & fcppt::tuple::operator<< (std::basic_ostream< Ch, Traits > &_stream, fcppt::tuple::object< Types... > const &_tuple)
 Outputs a tuple to a stream.
 
template<typename Tuple , typename NewElement >
fcppt::tuple::push_back_result< std::remove_cvref_t< Tuple >, std::remove_cvref_t< NewElement > > fcppt::tuple::push_back (Tuple &&_tuple, NewElement &&_new_element)
 Pushes an element to the back of a fcppt::tuple::object.
 

Typedef Documentation

◆ apply_result

template<typename Function , typename... Tuples>
using fcppt::tuple::apply_result
Initial value:
typename fcppt::tuple::detail::apply_result_impl<
Function,
std::make_index_sequence<
Tuples...>::type

Result of fcppt::tuple::apply.

◆ element

template<std::size_t I, typename T , typename = fcppt::tuple::is_object<T>>
using fcppt::tuple::element = std::tuple_element_t<I, fcppt::tuple::impl_type<T>>

The type of the I'th element of a tuple.

◆ from_array_result

template<typename Array , typename = std::enable_if_t<fcppt::array::is_object<Array>::value>>
using fcppt::tuple::from_array_result

◆ is_object

template<typename T >
using fcppt::tuple::is_object = typename fcppt::tuple::detail::is_object<T>::type

Tests whether a type is a tuple.

◆ map_result

template<typename Tuple , typename Function >
using fcppt::tuple::map_result
Initial value:
typename fcppt::tuple::detail::map_result<
std::make_index_sequence<fcppt::tuple::size<std::remove_cvref_t<Tuple>>::value>,
Tuple,
std::remove_cvref_t<Function>>::type

The result type of fcppt::tuple::map.

◆ push_back_result

template<typename Tuple , typename NewElement >
using fcppt::tuple::push_back_result
Initial value:
typename fcppt::tuple::detail::push_back_result<Tuple, NewElement>::type

The result type of fcppt::tuple::push_back.

◆ types_of

template<typename T , typename = std::enable_if_t<fcppt::tuple::is_object<T>::value>>
using fcppt::tuple::types_of = typename fcppt::tuple::detail::types_of<T>::type

The types of a tuple as an mpl::list.

Function Documentation

◆ apply()

template<typename Function , typename... Tuples>
fcppt::tuple::apply_result< Function, Tuples... > fcppt::tuple::apply ( Function const & _function,
Tuples &&... _tuples )

Applies a function to each tuple of elements of multiple tuples and returns a tuple containing the results.

Let Tuples=(t_1,...,t_n), where t_i = u_{i,1}, ..., u_{i,k}. Calculates r_j = function(u{1,j}, ..., u_{n,j}) for every 1 <= j <= k.

Template Parameters
TuplesMust be fcppt::tuple::objects.

◆ as_struct()

template<typename Result , typename Tuple >
requires (fcppt::tuple::is_object<std::remove_cvref_t<Tuple>>::value)
Result fcppt::tuple::as_struct ( Tuple && _tuple)
nodiscardconstexpr

Converts a tuple to a struct.

Template Parameters
ResultHas to be constructible from the tuple's types, i.e. if Tuple = (t_1,..,t_n), then Result has to be constructible from t_1, ..., t_n. TODO(philipp): concepts

◆ concat()

template<typename... Tuples>
requires (std::conjunction_v<fcppt::tuple::is_object<Tuples>...>)
decltype(auto) fcppt::tuple::concat ( Tuples &&... _tuples)

Concatenates multiple tuples.

◆ from_array()

template<typename Array >
requires (fcppt::array::is_object<std::remove_cvref_t<Array>>::value)
fcppt::tuple::from_array_result< std::remove_cvref_t< Array > > fcppt::tuple::from_array ( Array && _source)
nodiscard

◆ get() [1/2]

template<std::size_t I, typename... Types>
requires (std::less<>{}(I, sizeof...(Types)))
fcppt::tuple::element< I, fcppt::tuple::object< Types... > > & fcppt::tuple::get ( fcppt::tuple::object< Types... > & _value)
nodiscardconstexprnoexcept

Returns the I'th element of a nonconst tuple.

◆ get() [2/2]

template<std::size_t I, typename... Types>
requires (std::less<>{}(I, sizeof...(Types)))
fcppt::tuple::element< I, fcppt::tuple::object< Types... > > const & fcppt::tuple::get ( fcppt::tuple::object< Types... > const & _value)
nodiscardconstexprnoexcept

Returns the I'th element of a const tuple.

◆ init()

template<typename Tuple , typename Function >
requires (fcppt::tuple::is_object<Tuple>::value)
Tuple fcppt::tuple::init ( Function const & _function)
inlinenodiscard

Constructs a tuple by calling a function with static indices.

Constructs a tuple of type Tuple by calling _function(std::integral_constant<std::size_t, Index>) for every index.

Template Parameters
TupleMust be an fcppt::tuple::object.
FunctionMust be a function callable as T_i (std::integral_constant<std::size_t, i>) for 1 <= i <= n, where Tuple=(T_1,...,T_n).

◆ invoke()

template<typename F , typename Tuple >
requires (std::conjunction_v< fcppt::tuple::is_object<std::remove_cvref_t<Tuple>>, fcppt::mpl::is_invocable<F, fcppt::tuple::types_of<std::remove_cvref_t<Tuple>>>>)
decltype(auto) fcppt::tuple::invoke ( F const & _f,
Tuple && _tuple )
nodiscardconstexpr

Calls a function with the elements of a tuple.

This is the same as std::apply. Let _tuple = (x_1,...,x_n). Then the result is f(x_1,...,x_n).

◆ map()

template<typename Tuple , typename Function >
requires (fcppt::tuple::is_object<std::remove_cvref_t<Tuple>>::value)
fcppt::tuple::map_result< Tuple, Function > fcppt::tuple::map ( Tuple && _tuple,
Function const & _function )

Maps over a tuple.

Let _tuple be (v_1,...,v_n). The result of the function is the tuple (_function(v_1),...,_function(v_n)).

Template Parameters
TupleMust be an fcppt::tuple::object.
FunctionMust be callable with every type in Tuple.

◆ operator<<()

template<typename Ch , typename Traits , typename... Types>
std::basic_ostream< Ch, Traits > & fcppt::tuple::operator<< ( std::basic_ostream< Ch, Traits > & _stream,
fcppt::tuple::object< Types... > const & _tuple )

Outputs a tuple to a stream.

◆ operator==()

template<typename... Types>
bool fcppt::tuple::operator== ( fcppt::tuple::object< Types... > const & a,
fcppt::tuple::object< Types... > const & b )
inlinenodiscard

Compares two tuples for equality.

◆ push_back()

template<typename Tuple , typename NewElement >
fcppt::tuple::push_back_result< std::remove_cvref_t< Tuple >, std::remove_cvref_t< NewElement > > fcppt::tuple::push_back ( Tuple && _tuple,
NewElement && _new_element )

Pushes an element to the back of a fcppt::tuple::object.

Let _tuple be (v_1,...,v_n). The result of the function is (v_1,...,v_n,_new_element).

Template Parameters
TupleMust be a fcppt::tuple::object.