aboutsummaryrefslogtreecommitdiff
path: root/src/list/operation/length.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/list/operation/length.h')
-rw-r--r--src/list/operation/length.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/list/operation/length.h b/src/list/operation/length.h
new file mode 100644
index 0000000..1f609d4
--- /dev/null
+++ b/src/list/operation/length.h
@@ -0,0 +1,21 @@
+#ifndef TYPEASVALUE_SRC_LIST_OPERATION_LENGTH_H_
+#define TYPEASVALUE_SRC_LIST_OPERATION_LENGTH_H_
+
+#include "higher/fold.h"
+#include "operation/math.h"
+
+namespace tav {
+
+namespace detail {
+
+template <typename, typename Accumulated>
+using length_accumulate = Add<Size<1>, Accumulated>;
+
+}
+
+template <typename List>
+using Length = Fold<detail::length_accumulate, Size<0>, List>;
+
+}
+
+#endif // TYPEASVALUE_SRC_LIST_OPERATION_LENGTH_H_