aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-02-09 15:44:46 +0100
committerAdrian Kummerlaender2015-02-09 15:44:46 +0100
commit262806540c6eaf0dc45794cdf8f5f0404df10c79 (patch)
treedb51e0daaf5ba4c063151df1f3d7ea26c532b4e4 /src
parent0d194826e1661a0b945211bccb387df0b7d89066 (diff)
downloadTypeAsValue-262806540c6eaf0dc45794cdf8f5f0404df10c79.tar
TypeAsValue-262806540c6eaf0dc45794cdf8f5f0404df10c79.tar.gz
TypeAsValue-262806540c6eaf0dc45794cdf8f5f0404df10c79.tar.bz2
TypeAsValue-262806540c6eaf0dc45794cdf8f5f0404df10c79.tar.lz
TypeAsValue-262806540c6eaf0dc45794cdf8f5f0404df10c79.tar.xz
TypeAsValue-262806540c6eaf0dc45794cdf8f5f0404df10c79.tar.zst
TypeAsValue-262806540c6eaf0dc45794cdf8f5f0404df10c79.zip
Added `First`, `Second` and `Third` aliae for `Nth`
* increases expressiveness in some contexts * renamed `Partition` list template parameter to avoid confusion
Diffstat (limited to 'src')
-rw-r--r--src/list/operation/higher/partition.h6
-rw-r--r--src/list/operation/nth.h14
2 files changed, 17 insertions, 3 deletions
diff --git a/src/list/operation/higher/partition.h b/src/list/operation/higher/partition.h
index a0ea379..aed0ea6 100644
--- a/src/list/operation/higher/partition.h
+++ b/src/list/operation/higher/partition.h
@@ -7,11 +7,11 @@ namespace tav {
template <
template<typename> class Predicate,
- typename List
+ typename Elements
>
using Partition = Cons<
- typename Filter<Predicate, List>::type,
- typename Remove<Predicate, List>::type
+ typename Filter<Predicate, Elements>::type,
+ typename Remove<Predicate, Elements>::type
>;
}
diff --git a/src/list/operation/nth.h b/src/list/operation/nth.h
index 6020dcb..076add4 100644
--- a/src/list/operation/nth.h
+++ b/src/list/operation/nth.h
@@ -26,6 +26,20 @@ struct Nth<Index, void> {
typedef void type;
};
+template <>
+struct Nth<Size<0>, void> {
+ typedef void type;
+};
+
+template <typename List>
+using First = typename Nth<Size<0>, List>::type;
+
+template <typename List>
+using Second = typename Nth<Size<1>, List>::type;
+
+template <typename List>
+using Third = typename Nth<Size<2>, List>::type;
+
}
#endif // TYPEASVALUE_SRC_LIST_OPERATION_NTH_H_