From a3cfc224111c324324e29a9a7a61b511053ec14c Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Wed, 18 Feb 2015 20:23:35 +0100 Subject: Reimplemented `Append` in terms of `Fold` * `Fold` already implements the necessary partial specializations for traversing list structures --- src/list/operation/append.h | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) (limited to 'src/list/operation/append.h') diff --git a/src/list/operation/append.h b/src/list/operation/append.h index 2dcd184..77f72d9 100644 --- a/src/list/operation/append.h +++ b/src/list/operation/append.h @@ -1,27 +1,23 @@ #ifndef TYPEASVALUE_SRC_LIST_OPERATION_APPEND_H_ #define TYPEASVALUE_SRC_LIST_OPERATION_APPEND_H_ +#include "higher/fold.h" + namespace tav { namespace detail { -template < - typename Primary, - typename Secondary -> -struct Append { - typedef Cons< - Head, - Eval, - Secondary - >> - > type; -}; - -template -struct Append { - typedef Secondary type; +template +struct replace_void_cdr { + template + using function = Cons< + CAR, + If< + Eval>, + Replacement, + CDR + > + >; }; } @@ -30,7 +26,15 @@ template < typename Primary, typename Secondary > -using Append = Eval>; +using Append = If< + Eval>, + Secondary, + Fold< + detail::replace_void_cdr::template function, + void, + Primary + > +>; } -- cgit v1.2.3