2.10.0
Freundlich's C++ toolkit
Typedefs | Functions
fcppt.container.array

Description

Functions for std::array

Typedefs

template<typename Array >
using fcppt::container::array::size = typename fcppt::container::array::detail::size< Array >::type
 Gets the size of an array. More...
 

Functions

template<typename Function , typename Array1 , typename... Arrays>
auto fcppt::container::array::apply (Function const &_function, Array1 &&_array1, Arrays &&... _arrays) -> std::array< decltype(_function(fcppt::move_if_rvalue< Array1 >(std::declval< fcppt::container::to_reference_type< std::remove_reference_t< Array1 > > >()), fcppt::move_if_rvalue< Arrays >(std::declval< fcppt::container::to_reference_type< std::remove_reference_t< Arrays > > >())...)), fcppt::container::array::size< fcppt::type_traits::remove_cv_ref_t< Array1 > >::value >
 Applies a function to each tuple of elements of multiple arrays and returns an array containing the results. More...
 
template<typename Array , typename Function >
Array fcppt::container::array::init (Function const &_function)
 Constructs an array by calling a function with static indices. More...
 
template<typename Array >
Array fcppt::container::array::init_const (fcppt::type_traits::value_type< Array > const &_value)
 Constructs an array from a value. More...
 
template<typename Array , typename Function >
Array fcppt::container::array::init_move (Function const &_function)
 Constructs an array by calling a function for every element. More...
 
template<typename... Args>
std::array< ::brigand::front< ::brigand::list< fcppt::type_traits::remove_cv_ref_t< Args >... > >, sizeof...(Args)> fcppt::container::array::make (Args &&... _args)
 Make an array out of a parameter pack. More...
 
template<typename Array , typename Function >
auto fcppt::container::array::map (Array &&_source, Function const &_function) -> std::array< decltype(_function(fcppt::move_if_rvalue< Array >(std::declval< fcppt::container::to_reference_type< std::remove_reference_t< Array > > >()))), fcppt::container::array::size< fcppt::type_traits::remove_cv_ref_t< Array > >::value >
 Applies a function to every element of an array and returns an array of the results. More...
 
template<typename Source , typename NewElement >
std::array< fcppt::type_traits::value_type< fcppt::type_traits::remove_cv_ref_t< Source > >, fcppt::container::array::size< fcppt::type_traits::remove_cv_ref_t< Source > >::value+1u > fcppt::container::array::push_back (Source &&_source, NewElement &&_new_element)
 Pushes a new element to the back of an array. More...
 

Typedef Documentation

◆ size

template<typename Array >
using fcppt::container::array::size = typedef typename fcppt::container::array::detail::size< Array >::type

Gets the size of an array.

Derives from an integral constant that contains the size of Array.

Template Parameters
ArrayMust be a std::array

Function Documentation

◆ apply()

template<typename Function , typename Array1 , typename... Arrays>
auto fcppt::container::array::apply ( Function const &  _function,
Array1 &&  _array1,
Arrays &&...  _arrays 
) -> std::array< decltype( _function( fcppt::move_if_rvalue< Array1 >( std::declval< fcppt::container::to_reference_type< std::remove_reference_t< Array1 > > >() ), fcppt::move_if_rvalue< Arrays >( std::declval< fcppt::container::to_reference_type< std::remove_reference_t< Arrays > > >() )... ) ), fcppt::container::array::size< fcppt::type_traits::remove_cv_ref_t< Array1 > >::value >

Applies a function to each tuple of elements of multiple arrays and returns an array containing the results.

Calls _function(e, e_1, ..., e_n) for every e of _array1 and e_1, ..., e_n of _arrays.

Template Parameters
Array1Must be a std::array.
ArraysMust be std::arrays.
FunctionMust be a function callable as R (Array1::value_type, Arrays::value_type...), where R is the result type.

◆ init()

template<typename Array , typename Function >
Array fcppt::container::array::init ( Function const &  _function)
inline

Constructs an array by calling a function with static indices.

Constructs an array of type Array by calling _function(std::integral_constant<std::size_t, Index>) for every index.

Template Parameters
ArrayMust be a std::array.
FunctionMust be a function callable as Array::value_type (std::integral_constant<std::size_t, I>).

◆ init_const()

template<typename Array >
Array fcppt::container::array::init_const ( fcppt::type_traits::value_type< Array > const &  _value)
inline

Constructs an array from a value.

Constructs an array of type Array by initializing every element with _value.

Template Parameters
ArrayMust be a std::array.

◆ init_move()

template<typename Array , typename Function >
Array fcppt::container::array::init_move ( Function const &  _function)
inline

Constructs an array by calling a function for every element.

Constructs an array of type Array by initializing every element with _function().

Template Parameters
ArrayMust be a std::array.
FunctionA function callable as Array::value_type ().

◆ make()

template<typename... Args>
std::array< ::brigand::front< ::brigand::list< fcppt::type_traits::remove_cv_ref_t< Args >... > >, sizeof...(Args)> fcppt::container::array::make ( Args &&...  _args)
inline

Make an array out of a parameter pack.

Let _args be (a_1,...,a_n). All elements of _args must be of the same type T. The result is std::array<T,n>{a_1,...,a_n}.

Template Parameters
ArgsA parameter pack t_1,...,t_n such that remove_cv_ref<t_1> = ... = remove_cv_ref<t_n>.

◆ map()

template<typename Array , typename Function >
auto fcppt::container::array::map ( Array &&  _source,
Function const &  _function 
) -> std::array< decltype( _function( fcppt::move_if_rvalue< Array >( std::declval< fcppt::container::to_reference_type< std::remove_reference_t< Array > > >() ) ) ), fcppt::container::array::size< fcppt::type_traits::remove_cv_ref_t< Array > >::value >
inline

Applies a function to every element of an array and returns an array of the results.

Calls _function(element) for every element of _source.

Example:

typedef
std::array<int,3>
three_ints;
three_ints const a{{ 1,2,3 }};
three_ints const b(
a,
[](int const _arg) { return _arg * 3; }
)
);
// b now contains: 3, 6, 9
Template Parameters
ArrayMust be a std::array.
FunctionMust be a function callable as R (Array::value_type), where R is the result type.

◆ push_back()

template<typename Source , typename NewElement >
std::array< fcppt::type_traits::value_type< fcppt::type_traits::remove_cv_ref_t< Source > >, fcppt::container::array::size< fcppt::type_traits::remove_cv_ref_t< Source > >::value + 1u> fcppt::container::array::push_back ( Source &&  _source,
NewElement &&  _new_element 
)

Pushes a new element to the back of an array.

Pushes _new_element to the back of _source.

Template Parameters
SourceMust be a std::array.
NewElementMust be the same as value_type<Source>