aboutsummaryrefslogtreecommitdiff
path: root/src/list
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-01-17 17:28:02 +0100
committerAdrian Kummerlaender2015-01-17 17:28:02 +0100
commit385c51950644121d7b6e04718374b1af63209ac7 (patch)
tree4d386aadebbb4b1e28ac835f4e5e6736c05ed5dd /src/list
parentd975c2365730644a7eb15b88e02ec0e92b1fe7b1 (diff)
downloadTypeAsValue-385c51950644121d7b6e04718374b1af63209ac7.tar
TypeAsValue-385c51950644121d7b6e04718374b1af63209ac7.tar.gz
TypeAsValue-385c51950644121d7b6e04718374b1af63209ac7.tar.bz2
TypeAsValue-385c51950644121d7b6e04718374b1af63209ac7.tar.lz
TypeAsValue-385c51950644121d7b6e04718374b1af63209ac7.tar.xz
TypeAsValue-385c51950644121d7b6e04718374b1af63209ac7.tar.zst
TypeAsValue-385c51950644121d7b6e04718374b1af63209ac7.zip
Implemented `Length` function
* as its name implies this function returns the length of a given _Cons_ structure * result type is `Size<Length>` which wraps `std::size_t` to match the `sizeof` operator
Diffstat (limited to 'src/list')
-rw-r--r--src/list/list.h10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/list/list.h b/src/list/list.h
index edd46e8..f21d0fc 100644
--- a/src/list/list.h
+++ b/src/list/list.h
@@ -27,6 +27,16 @@ using Head = Car<Cons>;
template <typename Cons>
using Tail = Cdr<Cons>;
+template <typename Cons>
+struct Length {
+ typedef Add<Size<1>, typename Length<Cdr<Cons>>::type> type;
+};
+
+template <>
+struct Length<void> {
+ typedef Size<0> type;
+};
+
template <
typename Primary,
typename Secondary