aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-02-16 16:29:50 +0100
committerAdrian Kummerlaender2015-02-16 16:29:50 +0100
commit45c63c95293e42860ee17368ab24cc65cc60d378 (patch)
treed8fb63e2f75726ed369322faf9323fe1325a7765
parent324988569183e38e9c5e42318571693a6fcd9569 (diff)
downloadTypeAsValue-45c63c95293e42860ee17368ab24cc65cc60d378.tar
TypeAsValue-45c63c95293e42860ee17368ab24cc65cc60d378.tar.gz
TypeAsValue-45c63c95293e42860ee17368ab24cc65cc60d378.tar.bz2
TypeAsValue-45c63c95293e42860ee17368ab24cc65cc60d378.tar.lz
TypeAsValue-45c63c95293e42860ee17368ab24cc65cc60d378.tar.xz
TypeAsValue-45c63c95293e42860ee17368ab24cc65cc60d378.tar.zst
TypeAsValue-45c63c95293e42860ee17368ab24cc65cc60d378.zip
Reimplemented `Nth` in terms of `Drop`
-rw-r--r--src/list/operation/nth.h37
1 files changed, 6 insertions, 31 deletions
diff --git a/src/list/operation/nth.h b/src/list/operation/nth.h
index 5a604f4..0a56ba3 100644
--- a/src/list/operation/nth.h
+++ b/src/list/operation/nth.h
@@ -2,44 +2,19 @@
#define TYPEASVALUE_SRC_LIST_OPERATION_NTH_H_
#include "operation/math.h"
+#include "drop.h"
namespace tav {
-namespace detail {
-
-template <
- typename Index,
- typename List
->
-struct Nth {
- typedef Eval<Nth<
- Substract<Index, Size<1>>,
- Tail<List>
- >> type;
-};
-
-template <typename List>
-struct Nth<Size<0>, List> {
- typedef Head<List> type;
-};
-
-template <typename Index>
-struct Nth<Index, void> {
- typedef void type;
-};
-
-template <>
-struct Nth<Size<0>, void> {
- typedef void type;
-};
-
-}
-
template <
typename Index,
typename List
>
-using Nth = Eval<detail::Nth<Index, List>>;
+using Nth = If<
+ IsPair<Drop<Index, List>>,
+ Head<Drop<Index, List>>,
+ void
+>;
template <typename List>
using First = Nth<Size<0>, List>;