OpenVDB  9.0.1
Public Types | Static Public Member Functions | Static Public Attributes | List of all members
TypeList< Ts > Struct Template Reference

A list of types (not necessarily unique) More...

#include <openvdb/TypeList.h>

Public Types

using Self = TypeList
 The type of this list. More...
 
template<size_t N>
using Get = typename typelist_internal::TSGetElementImpl< Self, N >::type
 Access a particular element of this type list. If the index is out of range, typelist_internal::NullType is returned. More...
 
using Front = Get< 0 >
 
using Back = Get< Size-1 >
 
template<typename ListT = TypeList<>>
using Unique = typename typelist_internal::TSMakeUniqueImpl< ListT, Ts... >::type
 Remove any duplicate types from this TypeList by rotating the next valid type left (maintains the order of other types). Optionally combine the result with another TypeList. More...
 
template<typename... TypesToAppend>
using Append = typename typelist_internal::TSAppendImpl< Self, TypesToAppend... >::type
 Append types, or the members of another TypeList, to this list. More...
 
template<typename... TypesToRemove>
using Remove = typename typelist_internal::TSRemoveImpl< Self, TypesToRemove... >::type
 Remove all occurrences of one or more types, or the members of another TypeList, from this list. More...
 
using PopFront = typename typelist_internal::TSRemoveFirstImpl< Self >::type
 Remove the first element of this type list. Has no effect if the type list is already empty. More...
 
using PopBack = typename typelist_internal::TSRemoveLastImpl< Self >::type
 Remove the last element of this type list. Has no effect if the type list is already empty. More...
 
template<size_t First, size_t Last>
using RemoveByIndex = typename typelist_internal::TSRemoveIndicesImpl< Self, First, Last >::type
 Return a new list with types removed by their location within the list. If First is equal to Last, a single element is removed (if it exists). If First is greater than Last, the list remains unmodified. More...
 

Static Public Member Functions

template<typename OpT >
static void foreach (OpT op)
 Invoke a templated, unary functor on a value of each type in this list. More...
 

Static Public Attributes

static constexpr size_t Size = sizeof...(Ts)
 The number of types in the type list. More...
 
template<typename T >
static constexpr bool Contains = typelist_internal::TSHasTypeImpl<Self, T>::Value
 True if this list contains the given type, false otherwise. More...
 
template<typename T >
static constexpr int64_t Index = typelist_internal::TSHasTypeImpl<Self, T>::Index
 Returns the index of the first found element of the given type, -1 if no matching element exists. More...
 

Detailed Description

template<typename... Ts>
struct openvdb::v9_0::TypeList< Ts >

A list of types (not necessarily unique)

Example:

Member Typedef Documentation

using Append = typename typelist_internal::TSAppendImpl<Self, TypesToAppend...>::type

Append types, or the members of another TypeList, to this list.

Example:

{
using NumericTypes = IntTypes::Append<RealTypes>;
}
{
using NumericTypes = IntTypes::Append<float>::Append<double>;
}
using Back = Get<Size-1>
using Front = Get<0>
using Get = typename typelist_internal::TSGetElementImpl<Self, N>::type

Access a particular element of this type list. If the index is out of range, typelist_internal::NullType is returned.

using PopBack = typename typelist_internal::TSRemoveLastImpl<Self>::type

Remove the last element of this type list. Has no effect if the type list is already empty.

Example:

{
using EmptyTypes = openvdb::TypeList<>;
}
{
IntTypes::PopBack; // openvdb::TypeList<Int16, Int32>;
EmptyTypes::PopBack; // openvdb::TypeList<>;
}
using PopFront = typename typelist_internal::TSRemoveFirstImpl<Self>::type

Remove the first element of this type list. Has no effect if the type list is already empty.

Example:

{
using EmptyTypes = openvdb::TypeList<>;
}
{
IntTypes::PopFront; // openvdb::TypeList<Int32, Int64>;
EmptyTypes::PopFront; // openvdb::TypeList<>;
}
using Remove = typename typelist_internal::TSRemoveImpl<Self, TypesToRemove...>::type

Remove all occurrences of one or more types, or the members of another TypeList, from this list.

Example:

{
using ShortTypes = NumericTypes::Remove<LongTypes>; // float, Int16, Int32
}
using RemoveByIndex = typename typelist_internal::TSRemoveIndicesImpl<Self, First, Last>::type

Return a new list with types removed by their location within the list. If First is equal to Last, a single element is removed (if it exists). If First is greater than Last, the list remains unmodified.

Example:

{
}
{
using IntTypes = NumericTypes::RemoveByIndex<0,1>; // openvdb::TypeList<Int16, Int32, Int64>;
using RealTypes = NumericTypes::RemoveByIndex<2,4>; // openvdb::TypeList<float, double>;
using RemoveFloat = NumericTypes::RemoveByIndex<0,0>; // openvdb::TypeList<double, Int16, Int32, Int64>;
}
using Self = TypeList

The type of this list.

using Unique = typename typelist_internal::TSMakeUniqueImpl<ListT, Ts...>::type

Remove any duplicate types from this TypeList by rotating the next valid type left (maintains the order of other types). Optionally combine the result with another TypeList.

Example:

{
}
{
using UniqueTypes = Types::Unique<>; // <Int16, Int32, float, Int64>
}

Member Function Documentation

static void foreach ( OpT  op)
inlinestatic

Invoke a templated, unary functor on a value of each type in this list.

Example:

#include <typeinfo>
template<typename ListT>
void printTypeList()
{
std::string sep;
auto op = [&](auto x) { // C++14
std::cout << sep << typeid(decltype(x)).name(); sep = ", "; };
}
printTypeList<MyTypes>(); // "i, f, d" (exact output is compiler-dependent)
Note
The functor object is passed by value. Wrap it with std::ref to use the same object for each type.

Member Data Documentation

constexpr bool Contains = typelist_internal::TSHasTypeImpl<Self, T>::Value
static

True if this list contains the given type, false otherwise.

Example:

constexpr int64_t Index = typelist_internal::TSHasTypeImpl<Self, T>::Index
static

Returns the index of the first found element of the given type, -1 if no matching element exists.

Example:

{
}
{
const int64_t L1 = openvdb::TypeList<IntTypes>::Index<Int32>; // 1
const int64_t L2 = openvdb::TypeList<RealTypes>::Index<Int32>; // -1
}
constexpr size_t Size = sizeof...(Ts)
static

The number of types in the type list.