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>>;
```
This commit is contained in:
Jonathan Poelen
2023-06-19 23:07:13 +02:00
committed by Peter Dimov
parent efa2a7b554
commit 5e44572f44
+5 -2
View File
@@ -330,11 +330,14 @@ namespace detail
template<class L, class L2, class En> struct mp_drop_impl;
template<template<class...> class L, class... T, template<class...> class L2, class... U> struct mp_drop_impl<L<T...>, L2<U...>, mp_true>
template<template<class...> class L, class... U> struct mp_drop_impl_f
{
template<class... W> static mp_identity<L<W...>> f( U*..., mp_identity<W>*... );
};
using R = decltype( f( static_cast<mp_identity<T>*>(0) ... ) );
template<template<class...> class L, class... T, template<class...> class L2, class... U> struct mp_drop_impl<L<T...>, L2<U...>, mp_true>
{
using R = decltype( mp_drop_impl_f<L, U...>::f( static_cast<mp_identity<T>*>(0) ... ) );
using type = typename R::type;
};