OpenVDB 12.0.0
 
Loading...
Searching...
No Matches
TupleList<> Struct Reference

Specilization of an empty TupleList. Required due to constructor selection. More...

#include <openvdb/TypeList.h>

Public Types

using AsTypeList = TypeList<>
 
using TupleT = std::tuple<>
 
using AsTypeList
 
using TupleT
 

Public Member Functions

 TupleList ()=default
 
constexpr auto size ()
 
TupleTtuple ()
 
const TupleTtuple () const
 
template<size_t Idx>
constexpr auto & get ()
 
template<size_t Idx>
constexpr auto & get () const
 
template<typename OpT>
constexpr void foreach (OpT)
 
template<class Pred, class OpT>
constexpr void evalFirstPred (Pred, OpT)
 
template<class Pred, class OpT, typename RetT>
constexpr RetT evalFirstPred (Pred, OpT, RetT def)
 
 TupleList ()=default
 
 TupleList (Ts &&... args)
 
constexpr auto size ()
 
constexpr TupleTtuple ()
 
constexpr TupleTtuple () const
 
constexpr auto & get ()
 
constexpr auto & get () const
 
OPENVDB_FORCE_INLINE constexpr void foreach (OpT op)
 Run a function on each type instance in the underlying std::tuple. Effectively calls op(std::get<I>(mTuple)) where I = [0,Size). Does not support returning a value.
 
OPENVDB_FORCE_INLINE void evalFirstPred (Pred pred, OpT op)
 Run a function on the first element in the underlying std::tuple that satisfies the provided predicate. Effectively calls op(std::get<I>(mTuple)) when pred(I) returns true, then exits, where I = [0,Size). Does not support returning a value.
 
OPENVDB_FORCE_INLINE RetT evalFirstPred (Pred pred, OpT op, RetT def)
 Run a function on the first element in the underlying std::tuple that satisfies the provided predicate. Effectively calls op(std::get<I>(mTuple)) when pred(I) returns true, then exits, where I = [0,Size). Supports returning a value, but a default return value must be provided.
 

Detailed Description

Specilization of an empty TupleList. Required due to constructor selection.

Member Typedef Documentation

◆ AsTypeList [1/2]

using AsTypeList

◆ AsTypeList [2/2]

using AsTypeList = TypeList<>

◆ TupleT [1/2]

using TupleT

◆ TupleT [2/2]

using TupleT = std::tuple<>

Constructor & Destructor Documentation

◆ TupleList() [1/3]

TupleList ( )
default

◆ TupleList() [2/3]

TupleList ( )
default

◆ TupleList() [3/3]

TupleList ( Ts &&... args)
inline

Member Function Documentation

◆ evalFirstPred() [1/4]

OPENVDB_FORCE_INLINE void evalFirstPred ( Pred pred,
OpT op )
inline

Run a function on the first element in the underlying std::tuple that satisfies the provided predicate. Effectively calls op(std::get<I>(mTuple)) when pred(I) returns true, then exits, where I = [0,Size). Does not support returning a value.

Note
This is mainly useful to avoid the overhead of calling std::get on every element when only a single unknown element needs processing.
Parameters
pred Predicate to run on each index, should return true/false
op Function to run on the first element that satisfies pred

Example:

{
}
{
Types::AsTupleList tuple(Int32(1), float(3.3), std::string("foo"));
bool runtimeFlags[tuple.size()] = { .... } // some runtime flags
tuple.foreach(
[&](auto Idx) { return runtimeFlags[Idx]; },
[](auto value) { std::cout << value << std::endl; }
);
}
int32_t Int32
Definition Types.h:56
TupleT & tuple()
Definition TypeList.h:963
A list of types (not necessarily unique)
Definition TypeList.h:578

◆ evalFirstPred() [2/4]

OPENVDB_FORCE_INLINE RetT evalFirstPred ( Pred pred,
OpT op,
RetT def )
inline

Run a function on the first element in the underlying std::tuple that satisfies the provided predicate. Effectively calls op(std::get<I>(mTuple)) when pred(I) returns true, then exits, where I = [0,Size). Supports returning a value, but a default return value must be provided.

Parameters
predPredicate to run on each index, should return true/false
opFunction to run on the first element that satisfies pred
defDefault return value

Example:

{
}
{
Types::AsTupleList tuple(Int32(1), float(3.3), std::string("foo"));
// returns 3
auto size = tuple.foreach(
[](auto Idx) { return std::is_same<std::string, Types::template Get<Idx>>::value; },
[](auto value) { return value.size(); },
-1
);
}
constexpr auto size()
Definition TypeList.h:962

◆ evalFirstPred() [3/4]

template<class Pred, class OpT>
void evalFirstPred ( Pred ,
OpT  )
inlineconstexpr

◆ evalFirstPred() [4/4]

template<class Pred, class OpT, typename RetT>
RetT evalFirstPred ( Pred ,
OpT ,
RetT def )
inlineconstexpr

◆ foreach() [1/2]

OPENVDB_FORCE_INLINE constexpr void foreach ( OpT op)
inlineconstexpr

Run a function on each type instance in the underlying std::tuple. Effectively calls op(std::get<I>(mTuple)) where I = [0,Size). Does not support returning a value.

Parameters
opFunction to run on each type

Example:

{
}
{
Types::AsTupleList tuple(Int32(1), float(3.3), std::string("foo"));
tuple.foreach([](auto value) { std::cout << value << ' '; }); // prints '1 3.3 foo'
}

◆ foreach() [2/2]

template<typename OpT>
void foreach ( OpT )
inlineconstexpr

◆ get() [1/4]

auto & get ( )
inlineconstexpr

◆ get() [2/4]

template<size_t Idx>
auto & get ( )
inlineconstexpr

◆ get() [3/4]

auto & get ( ) const
inlineconstexpr

◆ get() [4/4]

template<size_t Idx>
auto & get ( ) const
inlineconstexpr

◆ size() [1/2]

auto size ( )
inlineconstexpr

◆ size() [2/2]

auto size ( )
inlineconstexpr

◆ tuple() [1/4]

TupleT & tuple ( )
inlineconstexpr

◆ tuple() [2/4]

TupleT & tuple ( )
inline

◆ tuple() [3/4]

TupleT & tuple ( ) const
inlineconstexpr

◆ tuple() [4/4]

const TupleT & tuple ( ) const
inline