From 997206a1aeea2abc0e331bcbb10f939f52670aa2 Mon Sep 17 00:00:00 2001 From: Jonathan Poelen Date: Tue, 20 Jun 2023 01:42:00 +0200 Subject: [PATCH] optimize mp_map_replace compiler | gcc-12 | clang-15 before | 0:00.46s - 187160K | 0:00.38s - 129104K after | 0:00.21s - 80236K | 0:00.33s - 123644K ```cpp using namespace boost::mp11; template> struct f { template using g = mp_map_replace>; }; template> using test = mp_transform::template g, L>; using r1 = mp_transform>; ``` --- include/boost/mp11/map.hpp | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/include/boost/mp11/map.hpp b/include/boost/mp11/map.hpp index b9581ac..5141d2e 100644 --- a/include/boost/mp11/map.hpp +++ b/include/boost/mp11/map.hpp @@ -38,11 +38,19 @@ template class M, class... U, class T> struct mp_map_replace_ { using K = mp_first; - // mp_replace_if is inlined here using a struct _f because of msvc-14.0 +#if BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1920 ) template struct _f { using type = mp_if< std::is_same, K>, T, V >; }; using type = mp_if< mp_map_contains, K>, M::type...>, M >; + +#else + + template using _f = mp_if< std::is_same, K>, T, V >; + + using type = mp_if< mp_map_contains, K>, M<_f...>, M >; + +#endif }; } // namespace detail