From 8e49cc6f8f2186ef028bfa765fd06e52ce5218c5 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sun, 15 Feb 2015 20:31:07 +0100 Subject: Reduced `Filter` and `Remove` implementations to direct aliases * i.e. instead of defining full class templates in the `detail` namespace we only define predicate helpers * I don't like how some symbols have to be prefixed with `tav::` in the `detail` namespace to prevent conflicts - this is one reason why as much implementation as possible should be moved to template aliases --- src/list/operation/higher/filter.h | 36 ++++++++++++++++-------------------- src/list/operation/higher/remove.h | 21 ++++++++------------- 2 files changed, 24 insertions(+), 33 deletions(-) diff --git a/src/list/operation/higher/filter.h b/src/list/operation/higher/filter.h index 17d49c2..9dcdf37 100644 --- a/src/list/operation/higher/filter.h +++ b/src/list/operation/higher/filter.h @@ -8,25 +8,17 @@ namespace tav { namespace detail { -template < - template class Predicate, - typename List -> -class Filter { - private: - template < - typename Current, - typename Previous - > - using predicate_wrapper = If< - Eval>, - Cons, - Previous - >; - - public: - typedef tav::Fold type; - +template class Predicate> +struct filter_predicate { + template < + typename Current, + typename Previous + > + using function = If< + Eval>, + Cons, + Previous + >; }; } @@ -35,7 +27,11 @@ template < template class Predicate, typename List > -using Filter = Eval>; +using Filter = Fold< + detail::filter_predicate::template function, + void, + List +>; } diff --git a/src/list/operation/higher/remove.h b/src/list/operation/higher/remove.h index e67e962..598f5a6 100644 --- a/src/list/operation/higher/remove.h +++ b/src/list/operation/higher/remove.h @@ -7,18 +7,10 @@ namespace tav { namespace detail { -template < - template class Predicate, - typename List -> -class Remove { - private: - template - using predicate_negator = Not>; - - public: - typedef tav::Filter type; - +template class Predicate> +struct predicate_negator { + template + using function = Not>; }; } @@ -27,7 +19,10 @@ template < template class Predicate, typename List > -using Remove = Eval>; +using Remove = Filter< + detail::predicate_negator::template function, + List +>; } -- cgit v1.2.3