From ad27a79a2e6bc380e68ec77ae961917a9fb402d3 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Thu, 12 Feb 2015 10:16:54 +0100 Subject: Revamped partial function application * moved internals into separate header i.e. the `detail` namespace relating to `Apply` * implemented automatic alias selection by implementing aliae of the basic variadic `type` template alias in different base classes ** variadic partial application is implemented in `detail::apply_variadic` *** `detail::apply_single` and `detail::apply_pair` define aliae to `detail::apply_variadic`'s `type` template alias *** both restricted aliae derive from `detail::apply_variadic` ** `Apply` derives from any of the aliae defining base classes depending on the count of placeholders as determined by `detail::count_placeholders` *** `Apply` is guaranteed to always be derived from `detail::apply_variadic` one way or the other * changed functions, test cases and examples depending on `Apply` accordingly ** `Length` had to be reimplemented without `Apply` as it doesn't allow usage of aliae expecting a different count of arguments anymore *** this is a advantage in the sense that core functionality of _TypeAsValue_ now doesn't depend on this complex partial application implementation anymore *** such functionality may be reimplemented separately from `Apply` * removed unnecessary `tav` namespace prefixes --- src/list/operation/basic.h | 21 ++++++++++++++------- src/list/operation/contains.h | 2 +- src/list/operation/delete.h | 2 +- src/list/operation/higher/sort.h | 2 +- 4 files changed, 17 insertions(+), 10 deletions(-) (limited to 'src/list') diff --git a/src/list/operation/basic.h b/src/list/operation/basic.h index cbbe22c..b4aa35a 100644 --- a/src/list/operation/basic.h +++ b/src/list/operation/basic.h @@ -2,17 +2,24 @@ #define TYPEASVALUE_SRC_LIST_OPERATION_BASIC_H_ #include "higher/fold.h" -#include "function/apply.h" #include "operation/math.h" namespace tav { -template -using Length = Fold< - Apply, _1>::pair_type, - Size<0>, - Pair ->; +template +class Length { + private: + template + using accumulate = Add, Accumulated>; + + public: + typedef typename Fold< + accumulate, + Size<0>, + Cons + >::type type; + +}; } diff --git a/src/list/operation/contains.h b/src/list/operation/contains.h index 51d7d9f..458acc0 100644 --- a/src/list/operation/contains.h +++ b/src/list/operation/contains.h @@ -12,7 +12,7 @@ template < typename List > using Contains = Any< - Apply::template single_type, + Apply::template type, List >; diff --git a/src/list/operation/delete.h b/src/list/operation/delete.h index 2ff674c..a524667 100644 --- a/src/list/operation/delete.h +++ b/src/list/operation/delete.h @@ -12,7 +12,7 @@ template < typename List > using Delete = Remove< - Apply::template single_type, + Apply::template type, List >; diff --git a/src/list/operation/higher/sort.h b/src/list/operation/higher/sort.h index f9146d6..5bc30c6 100644 --- a/src/list/operation/higher/sort.h +++ b/src/list/operation/higher/sort.h @@ -18,7 +18,7 @@ class Sort { using pivot = typename Nth::type; using partitions = typename Partition< - Apply::template single_type, + Apply::template type, typename DeleteNth::type >::type; -- cgit v1.2.3