Function unwrap_tuple

Synopsis

#include <src/entt/core/tuple.hpp>

template <typename Type>
constexpr decltype(auto) unwrap_tuple(Type &&value)

Description

Utility function to unwrap tuples of a single element.

Template Parameters

Type - Tuple type of any sizes.

Parameters

value - A tuple object of the given type.

Returns
The tuple itself if it contains more than one element, the first element otherwise.

Source

Lines 18-25 in src/entt/core/tuple.hpp.

template<typename Type>
constexpr decltype(auto) unwrap_tuple(Type &&value) ENTT_NOEXCEPT {
    if constexpr(std::tuple_size_v<std::remove_reference_t<Type>> == 1u) {
        return std::get<0>(std::forward<Type>(value));
    } else {
        return std::forward<Type>(value);
    }
}





Add Discussion

Log in to comment