From e24f25ada7e8f48dc35cb235e045a4324bccb4f2 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 14 Feb 2015 10:43:49 +0100 Subject: Introduced `Eval` function evaluation helper * replaces `typename *::type` constructs with `Eval` applications * aims to further unify function evaluation --- src/list/cons.h | 4 ++-- src/list/generator/higher/list_tabulate.h | 2 +- src/list/generator/iota.h | 10 +++++----- src/list/generator/make_list.h | 10 +++++----- src/list/list.h | 16 ++++++++-------- src/list/operation/append.h | 8 ++++---- src/list/operation/basic.h | 4 ++-- src/list/operation/delete_nth.h | 4 ++-- src/list/operation/drop.h | 4 ++-- src/list/operation/higher/drop_while.h | 8 ++++---- src/list/operation/higher/filter.h | 8 ++++---- src/list/operation/higher/find.h | 8 ++++---- src/list/operation/higher/fold.h | 6 +++--- src/list/operation/higher/map.h | 4 ++-- src/list/operation/higher/partition.h | 4 ++-- src/list/operation/higher/query.h | 8 ++++---- src/list/operation/higher/sort.h | 28 ++++++++++++++-------------- src/list/operation/higher/take_while.h | 12 ++++++------ src/list/operation/nth.h | 10 +++++----- src/list/operation/reverse.h | 14 ++++++-------- src/list/operation/take.h | 8 ++++---- 21 files changed, 89 insertions(+), 91 deletions(-) (limited to 'src/list') diff --git a/src/list/cons.h b/src/list/cons.h index 7f54eb5..8efca67 100644 --- a/src/list/cons.h +++ b/src/list/cons.h @@ -16,7 +16,7 @@ struct Cons { template struct Car { static_assert( - IsPair::type::value, + Eval>::value, "Pair type required" ); @@ -26,7 +26,7 @@ struct Car { template struct Cdr { static_assert( - IsPair::type::value, + Eval>::value, "Pair type required" ); diff --git a/src/list/generator/higher/list_tabulate.h b/src/list/generator/higher/list_tabulate.h index dd2914a..856ed11 100644 --- a/src/list/generator/higher/list_tabulate.h +++ b/src/list/generator/higher/list_tabulate.h @@ -12,7 +12,7 @@ template < > using ListTabulate = Map< Initializer, - typename Iota, Size<1>>::type + Eval, Size<1>>> >; } diff --git a/src/list/generator/iota.h b/src/list/generator/iota.h index 2d5b506..56ebeca 100644 --- a/src/list/generator/iota.h +++ b/src/list/generator/iota.h @@ -11,14 +11,14 @@ template < typename Step > struct Iota { - typedef typename Cons< + typedef Eval>, Add, Step - >::type - >::type type; + >> + >> type; }; template < @@ -26,7 +26,7 @@ template < typename Step > struct Iota, Initial, Step> { - typedef typename Cons::type type; + typedef Eval> type; }; } diff --git a/src/list/generator/make_list.h b/src/list/generator/make_list.h index 33419cb..d927905 100644 --- a/src/list/generator/make_list.h +++ b/src/list/generator/make_list.h @@ -11,18 +11,18 @@ template < typename Element > struct MakeList { - typedef typename Cons< + typedef Eval>, Element - >::type - >::type type; + >> + >> type; }; template struct MakeList, Element> { - typedef typename Cons::type type; + typedef Eval> type; }; } diff --git a/src/list/list.h b/src/list/list.h index 658ac31..e369739 100644 --- a/src/list/list.h +++ b/src/list/list.h @@ -10,25 +10,25 @@ template < typename... Tail > struct List { - typedef typename Cons< + typedef Eval::type - >::type type; + Eval> + >> type; }; template struct List { - typedef typename Cons::type type; + typedef Eval> type; }; template struct List { - typedef typename List::type type; + typedef Eval> type; }; template struct List { - typedef typename List::type type; + typedef Eval> type; }; template <> @@ -45,10 +45,10 @@ using ListOfType = List< >; template -using Head = typename Car::type; +using Head = Eval>; template -using Tail = typename Cdr::type; +using Tail = Eval>; } diff --git a/src/list/operation/append.h b/src/list/operation/append.h index 6cf15f0..28c9adf 100644 --- a/src/list/operation/append.h +++ b/src/list/operation/append.h @@ -8,13 +8,13 @@ template < typename Secondary > struct Append { - typedef typename Cons< + typedef Eval, - typename Append< + Eval, Secondary - >::type - >::type type; + >> + >> type; }; template diff --git a/src/list/operation/basic.h b/src/list/operation/basic.h index b4aa35a..5f9a3f9 100644 --- a/src/list/operation/basic.h +++ b/src/list/operation/basic.h @@ -13,11 +13,11 @@ class Length { using accumulate = Add, Accumulated>; public: - typedef typename Fold< + typedef Eval, Cons - >::type type; + >> type; }; diff --git a/src/list/operation/delete_nth.h b/src/list/operation/delete_nth.h index 03df12a..6127ade 100644 --- a/src/list/operation/delete_nth.h +++ b/src/list/operation/delete_nth.h @@ -12,8 +12,8 @@ template < typename List > using DeleteNth = Append< - typename Take::type, - typename Drop>, List>::type + Eval>, + Eval>, List>> >; } diff --git a/src/list/operation/drop.h b/src/list/operation/drop.h index 651dad5..c61983b 100644 --- a/src/list/operation/drop.h +++ b/src/list/operation/drop.h @@ -10,10 +10,10 @@ template < typename Current > struct Drop { - typedef typename Drop< + typedef Eval>, Tail - >::type type; + >> type; }; template diff --git a/src/list/operation/higher/drop_while.h b/src/list/operation/higher/drop_while.h index ad1553f..8ba2664 100644 --- a/src/list/operation/higher/drop_while.h +++ b/src/list/operation/higher/drop_while.h @@ -10,11 +10,11 @@ template < typename Current > struct DropWhile { - typedef typename If< - Predicate>::type::value, - typename DropWhile>::type, + typedef Eval>>, + Eval>>, Current - >::type type; + >> type; }; template < diff --git a/src/list/operation/higher/filter.h b/src/list/operation/higher/filter.h index acc1422..3588400 100644 --- a/src/list/operation/higher/filter.h +++ b/src/list/operation/higher/filter.h @@ -17,13 +17,13 @@ class Filter { typename Previous > using predicate_wrapper = If< - Predicate::type::value, - typename Cons::type, + Eval>, + Eval>, Previous >; public: - typedef typename Fold::type type; + typedef Eval> type; }; @@ -37,7 +37,7 @@ class Remove { using predicate_negator = Not>; public: - typedef typename Filter::type type; + typedef Eval> type; }; diff --git a/src/list/operation/higher/find.h b/src/list/operation/higher/find.h index bf9d04f..abc3199 100644 --- a/src/list/operation/higher/find.h +++ b/src/list/operation/higher/find.h @@ -11,11 +11,11 @@ template < typename Current > struct Find { - typedef typename If< - Predicate>::type::value, + typedef Eval>>, Head, - typename Find>::type - >::type type; + Eval>> + >> type; }; template < diff --git a/src/list/operation/higher/fold.h b/src/list/operation/higher/fold.h index 6ad4bd7..3ed0a42 100644 --- a/src/list/operation/higher/fold.h +++ b/src/list/operation/higher/fold.h @@ -9,10 +9,10 @@ template < typename Current > struct Fold { - typedef typename Function< + typedef Eval, - typename Fold>::type - >::type type; + Eval>> + >> type; }; template < diff --git a/src/list/operation/higher/map.h b/src/list/operation/higher/map.h index 9cb6524..ac214b7 100644 --- a/src/list/operation/higher/map.h +++ b/src/list/operation/higher/map.h @@ -16,12 +16,12 @@ class Map { typename Previous > using function_wrapper = Cons< - typename Function::type, + Eval>, Previous >; public: - typedef typename Fold::type type; + typedef Eval> type; }; diff --git a/src/list/operation/higher/partition.h b/src/list/operation/higher/partition.h index aed0ea6..eedeb91 100644 --- a/src/list/operation/higher/partition.h +++ b/src/list/operation/higher/partition.h @@ -10,8 +10,8 @@ template < typename Elements > using Partition = Cons< - typename Filter::type, - typename Remove::type + Eval>, + Eval> >; } diff --git a/src/list/operation/higher/query.h b/src/list/operation/higher/query.h index d2b8e76..1d00267 100644 --- a/src/list/operation/higher/query.h +++ b/src/list/operation/higher/query.h @@ -15,7 +15,7 @@ template < using Any = Fold< Or, Boolean, - typename Map::type + Eval> >; template < @@ -25,7 +25,7 @@ template < using All = Fold< And, Boolean, - typename Map::type + Eval> >; template < @@ -33,7 +33,7 @@ template < typename List > using None = Not< - typename Any::type + Eval> >; template < @@ -43,7 +43,7 @@ template < using Count = Fold< Add, tav::Size<0>, - typename Map::type + Eval> >; } diff --git a/src/list/operation/higher/sort.h b/src/list/operation/higher/sort.h index 5a4009c..cf86e9b 100644 --- a/src/list/operation/higher/sort.h +++ b/src/list/operation/higher/sort.h @@ -14,25 +14,25 @@ template < > class Sort { private: - using index = Divide::type, Size<2>>; - using pivot = typename Nth::type; + using index = Divide>, Size<2>>; + using pivot = Eval>; - using partitions = typename Partition< + using partitions = Eval::template function, - typename DeleteNth::type - >::type; + Eval> + >>; - using lhs = typename Car::type; - using rhs = typename Cdr::type; + using lhs = Eval>; + using rhs = Eval>; public: - typedef typename Concatenate< - typename List< - typename Sort::type, - typename List::type, - typename Sort::type - >::type - >::type type; + typedef Eval>, + Eval>, + Eval> + >> + >> type; }; template class Comparator> diff --git a/src/list/operation/higher/take_while.h b/src/list/operation/higher/take_while.h index d04dc2d..8e61c45 100644 --- a/src/list/operation/higher/take_while.h +++ b/src/list/operation/higher/take_while.h @@ -10,14 +10,14 @@ template < typename Current > struct TakeWhile { - typedef typename If< - Predicate>::type::value, - typename Cons< + typedef Eval>>, + Eval, - typename TakeWhile>::type - >::type, + Eval>> + >>, void - >::type type; + >> type; }; template < diff --git a/src/list/operation/nth.h b/src/list/operation/nth.h index 076add4..08e60cc 100644 --- a/src/list/operation/nth.h +++ b/src/list/operation/nth.h @@ -10,10 +10,10 @@ template < typename Pair > struct Nth { - typedef typename Nth< + typedef Eval>, Tail - >::type type; + >> type; }; template @@ -32,13 +32,13 @@ struct Nth, void> { }; template -using First = typename Nth, List>::type; +using First = Eval, List>>; template -using Second = typename Nth, List>::type; +using Second = Eval, List>>; template -using Third = typename Nth, List>::type; +using Third = Eval, List>>; } diff --git a/src/list/operation/reverse.h b/src/list/operation/reverse.h index 83691f8..d4b2be9 100644 --- a/src/list/operation/reverse.h +++ b/src/list/operation/reverse.h @@ -6,22 +6,20 @@ namespace tav { -template +template class Reverse { private: template < typename Current, typename Previous > - struct reversed_append { - typedef typename Append< - Previous, - typename Cons::type - >::type type; - }; + using reversed_append = Append< + Previous, + Eval> + >; public: - typedef typename Fold::type type; + typedef Eval> type; }; diff --git a/src/list/operation/take.h b/src/list/operation/take.h index c396c28..fdff123 100644 --- a/src/list/operation/take.h +++ b/src/list/operation/take.h @@ -10,13 +10,13 @@ template < typename Current > struct Take { - typedef typename Cons< + typedef Eval, - typename Take< + Eval>, Tail - >::type - >::type type; + >> + >> type; }; template -- cgit v1.2.3