Autoware.Auto
autoware::common::type_traits Namespace Reference

Classes

struct  conjunction
 A class to compute a conjunction over given traits. More...
 
struct  conjunction< TraitT >
 A conjunction of another type shall derive from that type. More...
 
struct  conjunction< TraitT, TraitsTs... >
 
struct  has_type
 A trait to check if a tuple has a type. More...
 
struct  has_type< QueryT, std::tuple< HeadT, TailTs... > >
 Recursive override of the main trait. More...
 
struct  has_type< QueryT, std::tuple< QueryT, TailTs... > >
 End of recursion for the main has_type trait. Becomes a true_type when the first type in the tuple matches the query type. More...
 
struct  has_type< QueryT, std::tuple<> >
 An overload of the general trait that signifies that nothing can be found in an empty tuple. More...
 
struct  index
 Find an index of a type in a tuple. More...
 
struct  index< HeadT, std::tuple< HeadT, Tail... > >
 Specialization for a tuple that starts with the HeadT type. End of recursion. More...
 
struct  index< QueryT, std::tuple< HeadT, Tail... > >
 Specialization for a tuple with a type different to QueryT that calls the recursive step. More...
 
struct  intersect
 A trait used to intersect types stored in tuples at compile time. The resulting typedef type will hold a tuple with the intersection of the types provided in the input tuples. More...
 

Functions

template<typename T >
constexpr autoware::common::types::bool8_t COMMON_PUBLIC impossible_branch () noexcept
 A helper function to be used in static_assert to indicate an impossible branch. More...
 
template<std::size_t I = 0UL, typename Callable , typename ... TypesT>
constexpr COMMON_PUBLIC std::enable_if_t< I==sizeof...(TypesT)> visit (std::tuple< TypesT... > &, Callable) noexcept
 Visit every element in a tuple. More...
 
template<std::size_t I = 0UL, typename Callable , typename ... TypesT>
constexpr COMMON_PUBLIC std::enable_if_t< I==sizeof...(TypesT)> visit (const std::tuple< TypesT... > &, Callable) noexcept
 Same as the previous specialization but for const tuple. More...
 
template<std::size_t I = 0UL, typename Callable , typename ... TypesT>
constexpr COMMON_PUBLIC std::enable_if_t< I !=sizeof...(TypesT)> visit (std::tuple< TypesT... > &tuple, Callable callable) noexcept
 Visit every element in a tuple. More...
 
template<std::size_t I = 0UL, typename Callable , typename ... TypesT>
constexpr COMMON_PUBLIC std::enable_if_t< I !=sizeof...(TypesT)> visit (const std::tuple< TypesT... > &tuple, Callable callable) noexcept
 Same as the previous specialization but for const tuple. More...
 

Function Documentation

◆ impossible_branch()

template<typename T >
constexpr autoware::common::types::bool8_t COMMON_PUBLIC autoware::common::type_traits::impossible_branch ( )
inlineconstexprnoexcept

A helper function to be used in static_assert to indicate an impossible branch.

Typically used when a static_assert is used to guard a certain default implementation to never be executed and to show a helpful message to the user.

Template Parameters
TAny type needed to delay the compilation of this function until it is used.
Returns
A boolean that should be false for any type passed into this function.

◆ visit() [1/4]

template<std::size_t I = 0UL, typename Callable , typename ... TypesT>
constexpr COMMON_PUBLIC std::enable_if_t<I == sizeof...(TypesT)> autoware::common::type_traits::visit ( const std::tuple< TypesT... > &  ,
Callable   
)
inlineconstexprnoexcept

Same as the previous specialization but for const tuple.

◆ visit() [2/4]

template<std::size_t I = 0UL, typename Callable , typename ... TypesT>
constexpr COMMON_PUBLIC std::enable_if_t<I != sizeof...(TypesT)> autoware::common::type_traits::visit ( const std::tuple< TypesT... > &  tuple,
Callable  callable 
)
inlineconstexprnoexcept

Same as the previous specialization but for const tuple.

◆ visit() [3/4]

template<std::size_t I = 0UL, typename Callable , typename ... TypesT>
constexpr COMMON_PUBLIC std::enable_if_t<I == sizeof...(TypesT)> autoware::common::type_traits::visit ( std::tuple< TypesT... > &  ,
Callable   
)
inlineconstexprnoexcept

Visit every element in a tuple.

        This specialization indicates the end of the recursive tuple traversal.
Template Parameters
ICurrent index.
CallableCallable type, usually a lambda with one auto input parameter.
TypesTTypes in the tuple.
Returns
Does not return anything. Capture variables in a lambda to return any values.

◆ visit() [4/4]

template<std::size_t I = 0UL, typename Callable , typename ... TypesT>
constexpr COMMON_PUBLIC std::enable_if_t<I != sizeof...(TypesT)> autoware::common::type_traits::visit ( std::tuple< TypesT... > &  tuple,
Callable  callable 
)
inlineconstexprnoexcept

Visit every element in a tuple.

        This specialization is used to apply the callable to an element of a tuple and
        recursively call this function on the next one.
Parameters
tupleThe tuple instance
[in]callableA callable, usually a lambda with one auto input parameter.
Template Parameters
ICurrent index.
CallableCallable type, usually a lambda with one auto input parameter.
TypesTTypes in the tuple.
Returns
Does not return anything. Capture variables in a lambda to return any values.