From 385c51950644121d7b6e04718374b1af63209ac7 Mon Sep 17 00:00:00 2001 From: Adrian Kummerlaender Date: Sat, 17 Jan 2015 17:28:02 +0100 Subject: Implemented `Length` function * as its name implies this function returns the length of a given _Cons_ structure * result type is `Size` which wraps `std::size_t` to match the `sizeof` operator --- src/list/list.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/list/list.h') 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; template using Tail = Cdr; +template +struct Length { + typedef Add, typename Length>::type> type; +}; + +template <> +struct Length { + typedef Size<0> type; +}; + template < typename Primary, typename Secondary -- cgit v1.2.3