From 123ce87e66013bc11bf0d9ca01776a60cf47c89b Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 17 Jan 2015 20:07:24 +0100 Subject: Extracted list operations into separate _operation_ headers --- src/list/list.h | 32 +++----------------------------- src/list/operation/basic.h | 21 +++++++++++++++++++++ src/list/operation/concatenate.h | 27 +++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 29 deletions(-) create mode 100644 src/list/operation/basic.h create mode 100644 src/list/operation/concatenate.h (limited to 'src/list') diff --git a/src/list/list.h b/src/list/list.h index f21d0fc..b0fe407 100644 --- a/src/list/list.h +++ b/src/list/list.h @@ -27,35 +27,9 @@ using Head = Car; template using Tail = Cdr; -template -struct Length { - typedef Add, typename Length>::type> type; -}; - -template <> -struct Length { - typedef Size<0> type; -}; - -template < - typename Primary, - typename Secondary -> -struct Concatenate { - typedef Cons< - Head, - typename Concatenate< - Tail, - Secondary - >::type - > type; -}; - -template -struct Concatenate { - typedef Secondary type; -}; - } +#include "operation/basic.h" +#include "operation/concatenate.h" + #endif // TYPEASVALUE_SRC_LIST_LIST_H_ diff --git a/src/list/operation/basic.h b/src/list/operation/basic.h new file mode 100644 index 0000000..1e05a50 --- /dev/null +++ b/src/list/operation/basic.h @@ -0,0 +1,21 @@ +#ifndef TYPEASVALUE_SRC_LIST_OPERATION_BASIC_H_ +#define TYPEASVALUE_SRC_LIST_OPERATION_BASIC_H_ + +namespace tav { + +template +struct Length { + typedef Add< + Size<1>, + typename Length + >::type> type; +}; + +template <> +struct Length { + typedef Size<0> type; +}; + +} + +#endif // TYPEASVALUE_SRC_LIST_OPERATION_BASIC_H_ diff --git a/src/list/operation/concatenate.h b/src/list/operation/concatenate.h new file mode 100644 index 0000000..21eb1ee --- /dev/null +++ b/src/list/operation/concatenate.h @@ -0,0 +1,27 @@ +#ifndef TYPEASVALUE_SRC_LIST_OPERATION_CONCATENATE_H_ +#define TYPEASVALUE_SRC_LIST_OPERATION_CONCATENATE_H_ + +namespace tav { + +template < + typename Primary, + typename Secondary +> +struct Concatenate { + typedef Cons< + Head, + typename Concatenate< + Tail, + Secondary + >::type + > type; +}; + +template +struct Concatenate { + typedef Secondary type; +}; + +} + +#endif // TYPEASVALUE_SRC_LIST_OPERATION_CONCATENATE_H_ -- cgit v1.2.3