diff options
Diffstat (limited to 'tiger-compiler/lib/misc/list.hh')
| -rw-r--r-- | tiger-compiler/lib/misc/list.hh | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/tiger-compiler/lib/misc/list.hh b/tiger-compiler/lib/misc/list.hh new file mode 100644 index 0000000..d27ab66 --- /dev/null +++ b/tiger-compiler/lib/misc/list.hh @@ -0,0 +1,25 @@ +/** + ** \file misc/list.hh + ** \brief Declaration of misc::list + */ + +#pragma once + +#include <misc/vector.hh> + +/// Wrappers on misc::vectors to provide functional-style list manipulation. +namespace misc::list +{ + /// Build a list of a \a head and a \a tail. + template <typename T> vector<T> cons(const T head, const vector<T>& tail); + + /// Get the head and tail of the list. Invert of cons. + template <typename T> std::pair<T, vector<T>> snoc(const vector<T>& v); + + /// Decompose the list into an array to use structured bindings. + template <std::size_t Size, typename T> + std::array<T, Size> decompose(const vector<T>& v); + +} // namespace misc::list + +#include <misc/list.hxx> |
