diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/collections.hpp | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/lib/collections.hpp b/lib/collections.hpp index c9b0127..beb01f8 100644 --- a/lib/collections.hpp +++ b/lib/collections.hpp @@ -13,6 +13,20 @@ operator+(const std::array<T, first> & a, const std::array<T, second> & b) return r; } +template<typename T, typename V, std::size_t first, std::size_t second> +constexpr std::array<std::pair<T, V>, first * second> +operator*(const std::array<T, first> & a, const std::array<V, second> & b) +{ + std::array<std::pair<T, V>, first * second> r; + auto out = r.begin(); + for (const auto & ae : a) { + for (const auto & be : b) { + *out++ = {ae, be}; + } + } + return r; +} + template<typename T, std::size_t N> constexpr auto operator*(const std::array<T, N> & in, auto && f) |