diff options
Diffstat (limited to 'src/list/generator')
-rw-r--r-- | src/list/generator/higher/list_tabulate.h | 20 | ||||
-rw-r--r-- | src/list/generator/iota.h | 34 |
2 files changed, 54 insertions, 0 deletions
diff --git a/src/list/generator/higher/list_tabulate.h b/src/list/generator/higher/list_tabulate.h new file mode 100644 index 0000000..9eee599 --- /dev/null +++ b/src/list/generator/higher/list_tabulate.h @@ -0,0 +1,20 @@ +#ifndef TYPEASVALUE_SRC_LIST_GENERATOR_HIGHER_LIST_TABULATE_H_ +#define TYPEASVALUE_SRC_LIST_GENERATOR_HIGHER_LIST_TABULATE_H_ + +#include "list/generator/iota.h" +#include "list/operation/higher/misc.h" + +namespace tav { + +template < + typename Count, + template<typename> class Initializer +> +using ListTabulate = Map< + Initializer, + typename Iota<Count, Size<0>, Size<1>>::type +>; + +} + +#endif // TYPEASVALUE_SRC_LIST_GENERATOR_HIGHER_LIST_TABULATE_H_ diff --git a/src/list/generator/iota.h b/src/list/generator/iota.h new file mode 100644 index 0000000..54f0f40 --- /dev/null +++ b/src/list/generator/iota.h @@ -0,0 +1,34 @@ +#ifndef TYPEASVALUE_SRC_LIST_GENERATOR_IOTA_H_ +#define TYPEASVALUE_SRC_LIST_GENERATOR_IOTA_H_ + +#include "operation/math.h" + +namespace tav { + +template < + typename Count, + typename Initial, + typename Step +> +struct Iota { + typedef Cons< + Initial, + typename Iota< + Substract<Count, Size<1>>, + Add<Initial, Step>, + Step + >::type + > type; +}; + +template < + typename Initial, + typename Step +> +struct Iota<Size<1>, Initial, Step> { + typedef Cons<Initial, void> type; +}; + +} + +#endif // TYPEASVALUE_SRC_LIST_GENERATOR_IOTA_H_ |