Querying

template<typename ...Ts>
auto core::tp::all(std::tuple<Ts...> const &tuple)

True if all tuple elements are true; otherwise, false.

Parameters:

tuple – The source tuple.

Template Parameters:

Ts – The types of the tuple elements. Must be bool convertible.

Returns:

True if all tuple elements are true; otherwise, false.

template<typename ...Ts>
auto core::tp::any(std::tuple<Ts...> const &tuple)

True if any tuple elements are true; otherwise, false.

Parameters:

tuple – The source tuple.

Template Parameters:

Ts – The types of the tuple elements. Must be bool convertible.

Returns:

True if any tuple elements are true; otherwise, false.

template<typename T>
auto core::tp::car(const T &t)

The first tuple element.

Template Parameters:

T – The tuple type.

Returns:

The first tuple element.

template<typename T, typename R = typename impl::range<1, std::tuple_size<T>::value>::type>
auto core::tp::cdr(const T &t)

All but the first tuple element.

Template Parameters:

T – The typle type.

Returns:

A new tuple with all but the first tuple element from the given tuple.

template<typename T, typename ...Ts>
auto core::tp::max(std::tuple<T, Ts...> const &tuple)

The maximum tuple element.

Template Parameters:
  • T – The type of the first tuple element.

  • Ts – The types of the remaining tuple elements.

Returns:

The maximum tuple element.

template<typename T, typename ...Ts>
auto core::tp::min(std::tuple<T, Ts...> const &tuple)

The minimum tuple element.

Template Parameters:
  • T – The type of the first tuple element.

  • Ts – The types of the remaining tuple elements.

Returns:

The minimum tuple element.

template<typename ...Ts>
auto core::tp::none(std::tuple<Ts...> const &tuple)

True if none of the tuple elements are true; otherwise, false.

Parameters:

tuple – The source tuple.

Template Parameters:

Ts – The types of the tuple elemetns. Must be bool convertible.

Returns:

True if none of the tuple elements are true; otherwise, false.

template<typename ...Ts>
void core::tp::print(std::ostream &os, std::tuple<Ts...> const &tup, std::string const &sep = ",")

Print each element of the given tuple.

Template Parameters:

Ts – The types of the tuple elements.

template<typename T, size_t... N>
auto core::tp::select(const T &t, impl::sequence<N...>)

A selection of tuple elements

Template Parameters:
  • T – The tuple type.

  • N – The tuple indices to return.

Returns:

A new tuple containing the tuple elements enumerated by N.

template<class T, size_t I = 0>
auto &core::tp::select_nth(T &tup, size_t idx)

The nth tuple element.

Template Parameters:
  • T – The tuple type.

  • I – The tuple index to return.

Returns:

The nth tuple element.

template<size_t I = 0, class Tuple, class Predicate>
std::ptrdiff_t core::tp::find_first(const Tuple &tup, Predicate predicate)

Find the first tuple element that satisfies the given predicate.

Template Parameters:
  • I – The starting tuple index

  • Tuple – The tuple type.

  • Predicate – The predicate type.

Returns:

The index of the first tuple element that satisfies predicate, or -1.