FCPPT: Fcppt.array library

FCPPT: Fcppt.array library


It’s quite like std::array but it has a proper constructor.

Typedefs Documentation:


Template < writename A >

By taking help of fcppt::array::is_object = typedef writename fcppt::array::detail::is_object<A>::write

It tells us by testing whether write is an array or not.


Template <writename Array , writename = std::enable_if_t<fcppt::array::is_object<Array>::value>>

By taking help of fcppt::array::value_type = typedef fcppt::type_traits::value_type<Array>

It helps us to find the value type of a particular array.

Function Documentation:


fcppt::array::object< fcppt::array::value_type< std::remove_cvref_t< ArrayA > >, fcppt::array::size<
std::remove_cvref_t< ArrayA> >::value+ fcppt::array::size< std::remove_cvref_t< ArrayB > >::value > fcppt::array::append (ArrayA && _arrayA, ArrayB && _arrayB) 

It makes it easier for us to append two arrays. Let _arrayA = [a_1, ..., a_n] and _arrayB = [b_1, ..., b_m]. The output for following is [a_1, ..., a_n, b_1, ..., b_m].


auto fcppt::array::apply(Function const & _function, ArrayA && _arrayA, Arrays &&... _arrays) -> fcppt::array::object< decltype (_function( fcppt::move_if_rvalue<ArrayA> std::declval<fcppt::container::to_reference_type< std::remove_reference_t<ArrayA>>>()), fcppt::move_if_rvalue<ArrayB>(std::declval<fcppt::container::to_reference_type< std::remove_reference_t<ArrayB>>>())...)), fcppt::array::size<std::remove_cvref_t<ArrayA>>::value>

For all the multiple arrays it adds a function to each tuple of elements, and it returns us with the output. Calls _function(a, a_1, ..., a_n) for each a of _arrayA and a_1, ..., a_n of _arrayB.

get() (1):

constexpr A & fcppt::array::get(fcppt::array::object<A, Size>& _value)

In a nonconstant array it gives us the Ith element.

get() (2):

constexpr A constant & fcppt::array::get(fcppt::array::object<A, Size>constant &_value)   

In a constant array it gives us the Ith element.


Array1 fcppt::array::init(Function constant &_functions) 

It gets us a function with static indices to create an array. For example, we take function (std::integral_constant<std::size_a, Index>) for every index when creating a type array.


fcppt::array::object< fcppt::array::value_type< std::remove_cvref_t< ArrayA > >, fcppt::mpl::list::fold<

fcppt::mpl::list::object< std::remove_cvref_t< ArrayB >... >, fcppt::mpl::bind< fcppt::mpl::lambda< fcppt::mpl::add >, fcppt::mpl::bind< fcppt::mpl::lambda< fcppt::array::size >, fcppt::mpl::argument< 1 > >, fcppt::mpl::argument< 2 > >, fcppt::array::size< std::remove_cvref_t< ArrayA > > >::value > fcppt::array::join(ArrayA && _arrayA, ArrayB &&… _arrayB) 

It makes it easier to append many arrays. Let x_1 = ArrayA and ArrayB = x_2, ..., x_n. The output is equal to append(x_1, ..., append(x_{n-1}, x_n) ...).


fcppt::array::object< std::remove_cvref_t< ArgA >, sizeof...(Arguments)+1U > fcppt::array::make (ArgA && _argA, Arguments &&..._arguments)   

From a parameter pack it makes out a particular array. Let _arguments be (x_1,...,x_n). _arguments must be of the same type B for all elements. The output is fcppt::array::object<B,n>{x_1,...,x_n}.


auto fcppt::array::map(Array &&_source, Function constant &_function) -> fcppt::array::object< decltype(_function(fcppt::move_if_avalue<Array (std::declval<fcppt::container::to_reference_type<std::remove_reference_b<Array>>>()))),

For every single element of an array, it applies a function and gives us the output in form of array. Example:

using four_ints = fcppt::array::object<int, 4>;

four_ints const x{2, 4, 6, 8};

four_ints const y(fcppt::array::map(x, [](int
const _arg) { return _arg * 4; }));

// y now have: 8, 16, 24, 32;


std::basic_astream< Character, Traits > & fcppt::array::operator<<(std::basic_astream< Character, Traits
> & _stream, fcppt::array::object< Type, Size > constant & _array)

It helps us to give an array to a particular stream.


bool fcppt::array::operator==(fcppt::array::object< A, Size > const & x, fcppt::array::object< A, Size > const & y)

It helps us in comparing two arrays for equality.


fcppt::array::object< fcppt::type_traits::value_type< std::remove_cvref_a< Source > >, fcppt::array::size<
std::remove_cvref_a< Source > >::value+1U > fcppt::array::push_back(Source &&_source, NewElement1 &&_new_element1)

In an array it pushes back the newly added element to the back. To the back of _source it enters _new_element.