From ec52d63d3caca690e822e1a07ba9c2f47710b4d5 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 17 Jan 2015 20:34:11 +0100 Subject: Implemented `Nth` function * as its name implies this function returns the _nth_ value of a given _Cons_ structure * added appropriate test case --- src/list/operation/basic.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src') diff --git a/src/list/operation/basic.h b/src/list/operation/basic.h index 1e05a50..cee4cbc 100644 --- a/src/list/operation/basic.h +++ b/src/list/operation/basic.h @@ -1,6 +1,8 @@ #ifndef TYPEASVALUE_SRC_LIST_OPERATION_BASIC_H_ #define TYPEASVALUE_SRC_LIST_OPERATION_BASIC_H_ +#include "operation/math.h" + namespace tav { template @@ -16,6 +18,23 @@ struct Length { typedef Size<0> type; }; +template < + typename Index, + typename Cons +> +struct Nth { + typedef If< + equal_value>::value, + Head, + typename Nth>, Tail>::type + > type; +}; + +template +struct Nth { + typedef void type; +}; + } #endif // TYPEASVALUE_SRC_LIST_OPERATION_BASIC_H_ -- cgit v1.2.3