aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorAdrian Kummerlaender2015-01-24 12:07:55 +0100
committerAdrian Kummerlaender2015-01-24 12:07:55 +0100
commitf9844b741feac35622b9566c6afae9bb686f5149 (patch)
tree15c5791acb5506a19a9fb16cc785065a7e478a99 /src
parent8432906bf9be6f16aafdb23aaed34f1247404329 (diff)
downloadTypeAsValue-f9844b741feac35622b9566c6afae9bb686f5149.tar
TypeAsValue-f9844b741feac35622b9566c6afae9bb686f5149.tar.gz
TypeAsValue-f9844b741feac35622b9566c6afae9bb686f5149.tar.bz2
TypeAsValue-f9844b741feac35622b9566c6afae9bb686f5149.tar.lz
TypeAsValue-f9844b741feac35622b9566c6afae9bb686f5149.tar.xz
TypeAsValue-f9844b741feac35622b9566c6afae9bb686f5149.tar.zst
TypeAsValue-f9844b741feac35622b9566c6afae9bb686f5149.zip
Added `MakeList` list generator
* as its name implies this function returns a list of `Count` elements of value `Element` * added appropriate test case
Diffstat (limited to 'src')
-rw-r--r--src/list/generator/make_list.h30
1 files changed, 30 insertions, 0 deletions
diff --git a/src/list/generator/make_list.h b/src/list/generator/make_list.h
new file mode 100644
index 0000000..3bf65a2
--- /dev/null
+++ b/src/list/generator/make_list.h
@@ -0,0 +1,30 @@
+#ifndef TYPEASVALUE_SRC_LIST_GENERATOR_MAKE_LIST_H_
+#define TYPEASVALUE_SRC_LIST_GENERATOR_MAKE_LIST_H_
+
+#include "list/cons.h"
+#include "operation/math.h"
+
+namespace tav {
+
+template <
+ typename Count,
+ typename Element
+>
+struct MakeList {
+ typedef Cons<
+ Element,
+ typename MakeList<
+ Substract<Count, Size<1>>,
+ Element
+ >::type
+ > type;
+};
+
+template <typename Element>
+struct MakeList<Size<1>, Element> {
+ typedef Cons<Element, void> type;
+};
+
+}
+
+#endif // TYPEASVALUE_SRC_LIST_GENERATOR_MAKE_LIST_H_