13#ifndef __AUDACITY_TYPELIST__
14#define __AUDACITY_TYPELIST__
64 static constexpr size_t length = 0;
65 static constexpr bool null =
true;
69 static constexpr size_t length =
sizeof...(Types);
70 static constexpr bool null =
false;
77template<
typename TypeList>
struct Null;
80 : std::bool_constant<sizeof...(Types) == 0> {};
82template<
typename TypeList>
struct Length;
86 : std::integral_constant<size_t, sizeof...(Types)>{};
89template<
typename TypeList>
struct Head;
101template<
typename TypeList>
struct Tail;
116template<
size_t N,
typename TypeList>
struct Nth {
127template<
size_t N,
typename TypeList>
using Nth_t =
140template<
typename Type,
typename TypeList>
struct Cons;
141template<
typename Type,
typename TypeList>
using Cons_t =
148template<
typename TypeList,
typename Type>
struct PushFront
149 :
Cons<Type, TypeList> {};
154template<
typename TypeList,
typename Type>
struct PushBack;
157template<
typename Type,
typename...
Types>
struct
168 using type =
typename std::conditional_t<
177template<
typename TypeList>
struct Tails {
182template<
typename TypeList>
struct Last;
192template<
typename Type,
typename...
Types>
199template<
template<
typename>
class... Template>
struct Fn;
200template<>
struct Fn<> {
template<
typename T>
using typemap = T; };
201template<
template<
typename>
class Template,
202 template<
typename>
class... Templates>
203struct Fn<Template, Templates...> {
205 Template<
typename Fn<Templates...>::template
typemap<T>>;
210template<
typename... Metafunctions>
struct Compose;
212template<
typename Metafunction,
typename... Metafunctions>
213struct Compose<Metafunction, Metafunctions...> {
221template<
template<
typename,
typename>
class BinaryTemplate,
typename First>
223 template<
typename T>
using typemap = BinaryTemplate<First, T>;
227template<
template<
typename,
typename>
class BinaryTemplate,
typename Second>
229 template<
typename T>
using typemap = BinaryTemplate<T, Second>;
233template<
template<
typename...>
class Template,
typename TypeList>
struct Apply;
234template<
template<
typename...>
class Template,
typename TypeList>
236template<
template<
typename...>
class Template,
typename...
Types>
240template<
typename TupleLike>
struct Bind {
242 template<
typename>
struct Impl;
243 template<
size_t...
Is>
struct Impl<
std::index_sequence<Is...>> {
246 enum :
size_t {
size = std::tuple_size_v<TupleLike> };
253template<
typename Metafunction,
typename TypeList>
struct Map {
261template<
typename Metafunction,
typename TypeList>
using Map_t =
266template<
typename Metafunction,
typename TypeList>
struct MapList {
269template<
typename Metafunction,
typename TypeList>
using MapList_t
272template<
typename... Lists>
struct Append;
275template<
typename TypeList,
typename... TypeLists>
278 template<
typename... FirstTypes>
struct CaptureFirst {
279 template<
typename... RestTypes>
struct CaptureRest {
289template<
template<
typename Type,
typename Accumulator>
class Op,
297 template<
typename Acc,
typename T,
typename... Ts>
306template<
template<
typename Type,
typename Accumulator>
class Op,
312template<
template<
typename Prefix,
typename Accumulator>
class Op,
317 template<
typename T,
typename Pair>
struct Op1 {
321 template<
typename T,
typename Pair>
using Op1_t =
326template<
template<
typename Prefix,
typename Accumulator>
class Op,
332template<
template<
typename Type,
typename Accumulator>
class Op,
344template<
template<
typename Type,
typename Accumulator>
class Op,
350template<
template<
typename Tail,
typename Accumulator>
class Op,
356 using type = Op<TL, typename Accumulate<Acc, Tail_t<TL>>
::type>;
362template<
template<
typename Tail,
typename Accumulator>
class Op,
371template<
typename Predicate,
typename T>
struct Call {
372 using type =
typename Predicate::template typemap<T>;
374template<
typename Predicate,
typename T>
using Call_t =
379 std::conditional_t<Const, Fn<std::add_const_t>,
Identity>;
382template<
bool Const,
typename TypeList>
using MapConst =
383 std::conditional_t<Const,
392template<
typename Predicate,
typename T>
using Is_t =
394template<
typename Predicate,
typename T>
static constexpr bool Is_v =
402template<
typename... Predicates>
struct Or;
403template<>
struct Or<> {
404 template<
typename T>
using typemap = std::false_type;
406template<
typename Predicate,
typename... Predicates>
407struct Or<Predicate, Predicates...> {
409 template<
typename T>
struct Rest {
410 static constexpr bool value =
Is_v<
Or<Predicates...>, T>;
413 template<
typename T>
using typemap =
typename std::disjunction<
421template<
typename... Predicates>
struct And;
423 template<
typename T>
using typemap = std::true_type;
425template<
typename Predicate,
typename... Predicates>
426struct And<Predicate, Predicates...> {
428 template<
typename T>
struct Rest {
429 static constexpr bool value =
Is_v<
And<Predicates...>, T>;
432 template<
typename T>
using typemap =
typename std::conjunction<
439template<
typename Predicate,
typename TypeList>
struct Every
440 :
Apply_t<std::conjunction, Map_t<Predicate, TypeList>> {};
442template<
typename Predicate,
typename TypeList>
constexpr auto Every_v =
447template<
typename Predicate,
typename TypeList>
struct Some
448 :
Apply_t<std::disjunction, Map_t<Predicate, TypeList>> {};
450template<
typename Predicate,
typename TypeList>
constexpr auto Some_v =
456template<
typename Predicate,
typename TypeList>
struct NotEvery
457 :
Some<Not<Predicate>, TypeList> {};
459template<
typename Predicate,
typename TypeList>
constexpr auto NotEvery_v =
465template<
typename Predicate,
typename TypeList>
struct NotAny
466 :
Every<Not<Predicate>, TypeList> {};
468template<
typename Predicate,
typename TypeList>
constexpr auto NotAny_v =
473template<
typename Item,
typename TypeList>
struct In
474 :
Some<Bind1st<std::is_same, Item>, TypeList> {};
475template<
typename Item,
typename TypeList>
constexpr auto In_v =
479template<
typename Item,
typename TypeList>
struct HasBaseIn
480 :
Some<Bind2nd<std::is_base_of, Item>, TypeList> {};
481template<
typename Item,
typename TypeList>
constexpr auto HasBaseIn_v =
488 template<
typename Type,
typename Acc>
using Op = std::conditional_t<
489 Is_v<Predicate, Type>,
500template<
typename Predicate,
typename TypeList>
struct Filter {
503template<
typename Predicate,
typename TypeList>
using Filter_t =
std::vector< Type > Types
Utilities for compile-time type manipulation. Some terminology as in Lisp.
static constexpr bool Is_v
typename RightFold< Op, TypeList, Initial >::type RightFold_t
std::conditional_t< Const, Fn< std::add_const_t >, Identity > MaybeConst
Conditionally add const to a type.
constexpr auto HasBaseIn_v
typename NonEmptyTails< TypeList >::type NonEmptyTails_t
constexpr auto NotEvery_v
The constant value in the corresponding type.
typename Bind< TupleLike >::type Bind_t
typename Tails< TypeList >::type Tails_t
typename PushFront< TypeList, Type >::type PushFront_t
typename Second< TypeList >::type Second_t
typename Is< Predicate, T >::type Is_t
constexpr auto NotAny_v
The constant value in the corresponding type.
typename LeftFoldList< Op, TypeList, Initial >::type LeftFoldList_t
typename LeftFold< Op, TypeList, Initial >::type LeftFold_t
Tail_t< TypeList > Rest_t
typename StablePartition< Predicate, TypeList >::type StablePartition_t
typename Tail< TypeList >::type Tail_t
typename Length< TypeList >::type Length_t
constexpr auto Every_v
The constant value in the corresponding type.
typename Last< TypeList >::type Last_t
typename Filter< Predicate, TypeList >::type Filter_t
typename ButLast< TypeList >::type ButLast_t
typename Reverse< TypeList >::type Reverse_t
typename Call< Predicate, T >::type Call_t
typename Apply< Template, TypeList >::type Apply_t
typename PushBack< TypeList, Type >::type PushBack_t
typename Map< Metafunction, TypeList >::type Map_t
std::conditional_t< Const, Map< Fn< std::add_const_t >, TypeList >, type_identity< TypeList > > MapConst
Conditionally map const over a type list.
typename MapList< Metafunction, TypeList >::type MapList_t
typename MapConst< Const, TypeList >::type MapConst_t
typename Cons< Type, TypeList >::type Cons_t
typename Head< TypeList >::type Head_t
constexpr auto Some_v
The constant value in the corresponding type.
typename RightFoldList< Op, TypeList, Initial >::type RightFoldList_t
typename Append< Lists... >::type Append_t
typename Nth< N, TypeList >::type Nth_t
typename First< TypeList >::type First_t
double Accumulate(const TrackList &list, double(Track::*memfn)() const, double ident, const double &(*combine)(const double &, const double &))
typename std::conjunction< typename Predicate::template typemap< T >, Rest< T > > typemap
typename Apply_t< CaptureRest, Append_t< TypeLists... > >::type type
typename Apply_t< CaptureFirst, TypeList >::type type
Template< Types... > type
Bind the types in TypeList to the parameters of a variadic Template.
Given a binary template and a fixed argument, make a metafunction.
BinaryTemplate< First, T > typemap
Given a binary template and a fixed argument, make a metafunction.
BinaryTemplate< T, Second > typemap
Destructure any tuple-like type into a TypeList.
typename Impl< std::make_index_sequence< size > >::type type
Cons_t< Type, ButLast_t< List< Types... > > > type
Apply a metafunction to a type.
typename Predicate::template typemap< T > type
Build a type list from a type and another type list.
Select only the subsequence of the type list satisfying the predicate.
First_t< StablePartition_t< Predicate, TypeList > > type
Template< typename Fn< Templates... >::template typemap< T > > typemap
Whether the given type is derived from any member of the list.
typename List< Types... >::head type
Delays expansion of nested alias head; so Head<Nil> is legal.
Last_t< List< Types... > > type
typename Accumulate< Op< T, Acc >, Ts... >::type type
typename Accumulate< Initial, Types... >::type type
Left fold reduction of a list of types by a binary template.
typename Apply_t< Impl, TypeList >::type type
PushBack_t< Second_t< Pair >, T > NewPrefix
Like LeftFold, but passing nonempty prefixes, not elements, to Op.
typename Op1< T, Pair >::type Op1_t
First_t< LeftFold_t< Op1_t, TypeList, List< Initial, Nil > > > type
Non-empty specialization also defines first and rest.
Primary template for a list of arbitrary types.
Transform a list of types by the given metafunction.
typename Apply_t< Impl, TypeList >::type type
Map_t< Metafunction, NonEmptyTails_t< TypeList > > type
Cons_t< TypeList, typename NonEmptyTails< Tail_t< TypeList > >::type > type
typename std::conditional_t< Null_v< TypeList >, type_identity< Nil >, Next >::type type
typename Countdown< I - 1, Tail_t< TL > >::type type
typename Countdown< N, TypeList >::type type
typename std::disjunction< typename Predicate::template typemap< T >, Rest< T > > typemap
PushBack – no Common Lisp equivalent name.
An alternative more suggestive of C++ than Lisp conventions.
Op< Head_t< TL >, typename Accumulate< Acc, Tail_t< TL > >::type > type
Right fold reduction of a list of types by a binary template.
typename Accumulate< Initial, TypeList >::type type
Op< TL, typename Accumulate< Acc, Tail_t< TL > >::type > type
Like RightFold, but passing nonempty tails, not elements, to Op.
typename Accumulate< Initial, TypeList >::type type
RightFold_t< Op, TypeList, List< Nil, Nil > > type
std::conditional_t< Is_v< Predicate, Type >, List< Cons_t< Type, First_t< Acc > >, Second_t< Acc > >, List< First_t< Acc >, Cons_t< Type, Second_t< Acc > > > > Op
typename List< Types... >::tail type
Delays expansion of nested alias rest; so Tail<Nil> is legal.
PushBack_t< NonEmptyTails_t< TypeList >, Nil > type
standard in C++20; add a level of indirection to a type