aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/list/operation/append.h40
-rw-r--r--src/list/operation/concatenate.h1
-rw-r--r--src/list/operation/reverse.h2
3 files changed, 24 insertions, 19 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
+ >
+>;
}
diff --git a/src/list/operation/concatenate.h b/src/list/operation/concatenate.h
index 944470b..a5cbaa6 100644
--- a/src/list/operation/concatenate.h
+++ b/src/list/operation/concatenate.h
@@ -2,6 +2,7 @@
#define TYPEASVALUE_SRC_LIST_OPERATION_CONCATENATE_H_
#include "append.h"
+#include "higher/remove.h"
#include "higher/fold.h"
namespace tav {
diff --git a/src/list/operation/reverse.h b/src/list/operation/reverse.h
index 6d9237d..cabc229 100644
--- a/src/list/operation/reverse.h
+++ b/src/list/operation/reverse.h
@@ -12,7 +12,7 @@ template <
typename Current,
typename Previous
>
-using reversed_append = tav::Append<Previous, List<Current>>;
+using reversed_append = Append<Previous, List<Current>>;
}