aboutsummaryrefslogtreecommitdiff
path: root/src/list/operation/append.h
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-02-18 20:23:35 +0100
committerAdrian Kummerlaender2015-02-18 20:23:35 +0100
commita3cfc224111c324324e29a9a7a61b511053ec14c (patch)
tree64c92507ee353e64b00597460d428ad4c84e7b14 /src/list/operation/append.h
parentaf5662781840ac45c21cbf14cbc7973bcf39d1da (diff)
downloadTypeAsValue-a3cfc224111c324324e29a9a7a61b511053ec14c.tar
TypeAsValue-a3cfc224111c324324e29a9a7a61b511053ec14c.tar.gz
TypeAsValue-a3cfc224111c324324e29a9a7a61b511053ec14c.tar.bz2
TypeAsValue-a3cfc224111c324324e29a9a7a61b511053ec14c.tar.lz
TypeAsValue-a3cfc224111c324324e29a9a7a61b511053ec14c.tar.xz
TypeAsValue-a3cfc224111c324324e29a9a7a61b511053ec14c.tar.zst
TypeAsValue-a3cfc224111c324324e29a9a7a61b511053ec14c.zip
Reimplemented `Append` in terms of `Fold`
* `Fold` already implements the necessary partial specializations for traversing list structures
Diffstat (limited to 'src/list/operation/append.h')
-rw-r--r--src/list/operation/append.h40
1 files changed, 22 insertions, 18 deletions
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<Primary>,
- Eval<Append<
- Tail<Primary>,
- Secondary
- >>
- > type;
-};
-
-template <typename Secondary>
-struct Append<void, Secondary> {
- typedef Secondary type;
+template <typename Replacement>
+struct replace_void_cdr {
+ template <typename CAR, typename CDR>
+ using function = Cons<
+ CAR,
+ If<
+ Eval<std::is_void<CDR>>,
+ Replacement,
+ CDR
+ >
+ >;
};
}
@@ -30,7 +26,15 @@ template <
typename Primary,
typename Secondary
>
-using Append = Eval<detail::Append<Primary, Secondary>>;
+using Append = If<
+ Eval<std::is_void<Primary>>,
+ Secondary,
+ Fold<
+ detail::replace_void_cdr<Secondary>::template function,
+ void,
+ Primary
+ >
+>;
}