aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-02-15 20:31:07 +0100
committerAdrian Kummerlaender2015-02-15 20:31:07 +0100
commit8e49cc6f8f2186ef028bfa765fd06e52ce5218c5 (patch)
treed5ea614a9e666c267f85b1377f909f63868a3b13
parent46e174935b122c0da4b51532a7f683a512eeaf65 (diff)
downloadTypeAsValue-8e49cc6f8f2186ef028bfa765fd06e52ce5218c5.tar
TypeAsValue-8e49cc6f8f2186ef028bfa765fd06e52ce5218c5.tar.gz
TypeAsValue-8e49cc6f8f2186ef028bfa765fd06e52ce5218c5.tar.bz2
TypeAsValue-8e49cc6f8f2186ef028bfa765fd06e52ce5218c5.tar.lz
TypeAsValue-8e49cc6f8f2186ef028bfa765fd06e52ce5218c5.tar.xz
TypeAsValue-8e49cc6f8f2186ef028bfa765fd06e52ce5218c5.tar.zst
TypeAsValue-8e49cc6f8f2186ef028bfa765fd06e52ce5218c5.zip
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
-rw-r--r--src/list/operation/higher/filter.h36
-rw-r--r--src/list/operation/higher/remove.h21
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<typename> class Predicate,
- typename List
->
-class Filter {
- private:
- template <
- typename Current,
- typename Previous
- >
- using predicate_wrapper = If<
- Eval<Predicate<Current>>,
- Cons<Current, Previous>,
- Previous
- >;
-
- public:
- typedef tav::Fold<predicate_wrapper, void, List> type;
-
+template <template<typename> class Predicate>
+struct filter_predicate {
+ template <
+ typename Current,
+ typename Previous
+ >
+ using function = If<
+ Eval<Predicate<Current>>,
+ Cons<Current, Previous>,
+ Previous
+ >;
};
}
@@ -35,7 +27,11 @@ template <
template<typename> class Predicate,
typename List
>
-using Filter = Eval<detail::Filter<Predicate, List>>;
+using Filter = Fold<
+ detail::filter_predicate<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<typename> class Predicate,
- typename List
->
-class Remove {
- private:
- template <typename Element>
- using predicate_negator = Not<Predicate<Element>>;
-
- public:
- typedef tav::Filter<predicate_negator, List> type;
-
+template <template<typename> class Predicate>
+struct predicate_negator {
+ template <typename Element>
+ using function = Not<Predicate<Element>>;
};
}
@@ -27,7 +19,10 @@ template <
template<typename> class Predicate,
typename List
>
-using Remove = Eval<detail::Remove<Predicate, List>>;
+using Remove = Filter<
+ detail::predicate_negator<Predicate>::template function,
+ List
+>;
}