BitShares-Core
7.0.2
BitShares blockchain node software and command-line wallet software
|
Go to the documentation of this file.
17 template<
typename...>
struct list;
22 template<
typename,
template<
typename...>
class>
struct apply;
23 template<
typename... Ts,
template<
typename...>
class Delegate>
26 template<
typename... Ts>
28 template<>
struct length<> { constexpr
static std::size_t value = 0; };
29 template<
typename T,
typename... Ts>
30 struct length<T, Ts...> { constexpr
static std::size_t value =
length<Ts...>::value+1; };
33 template<
typename... OldTypes,
typename... NewTypes>
37 template<
typename... OldTypes,
typename... NewTypes,
typename NextList,
typename... Lists>
45 template<std::
size_t count>
48 list<std::integral_constant<std::size_t, count-1>>>
::type;
52 template<
typename... List,
typename Transformer>
57 template<
typename Search,
typename List>
struct index_of;
58 template<
typename Search>
struct index_of<Search,
list<>> { constexpr
static int value = -1; };
59 template<
typename Search,
typename T,
typename... Ts>
61 constexpr
static int deeper =
index_of<Search,
list<Ts...>>::value;
62 constexpr
static int value = std::is_same<Search, T>::value? 0 : (deeper == -1? -1 : deeper + 1);
66 template<
typename... Uniques>
70 template<
typename... Uniques,
typename T>
75 template<
typename... Uniques,
typename T1,
typename T2,
typename... Types>
80 template<
typename... Uniques,
typename... Lists>
84 template<
typename Uniques,
typename L1a,
typename... L1s,
typename L2,
typename... Lists>
89 template<
typename, std::
size_t>
struct at;
90 template<
typename T,
typename... Types>
92 template<
typename T,
typename... Types, std::size_t
index>
95 template<
typename,
typename, std::
size_t>
struct remove_at;
96 template<
typename... Left,
typename T,
typename... Right>
98 template<
typename... Left,
typename T,
typename... Right, std::size_t
index>
103 template<
template<
typename>
class Filter,
typename Filtered,
typename List>
struct filter;
104 template<
template<
typename>
class Filter,
typename... Filtered>
106 template<
template<
typename>
class Filter,
typename... Filtered,
typename T1,
typename... Types>
108 using type =
typename std::conditional_t<Filter<T1>::value,
113 template<
typename,
typename, std::
size_t, std::
size_t,
typename =
void>
struct slice;
114 template<
typename... Results,
typename... Types, std::size_t
index>
116 template<
typename... Results,
typename T,
typename... Types, std::size_t end>
118 :
slice<list<Results..., T>, list<Types...>, 0, end-1> {};
119 template<
typename T,
typename... Types, std::size_t start, std::size_t end>
121 :
slice<list<>, list<Types...>, start-1, end-1> {};
123 template<
typename,
typename>
struct zip;
126 template<
typename A,
typename... As,
typename B,
typename... Bs>
131 template<
typename Callable,
typename Ret,
typename T>
137 template<
typename... Types>
141 template<
typename List,
template<
typename...>
class Delegate>
145 template<
typename List>
149 template<
typename... Lists>
153 template<std::
size_t count>
160 template<
typename List = list<>>
169 template<
typename List,
typename Transformer>
173 template<
typename List,
typename T>
177 template<
typename List,
typename T>
178 constexpr
static bool contains() {
return impl::index_of<T, List>::value != -1; }
181 template<
typename... TypeLists>
185 template<
typename List, std::
size_t index>
189 template<
typename List>
192 template<
typename List>
196 template<
typename List, std::
size_t index>
200 template<
typename List,
typename Remove>
204 template<
typename List,
template<
typename>
class Filter>
208 template<
template<
typename>
class Filter>
211 struct type { constexpr
static bool value = !Filter<T>::value; };
215 template<typename List, std::size_t start, std::size_t end = length<List>()>
219 template<
typename ListA,
typename ListB>
224 template<
typename List>
241 template<
typename... Types,
typename Callable,
typename = std::enable_if_t<
impl::length<Types...>::value != 0>,
244 static std::function<Return(Callable&)> call_table[] =
245 { impl::dispatch_helper<Callable, Return, wrapper<Types>>... };
247 throw std::out_of_range(
"Invalid index to fc::typelist::runtime::dispatch()");
249 template<
typename List,
typename Callable>
251 if (
index < 0)
throw std::out_of_range(
"Negative index to fc::typelist::runtime::dispatch()");
256 template<
typename... Types,
typename Callable>
258 bool trues[] = { [](Callable& c,
auto t) { c(t);
return true; }(c,
wrapper<Types>())... };
std::conditional_t< index_of< T, list< Uniques... > >::value >=0, list< Uniques... >, list< Uniques..., T > > type
typename impl::apply< List, Delegate >::type apply
Apply a list of types as arguments to another template.
typename impl::at< List, index >::type at
Get the type at the specified list index.
typename impl::slice< list<>, List, start, end >::type slice
Take the sublist at indexes [start, end)
typename impl::concat_unique< list<>, TypeLists... >::type concat_unique
Remove duplicate items from one or more typelists and concatenate them all together.
constexpr static bool value
at< List, 0 > first
Get the type at the beginning of the list.
typename concat_unique< typename concat_unique< Uniques, list< L1a, L1s... > >::type, L2, Lists... >::type type
typename impl::make_sequence< count >::type make_sequence
Create a list of sequential integers ranging from [0, count)
typename impl::remove_at< list<>, List, index >::type remove_at
Get the list with the element at the given index removed.
typename concat< typename make_sequence< count-1 >::type, list< std::integral_constant< std::size_t, count-1 > >>::type type
Ret dispatch_helper(Callable &c)
typename impl::concat< Lists... >::type concat
Concatenate two or more typelists together.
This namespace contains the list type, and all of the operations and queries which can be performed u...
typename concat< list< OldTypes..., NewTypes... >, NextList, Lists... >::type type
Template to invert a filter, i.e. filter<mylist, filter_inverter<myfilter>::type>
typename builder< typename impl::concat< List, list< NewType > >::type >::type add
remove_at< List, index_of< List, Remove >()> remove_element
Get the list with the given type removed.
at< List, length< List >() -1 > last
Get the type at the end of the list.
typename impl::transform< List, Transformer >::type transform
Transform elements of a typelist.
typename concat< list< list< A, B > >, typename zip< list< As... >, list< Bs... > >::type >::type type
typename concat_unique< list< Uniques... >, Lists... >::type type
Type wrapper object allowing arbitrary types to be passed to functions as information rather than dat...
typename concat_unique< typename concat_unique< list< Uniques... >, list< T1 > >::type, list< T2, Types... > >::type type
typename impl::zip< ListA, ListB >::type zip
Zip two equal-length typelists together, i.e. zip<list<X, Y>, list<A, B>> == list<list<X,...
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>()
typename remove_at< list< Left..., T >, list< Right... >, index-1 >::type type
typename impl::filter< Filter, list<>, List >::type filter
Get a list with all elements that do not pass a filter removed.
typename std::conditional_t< Filter< T1 >::value, filter< Filter, list< Filtered..., T1 >, list< Types... > >, filter< Filter, list< Filtered... >, list< Types... > >>::type type
typename builder< typename impl::concat< List, NewList >::type >::type add_list
void for_each(list< Types... >, Callable c)
Invoke the provided callable with an argument wrapper<Type>() for each type in the list.
typename impl::zip< typename impl::make_sequence< length< List >()>::type, List >::type index