mirror of
https://github.com/boostorg/mp11.git
synced 2026-07-05 08:00:48 +02:00
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<class T> using p = mp_bool<T::value & 1>; template<class T> using f = mp_size_t<T::value + 1>; template<class I> using test = mp_transform_if<p, f, mp_iota<I>>; using r1 = mp_transform<test, mp_iota_c<50>>; ```
This commit is contained in:
@@ -172,7 +172,7 @@ template<template<class...> class F, template<class...> class L1, class... T1, t
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<template<class...> class P, template<class...> class F, class... L> struct mp_transform_if_impl
|
||||
template<template<class...> class P, template<class...> 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<template<class...> class P, template<class...> class F, class... L> str
|
||||
template<class... U> using _f = mp_eval_if_q<mp_not<mp_invoke_q<Qp, U...>>, mp_first<mp_list<U...>>, Qf, U...>;
|
||||
|
||||
#endif
|
||||
};
|
||||
|
||||
using type = mp_transform<_f, L...>;
|
||||
template<template<class...> class P, template<class...> class F, class... L> struct mp_transform_if_impl
|
||||
{
|
||||
using type = mp_transform<mp_transform_if_impl_f<P, F>::template _f, L...>;
|
||||
};
|
||||
|
||||
} // namespace detail
|
||||
|
||||
Reference in New Issue
Block a user