A trivial wrapper around a std::tuple but with compatible TypeList methods. Importantly can be instatiated from a TypeList and implements a similar ::foreach interface.
More...
#include <openvdb/TypeList.h>
|
| TupleList ()=default |
|
| TupleList (Ts &&...args) |
|
constexpr auto | size () |
|
constexpr TupleT & | tuple () |
|
constexpr TupleT & | tuple () const |
|
template<size_t Idx> |
constexpr auto & | get () |
|
template<size_t Idx> |
constexpr auto & | get () const |
|
template<typename OpT > |
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. More...
|
|
template<class Pred , class OpT > |
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. More...
|
|
template<class Pred , class OpT , typename RetT > |
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. More...
|
|
template<typename... Ts>
struct openvdb::v12_0::TupleList< Ts >
A trivial wrapper around a std::tuple but with compatible TypeList methods. Importantly can be instatiated from a TypeList and implements a similar ::foreach interface.
- Warning
- Some member methods here run on actual instances of types in the list. As such, it's unlikely that they can always be resolved at compile time (unlike methods in TypeList). Compilers are notriously bad at automatically inlining recursive/nested template instations (without fine tuning inline options to the frontend) so the public API of this class is marked as force inlined. You can disable this behaviour by defining: OPENVDB_TYPELIST_NO_FORCE_INLINE before including this header. Note however that the ValueAccessor uses this API and disabling force inlining can cause significant performance degredation.
using TupleT = std::tuple<Ts...> |
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<I> 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()] = { .... }
[&](auto Idx) { return runtimeFlags[Idx]; },
[](auto value) { std::cout << value << std::endl; }
);
}
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
-
pred | Predicate to run on each index, should return true/false |
op | Function to run on the first element that satisfies pred |
def | Default return value |
Example:
{
}
{
Types::AsTupleList
tuple(
Int32(1),
float(3.3), std::string(
"foo"));
auto size =
tuple.foreach(
[](auto Idx) { return std::is_same<std::string, Types::template Get<Idx>>::value; },
[](auto value) { return value.size(); },
-1
);
}
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
-
op | Function to run on each type |
Example:
{
}
{
Types::AsTupleList
tuple(
Int32(1),
float(3.3), std::string(
"foo"));
tuple.foreach([](
auto value) { std::cout << value <<
' '; });
}
constexpr auto& get |
( |
| ) |
const |
|
inline |
constexpr TupleT& tuple |
( |
| ) |
const |
|
inline |