4.0.0
Freundlich's C++ toolkit
Classes | Typedefs | Functions
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 = typename fcppt::tuple::detail::apply_result_impl< Function, std::make_index_sequence< fcppt::tuple::size< fcppt::mpl::list::front< fcppt::mpl::list::object< Tuples... > > >::value >, Tuples... >::type
 Result of fcppt::tuple::apply. More...
 
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. More...
 
template<typename Array , typename = std::enable_if_t<fcppt::array::is_object<Array>::value>>
using fcppt::tuple::from_array_result = fcppt::mpl::list::as_tuple< fcppt::mpl::list::repeat< fcppt::type_traits::value_type< Array >, fcppt::array::size< Array > > >
 Result of fcppt::tuple::from_array. More...
 
template<typename T >
using fcppt::tuple::is_object = typename fcppt::tuple::detail::is_object< T >::type
 Tests whether a type is a tuple. More...
 
template<typename Tuple , typename Function >
using fcppt::tuple::map_result = 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. More...
 
template<typename Tuple , typename NewElement >
using fcppt::tuple::push_back_result = typename fcppt::tuple::detail::push_back_result< Tuple, NewElement >::type
 The result type of fcppt::tuple::push_back. More...
 
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. More...
 

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. More...
 
template<typename... Types>
bool fcppt::tuple::operator== (fcppt::tuple::object< Types... > const &a, fcppt::tuple::object< Types... > const &b)
 Compares two tuples for equality. More...
 
template<typename... Tuples, typename = std::enable_if_t<std::conjunction_v<fcppt::tuple::is_object<Tuples>...>>>
decltype(auto) fcppt::tuple::concat (Tuples &&..._tuples)
 Concatenates multiple tuples. More...
 
template<typename Array , typename = std::enable_if_t< 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. More...
 
template<std::size_t I, typename... Types, typename = std::enable_if_t<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. More...
 
template<std::size_t I, typename... Types, typename = std::enable_if_t<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. More...
 
template<typename Tuple , typename Function , typename = std::enable_if_t<fcppt::tuple::is_object<Tuple>::value>>
Tuple fcppt::tuple::init (Function const &_function)
 Constructs a tuple by calling a function with static indices. More...
 
template<typename F , typename Tuple , typename = std::enable_if_t<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. More...
 
template<typename Tuple , typename Function , typename = std::enable_if_t< 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. More...
 
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. More...
 
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. More...
 

Typedef Documentation

◆ apply_result

template<typename Function , typename... Tuples>
using fcppt::tuple::apply_result = typedef typename fcppt::tuple::detail::apply_result_impl< Function, std::make_index_sequence< fcppt::tuple::size<fcppt::mpl::list::front<fcppt::mpl::list::object<Tuples...> >>::value>, 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 = typedef 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 = typedef fcppt::mpl::list::as_tuple< fcppt::mpl::list::repeat<fcppt::type_traits::value_type<Array>, fcppt::array::size<Array> >>

◆ is_object

template<typename T >
using fcppt::tuple::is_object = typedef 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 = typedef 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 = typedef 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 = typedef 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.

◆ concat()

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

Concatenates multiple tuples.

◆ from_array()

template<typename Array , typename = std::enable_if_t< 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)

◆ get() [1/2]

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

Returns the I'th element of a nonconst tuple.

◆ get() [2/2]

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

Returns the I'th element of a const tuple.

◆ init()

template<typename Tuple , typename Function , typename = std::enable_if_t<fcppt::tuple::is_object<Tuple>::value>>
Tuple fcppt::tuple::init ( Function const &  _function)
inline

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 , typename = std::enable_if_t<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 
)
inlineconstexpr

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 , typename = std::enable_if_t< 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 
)
inline

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.