BitShares-Core  7.0.2
BitShares blockchain node software and command-line wallet software
Classes | Functions
fc::typelist::runtime Namespace Reference

This namespace contains some utilities that provide runtime operations on typelists. More...

Classes

struct  wrapper
 Type wrapper object allowing arbitrary types to be passed to functions as information rather than data. More...
 

Functions

template<typename... Types, typename Callable , typename = std::enable_if_t<impl::length<Types...>::value != 0>, typename Return = decltype(std::declval<Callable>()(wrapper<at<list<Types...>, 0>>()))>
Return dispatch (list< Types... >, std::size_t index, Callable c)
 Index into the typelist for a type T, and invoke the callable with an argument wrapper<T>() More...
 
template<typename List , typename Callable >
auto dispatch (List l, int64_t index, Callable c)
 
template<typename... Types, typename Callable >
void for_each (list< Types... >, Callable c)
 Invoke the provided callable with an argument wrapper<Type>() for each type in the list. More...
 

Detailed Description

This namespace contains some utilities that provide runtime operations on typelists.

Function Documentation

◆ dispatch() [1/2]

template<typename List , typename Callable >
auto fc::typelist::runtime::dispatch ( List  l,
int64_t  index,
Callable  c 
)

Definition at line 250 of file typelist.hpp.

◆ dispatch() [2/2]

template<typename... Types, typename Callable , typename = std::enable_if_t<impl::length<Types...>::value != 0>, typename Return = decltype(std::declval<Callable>()(wrapper<at<list<Types...>, 0>>()))>
Return fc::typelist::runtime::dispatch ( list< Types... >  ,
std::size_t  index,
Callable  c 
)

Index into the typelist for a type T, and invoke the callable with an argument wrapper<T>()

Parameters
indexIndex of the type in the typelist to invoke the callable with
cThe callable to invoke
Returns
The value returned by the callable
Note
The callable return type must be the same for all list elements

If index is out of bounds, throws std::out_of_range exception

Definition at line 243 of file typelist.hpp.

◆ for_each()

template<typename... Types, typename Callable >
void fc::typelist::runtime::for_each ( list< Types... >  ,
Callable  c 
)

Invoke the provided callable with an argument wrapper<Type>() for each type in the list.

Definition at line 257 of file typelist.hpp.