std::tuple extensions

BBM heavily relies on std::tuple, and for your convenience some additional extensions to the stl library are included:

  1. Create a tuple from other types that support std::get:

    template<typename T>
    inline auto bbm::to_tuple(T &&t)

    Create a tuple from any other type that supports std::get.

  2. Get a subset of a tuple:

    template<size_t START, size_t COUNT, typename TUP>
    inline constexpr auto bbm::subtuple(TUP &&tup)

    subtuple

    Template Parameters:
    • START – = start index of elements to include in the new tuple

    • COUNT – = number of elements to include

  3. Handling creating tuples to references, and removing references:

    template<typename ...ARGS>
    inline constexpr auto bbm::make_ref_tuple(ARGS&&... args)

    Make a tuple of references.

    Returns std::tuple<ARGS…>, and therefore this method differs from:

    • std::make_tuple which returns a std::tuple<std::decay_t<ARGS>…>

    • std::forward_as_tuple which returns a std::tuple<ARGS&&…>

    template<typename ...ARGS>
    inline constexpr auto bbm::value_copy_tuple(const std::tuple<ARGS...> &tup)

    Value-copy a tuple.

    For example std::tuple<int&, int> will be converted to std::tuple<int, int>

    Parameters:

    tup – = tuple, possibly with references

    Returns:

    a copy of the tuple without references.

  4. Flatten recursive tuples:

    template<typename T>
    inline constexpr auto bbm::tuple_flatten(T &&t)

    Recursively flatten a tuple.

    The resulting tuple is the concatenation of all elements of child tuples.

  5. Adding and removing const to tuple types:

    template<typename T>
    inline constexpr auto bbm::tuple_add_const(T &&t)

    tuple_add_const to each element

    template<typename T>
    inline constexpr auto bbm::tuple_remove_const(T &&t)

    tuple_remove_const from each element

BBM also includes a few As well as additional type-traits:

template<typename T>
using bbm::to_tuple_t = decltype(to_tuple(std::declval<T>()))

type of converting a type that supports std::get to a tuple

template<typename ...Ts>
using bbm::tuple_cat_t = decltype(std::tuple_cat(std::declval<Ts>()...))

tuple_cat_t

Returns the type of std::tuple_cat

template<size_t START, size_t COUNT, typename TUP>
using bbm::subtuple_t = decltype(subtuple<START, COUNT>(std::declval<TUP>()))

subtuple type

template<typename T>
using bbm::tuple_flatten_t = decltype(tuple_flatten(std::declval<std::decay_t<T>>()))

flattened tuple type

template<typename T>
using bbm::tuple_add_const_t = decltype(tuple_add_const(std::declval<std::decay_t<T>>()))

tuple_add_const type

template<typename T>
using bbm::tuple_remove_const_t = decltype(tuple_remove_const(std::declval<std::decay_t<T>>()))

tuple_remove_const type

And finally, BBM support ostream forwarding of std::tuple.