Construction

From Other Tuples

template<typename X, typename ...Xs>
auto core::tp::cons(X x, const std::tuple<Xs...> &t)

Create a new tuple by prepending element x to tuple t.

Template Parameters:
  • X – The type of the element to prepend.

  • Xs – The types in the tuple t.

Returns:

A new tuple with x prepended to t.

template<typename X, typename ...Xs>
auto core::tp::append(const std::tuple<Xs...> &t, X x)

Create a new tuple by appending element x to tuple t.

Template Parameters:
  • X – The type of the element to append.

  • Xs – The types in the tuple t.

Returns:

A new tuple with x appended to t.

From Containers

template<typename T, std::size_t N>
constexpr auto core::tp::from_array(std::array<T, N> &array)

Create a new tuple from the given array.

Template Parameters:
  • T – The array element type.

  • N – The size of the array.

Returns:

A new tuple with the elements from the given array.

template<std::size_t N, class C>
constexpr auto core::tp::from_container(const C &c)

Create a new tuple from the given container c.

The template parameter N must be supplied by the caller because it cannot, in general, be inferred from the container at compile time. Also, the container C must have an indexing operator[].

Template Parameters:
  • N – The size of the container.

  • T – The container element type.

Returns:

A new tuple with the elements from container c.

template<typename T, std::size_t N>
constexpr auto core::tp::from_vector(std::vector<T> &vec)

Create a new tuple from the given vector vec.

The template parameter N must be supplied by the caller because it cannot be inferred from the vector at compile time.

Template Parameters:
  • T – The vector element type.

  • N – The size of the container.

Returns:

A new tuple with the elements from vector vec.

From Strings

template<typename T, std::size_t N = mp::size_v<T>>
mp::rename_t<T, std::tuple> core::tp::parse(const std::vector<std::string_view> &vec)

Create a new tuple by parsing the given string_view’s according to the type of the coresponding tuple element.

This function requires the cxx_core_string library to be installed in order to parse the individual elements.

Template Parameters:
  • T – The type of tuple to create.

  • N – The tuple arity.

Tuple Types

template<class T, size_t N>
using core::tp::generate_t = core::mp::rename_t<core::mp::generate_t<T, N>, std::tuple>

Evaluates to type std::tuple with N elements of type T.

Template Parameters:
  • T – The type of each typle element.

  • N – The number of tuple elements.