diff options
author | Adrian Kummerlaender | 2015-01-16 23:55:01 +0100 |
---|---|---|
committer | Adrian Kummerlaender | 2015-01-16 23:55:01 +0100 |
commit | f922e0b5dfc0a03378b231ad2705dbef29310d56 (patch) | |
tree | 5eba4408c43405284d0b205a616265d12fdde15f /src/list | |
parent | 01029e59e8eda0a160291c3c92f9db5b1cac54d3 (diff) | |
download | TypeAsValue-f922e0b5dfc0a03378b231ad2705dbef29310d56.tar TypeAsValue-f922e0b5dfc0a03378b231ad2705dbef29310d56.tar.gz TypeAsValue-f922e0b5dfc0a03378b231ad2705dbef29310d56.tar.bz2 TypeAsValue-f922e0b5dfc0a03378b231ad2705dbef29310d56.tar.lz TypeAsValue-f922e0b5dfc0a03378b231ad2705dbef29310d56.tar.xz TypeAsValue-f922e0b5dfc0a03378b231ad2705dbef29310d56.tar.zst TypeAsValue-f922e0b5dfc0a03378b231ad2705dbef29310d56.zip |
Implemented recursive `Concatenate` _Cons_ constructor
* concatenates two given _Cons_ based lists into a single one
Diffstat (limited to 'src/list')
-rw-r--r-- | src/list/list.h | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/src/list/list.h b/src/list/list.h index 47d0d2f..edd46e8 100644 --- a/src/list/list.h +++ b/src/list/list.h @@ -21,6 +21,31 @@ struct List<Head> { typedef Cons<Head, void> type; }; +template <typename Cons> +using Head = Car<Cons>; + +template <typename Cons> +using Tail = Cdr<Cons>; + +template < + typename Primary, + typename Secondary +> +struct Concatenate { + typedef Cons< + Head<Primary>, + typename Concatenate< + Tail<Primary>, + Secondary + >::type + > type; +}; + +template <typename Secondary> +struct Concatenate<void, Secondary> { + typedef Secondary type; +}; + } #endif // TYPEASVALUE_SRC_LIST_LIST_H_ |