diff options
author | Adrian Kummerlaender | 2015-01-17 22:48:39 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2015-01-17 22:48:39 +0100 |
commit | 8943b2e30f8275619df0cf89f1e8ebc7deb58ca5 (patch) | |
tree | afa2c29c854cf8d3a8db9600174aa8f8b345aa2f | |
parent | 28dd281dd3e7c16185ecdb06b2a83f15bb074717 (diff) | |
download | TypeAsValue-8943b2e30f8275619df0cf89f1e8ebc7deb58ca5.tar TypeAsValue-8943b2e30f8275619df0cf89f1e8ebc7deb58ca5.tar.gz TypeAsValue-8943b2e30f8275619df0cf89f1e8ebc7deb58ca5.tar.bz2 TypeAsValue-8943b2e30f8275619df0cf89f1e8ebc7deb58ca5.tar.lz TypeAsValue-8943b2e30f8275619df0cf89f1e8ebc7deb58ca5.tar.xz TypeAsValue-8943b2e30f8275619df0cf89f1e8ebc7deb58ca5.tar.zst TypeAsValue-8943b2e30f8275619df0cf89f1e8ebc7deb58ca5.zip |
Replaced `If` based `Nth` implementation with partial specializations
* partial specializations offer control over lazy type instantiation
** `If` is currently only a `std::conditional` wrapper and requires further refinement to be really useful for this kind of use case
-rw-r--r-- | src/list/operation/basic.h | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/src/list/operation/basic.h b/src/list/operation/basic.h index dbd080e..586cf2f 100644 --- a/src/list/operation/basic.h +++ b/src/list/operation/basic.h @@ -2,7 +2,6 @@ #define TYPEASVALUE_SRC_LIST_OPERATION_BASIC_H_ #include "operation/math.h" -#include "conditional/if.h" namespace tav { @@ -24,14 +23,10 @@ template < typename Cons > struct Nth { - typedef If< - equal_value<Index, Size<0>>::value, - Head<Cons>, - typename Nth< - Substract<Index, Size<1>>, - Tail<Cons> - >::type - > type; + typedef typename Nth< + Substract<Index, Size<1>>, + Tail<Cons> + >::type type; }; template <typename Index> @@ -39,6 +34,11 @@ struct Nth<Index, void> { typedef void type; }; +template <typename Cons> +struct Nth<Size<0>, Cons> { + typedef Head<Cons> type; +}; + template < typename Count, typename Current |