From e1739b99d306478fc62e0609246de7b0f933e50b Mon Sep 17 00:00:00 2001 From: drewcassidy Date: Thu, 1 Apr 2021 23:26:16 -0700 Subject: [PATCH] Fix map? --- quicktex/util.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/quicktex/util.h b/quicktex/util.h index 4bf062c..92b2059 100644 --- a/quicktex/util.h +++ b/quicktex/util.h @@ -23,6 +23,7 @@ #include #include #include +#include #include #include "ndebug.h" @@ -48,7 +49,7 @@ template constexpr auto iabs(S i) { * @param packed Packed integer input of type I. * @return Unpacked std::array of type O and size C. */ -template constexpr auto Unpack(I packed) noexcept(ndebug) { +template constexpr std::array Unpack(I packed) { // type checking static_assert(std::is_unsigned::value, "Packed input type must be unsigned"); static_assert(std::is_unsigned::value, "Unpacked output type must be unsigned"); @@ -75,7 +76,7 @@ template constexpr auto Unpack(I pa * @param vals Unpacked std::array of type I and size C. * @return Packed integer input of type O. */ -template constexpr auto Pack(const std::array &vals) { +template constexpr O Pack(const std::array &vals) { // type checking static_assert(std::is_unsigned::value, "Unpacked input type must be unsigned"); static_assert(std::is_unsigned::value, "Packed output type must be unsigned"); @@ -100,8 +101,12 @@ template constexpr std::array ExpandAr return res; } -template constexpr auto MapArray(const std::array &input, Fn op) { - std::array, N> output; +template constexpr auto MapArray(const Seq &input, Fn op) { + using I = typename Seq::value_type; + using O = decltype(op(std::declval())); + constexpr size_t N = std::tuple_size::value; + + std::array output; for (unsigned i = 0; i < N; i++) { output[i] = op(input[i]); } return output; }