4.6.0
Freundlich's C++ toolkit
|
Like std::array but with a proper constructor.
Typedefs | |
template<typename T > | |
using | fcppt::array::is_object = typename fcppt::array::detail::is_object<T>::type |
Tests whether a type is a array. | |
template<typename Array , typename = std::enable_if_t<fcppt::array::is_object<Array>::value>> | |
using | fcppt::array::size = std::integral_constant<std::size_t,std::tuple_size_v<fcppt::array::impl_type<Array>>> |
Gets the size of an array. | |
template<typename Array , typename = std::enable_if_t<fcppt::array::is_object<Array>::value>> | |
using | fcppt::array::value_type = fcppt::type_traits::value_type<Array> |
The value type of an array. | |
Functions | |
template<typename Array1 , typename Array2 > requires (std::conjunction_v< fcppt::array::is_object<std::remove_cvref_t<Array1>>, fcppt::array::is_object<std::remove_cvref_t<Array2>>, std::is_same< fcppt::array::value_type<std::remove_cvref_t<Array1>>, fcppt::array::value_type<std::remove_cvref_t<Array2>>>>) | |
fcppt::array::object< fcppt::array::value_type< std::remove_cvref_t< Array1 > >, fcppt::array::size< std::remove_cvref_t< Array1 > >::value+fcppt::array::size< std::remove_cvref_t< Array2 > >::value > | fcppt::array::append (Array1 &&_array1, Array2 &&_array2) |
Appends two arrays. | |
template<typename Function , typename Array1 , typename... Arrays> | |
auto | fcppt::array::apply (Function const &_function, Array1 &&_array1, Arrays &&..._arrays) -> fcppt::array::object< 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::array::size< std::remove_cvref_t< Array1 > >::value > requires(std::conjunction_v< fcppt::array::is_object< std::remove_cvref_t< Array1 > >, fcppt::array::is_object< std::remove_cvref_t< Arrays > >..., std::is_same< fcppt::array::size< std::remove_cvref_t< Array1 > >, fcppt::array::size< std::remove_cvref_t< Arrays > > >... >) |
Applies a function to each tuple of elements of multiple arrays and returns an array containing the results. | |
template<typename T , std::size_t Size> | |
bool | fcppt::array::operator== (fcppt::array::object< T, Size > const &a, fcppt::array::object< T, Size > const &b) |
Compares two arrays for equality. | |
template<std::size_t Size, typename Source > | |
fcppt::optional::object< fcppt::array::object< fcppt::type_traits::value_type< std::remove_cvref_t< Source > >, Size > > | fcppt::array::from_range (Source &&_source) |
Creates an fcppt::array::object out of a range. | |
template<std::size_t I, typename T , std::size_t Size> requires (std::less<>{}(I, Size)) | |
constexpr T & | fcppt::array::get (fcppt::array::object< T, Size > &_value) noexcept |
Returns the I'th element of a nonconst array. | |
template<std::size_t I, typename T , std::size_t Size> requires (std::less<>{}(I, Size)) | |
constexpr T const & | fcppt::array::get (fcppt::array::object< T, Size > const &_value) noexcept |
Returns the I'th element of a const array. | |
template<typename Array , typename Function > requires fcppt::array::is_object<Array>::value | |
Array | fcppt::array::init (Function const &_function) |
Constructs an array by calling a function with static indices. | |
template<typename Array1 , typename... Arrays> requires (std::conjunction_v< fcppt::array::is_object<std::remove_cvref_t<Array1>>, fcppt::array::is_object<std::remove_cvref_t<Arrays>>..., std::is_same< fcppt::array::value_type<std::remove_cvref_t<Array1>>, fcppt::array::value_type<std::remove_cvref_t<Arrays>>>...>) | |
fcppt::array::object< fcppt::array::value_type< std::remove_cvref_t< Array1 > >, fcppt::mpl::list::fold< fcppt::mpl::list::object< std::remove_cvref_t< Arrays >... >, fcppt::mpl::bind< fcppt::mpl::lambda< fcppt::mpl::add >, fcppt::mpl::bind< fcppt::mpl::lambda< fcppt::array::size >, fcppt::mpl::arg< 1 > >, fcppt::mpl::arg< 2 > >, fcppt::array::size< std::remove_cvref_t< Array1 > > >::value > | fcppt::array::join (Array1 &&_array1, Arrays &&..._arrays) |
Appends multiple arrays. | |
template<typename Arg1 , typename... Args> requires ( std::conjunction_v<std::is_same<std::remove_cvref_t<Arg1>, std::remove_cvref_t<Args>>...>) | |
fcppt::array::object< std::remove_cvref_t< Arg1 >, sizeof...(Args)+1U > | fcppt::array::make (Arg1 &&_arg1, Args &&..._args) |
Make an array out of a parameter pack. | |
template<typename Array , typename Function > | |
auto | fcppt::array::map (Array &&_source, Function const &_function) -> fcppt::array::object< decltype(_function(fcppt::move_if_rvalue< Array >(std::declval< fcppt::container::to_reference_type< std::remove_reference_t< Array > > >()))), fcppt::array::size< std::remove_cvref_t< Array > >::value > requires(fcppt::array::is_object< std::remove_cvref_t< Array > >::value) |
Applies a function to every element of an array and returns an array of the results. | |
template<typename Ch , typename Traits , typename Type , std::size_t Size> | |
std::basic_ostream< Ch, Traits > & | fcppt::array::operator<< (std::basic_ostream< Ch, Traits > &_stream, fcppt::array::object< Type, Size > const &_array) |
Outputs an array to a stream. | |
template<typename Source , typename NewElement > requires (std::conjunction_v< fcppt::array::is_object<std::remove_cvref_t<Source>>, std::is_same< std::remove_cvref_t<NewElement>, fcppt::array::value_type<std::remove_cvref_t<Source>>>>) | |
fcppt::array::object< fcppt::type_traits::value_type< std::remove_cvref_t< Source > >, fcppt::array::size< std::remove_cvref_t< Source > >::value+1U > | fcppt::array::push_back (Source &&_source, NewElement &&_new_element) |
Pushes a new element to the back of an array. | |
using fcppt::array::is_object = typename fcppt::array::detail::is_object<T>::type |
Tests whether a type is a array.
using fcppt::array::size = std::integral_constant<std::size_t,std::tuple_size_v<fcppt::array::impl_type<Array>>> |
Gets the size of an array.
using fcppt::array::value_type = fcppt::type_traits::value_type<Array> |
The value type of an array.
fcppt::array::object< fcppt::array::value_type< std::remove_cvref_t< Array1 > >, fcppt::array::size< std::remove_cvref_t< Array1 > >::value+ fcppt::array::size< std::remove_cvref_t< Array2 > >::value > fcppt::array::append | ( | Array1 && | _array1, |
Array2 && | _array2 ) |
Appends two arrays.
Let _array1 = [x_1, ..., x_n]
and _array2 = [y_1, ..., y_m]
. The result is [x_1, ..., x_n, y_1, ..., y_m]
.
Both arrays must have the same value type.
auto fcppt::array::apply | ( | Function const & | _function, |
Array1 && | _array1, | ||
Arrays &&... | _arrays ) -> fcppt::array::object< 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::array::size<std::remove_cvref_t<Array1>>::value> requires(std::conjunction_v< fcppt::array::is_object<std::remove_cvref_t<Array1>>, fcppt::array::is_object<std::remove_cvref_t<Arrays>>..., std::is_same< fcppt::array::size<std::remove_cvref_t<Array1>>, fcppt::array::size<std::remove_cvref_t<Arrays>>>...>) |
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.
Function | Must be a function callable as R (Array1::value_type, Arrays::value_type...) , where R is the result type. |
fcppt::optional::object< fcppt::array::object< fcppt::type_traits::value_type< std::remove_cvref_t< Source > >, Size > > fcppt::array::from_range | ( | Source && | _source | ) |
Creates an fcppt::array::object out of a range.
Source | Must be a random-access range. |
|
nodiscardconstexprnoexcept |
Returns the I'th element of a nonconst array.
|
nodiscardconstexprnoexcept |
Returns the I'th element of a const array.
|
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.
Function | Must be a function callable as Array::value_type (std::integral_constant<std::size_t, I>) . |
fcppt::array::object< fcppt::array::value_type< std::remove_cvref_t< Array1 > >, fcppt::mpl::list::fold< fcppt::mpl::list::object< std::remove_cvref_t< Arrays >... >, fcppt::mpl::bind< fcppt::mpl::lambda< fcppt::mpl::add >, fcppt::mpl::bind< fcppt::mpl::lambda< fcppt::array::size >, fcppt::mpl::arg< 1 > >, fcppt::mpl::arg< 2 > >, fcppt::array::size< std::remove_cvref_t< Array1 > > >::value > fcppt::array::join | ( | Array1 && | _array1, |
Arrays &&... | _arrays ) |
Appends multiple arrays.
Let a_1 = Array1
and Arrays = a_2, ..., a_n
. The result is equivalent to append(a_1, ..., append(a_{n-1}, a_n) ...)
.
All arrays must have the same value type.
|
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 fcppt::array::object<T,n>{a_1,...,a_n}
.
Args | A parameter pack t_1,...,t_n such that remove_cv_ref<t_1> = ... = remove_cv_ref<t_n> . |
|
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:
Function | Must be a function callable as R (Array::value_type) , where R is the result type. |
std::basic_ostream< Ch, Traits > & fcppt::array::operator<< | ( | std::basic_ostream< Ch, Traits > & | _stream, |
fcppt::array::object< Type, Size > const & | _array ) |
Outputs an array to a stream.
|
inlinenodiscard |
Compares two arrays for equality.
|
nodiscard |
Pushes a new element to the back of an array.
Pushes _new_element to the back of _source.
NewElement | Must be the same as value_type<Source> |