From b21ff00f9bc03e5b87f259bc25e45594ab245a34 Mon Sep 17 00:00:00 2001 From: Jonathan Poelen Date: Mon, 19 Jun 2023 22:51:22 +0200 Subject: [PATCH] optimize mp_transform_if (extract f from the struct to benefit from memoization) compiler | gcc-12 | clang-15 before | 0:00.13s - 60432K | 0:00.16s - 100956K after | 0:00.11s - 47300K | 0:00.16s - 100484K ```cpp using namespace boost::mp11; template using p = mp_bool; template using f = mp_size_t; template using test = mp_transform_if>; using r1 = mp_transform>; ``` --- include/boost/mp11/algorithm.hpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/include/boost/mp11/algorithm.hpp b/include/boost/mp11/algorithm.hpp index 07a8ffd..0c8b4b2 100644 --- a/include/boost/mp11/algorithm.hpp +++ b/include/boost/mp11/algorithm.hpp @@ -172,7 +172,7 @@ template class F, template class L1, class... T1, t namespace detail { -template class P, template class F, class... L> struct mp_transform_if_impl +template class P, template class F> struct mp_transform_if_impl_f { // the stupid quote-unquote dance avoids "pack expansion used as argument for non-pack parameter of alias template" @@ -189,8 +189,11 @@ template class P, template class F, class... L> str template using _f = mp_eval_if_q>, mp_first>, Qf, U...>; #endif +}; - using type = mp_transform<_f, L...>; +template class P, template class F, class... L> struct mp_transform_if_impl +{ + using type = mp_transform::template _f, L...>; }; } // namespace detail