From 45c63c95293e42860ee17368ab24cc65cc60d378 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Mon, 16 Feb 2015 16:29:50 +0100 Subject: Reimplemented `Nth` in terms of `Drop` --- src/list/operation/nth.h | 37 ++++++------------------------------- 1 file changed, 6 insertions(+), 31 deletions(-) (limited to 'src/list') 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>, - Tail - >> type; -}; - -template -struct Nth, List> { - typedef Head type; -}; - -template -struct Nth { - typedef void type; -}; - -template <> -struct Nth, void> { - typedef void type; -}; - -} - template < typename Index, typename List > -using Nth = Eval>; +using Nth = If< + IsPair>, + Head>, + void +>; template using First = Nth, List>; -- cgit v1.2.3