Skip to content

Commit 5e44572

Browse files
jonathanpoelenpdimov
authored andcommitted
optimize mp_drop (extract f from the struct to benefit from memoization)
compiler | gcc-12 | clang-15 before | 0:00.48s - 192464K | 0:00.48s - 154480K after | 0:00.43s - 172472K | 0:00.46s - 150404K ```cpp template<class L> struct f { template<class I> using g = mp_drop<L, I>; }; template<class I, class L = mp_iota<I>> using test = mp_transform<f<L>::template g, L>; using r1 = mp_transform<test, mp_iota_c<50>>; ```
1 parent efa2a7b commit 5e44572

1 file changed

Lines changed: 5 additions & 2 deletions

File tree

include/boost/mp11/algorithm.hpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -330,11 +330,14 @@ namespace detail
330330

331331
template<class L, class L2, class En> struct mp_drop_impl;
332332

333-
template<template<class...> class L, class... T, template<class...> class L2, class... U> struct mp_drop_impl<L<T...>, L2<U...>, mp_true>
333+
template<template<class...> class L, class... U> struct mp_drop_impl_f
334334
{
335335
template<class... W> static mp_identity<L<W...>> f( U*..., mp_identity<W>*... );
336+
};
336337

337-
using R = decltype( f( static_cast<mp_identity<T>*>(0) ... ) );
338+
template<template<class...> class L, class... T, template<class...> class L2, class... U> struct mp_drop_impl<L<T...>, L2<U...>, mp_true>
339+
{
340+
using R = decltype( mp_drop_impl_f<L, U...>::f( static_cast<mp_identity<T>*>(0) ... ) );
338341

339342
using type = typename R::type;
340343
};

0 commit comments

Comments
 (0)