From fb79d23aaccf0ccf0e54f6f8aa8da3c28375242a Mon Sep 17 00:00:00 2001 From: joaquintides Date: Fri, 8 Nov 2024 19:08:50 +0100 Subject: [PATCH 1/4] improved performance of mp_is_set --- include/boost/mp11/set.hpp | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/include/boost/mp11/set.hpp b/include/boost/mp11/set.hpp index 808636b7..3df0841e 100644 --- a/include/boost/mp11/set.hpp +++ b/include/boost/mp11/set.hpp @@ -1,7 +1,7 @@ #ifndef BOOST_MP11_SET_HPP_INCLUDED #define BOOST_MP11_SET_HPP_INCLUDED -// Copyright 2015, 2019 Peter Dimov. +// Copyright 2015, 2019, 2024 Peter Dimov. // // Distributed under the Boost Software License, Version 1.0. // @@ -94,19 +94,23 @@ template using mp_set_push_front = typename detail::mp_set_ namespace detail { -template struct mp_is_set_impl +struct mp_is_set_helper_start { - using type = mp_false; + static constexpr bool value = true; + template static mp_false contains( T ); }; -template class L, class... T> struct mp_is_set_impl> +template +struct mp_is_set_helper: Base { - using type = mp_to_bool, mp_set_push_back, T...> > >; + static constexpr bool value = Base::value && !decltype( Base::contains( mp_identity{} ) )::value; + using Base::contains; + static mp_true contains( mp_identity ); }; } // namespace detail -template using mp_is_set = typename detail::mp_is_set_impl::type; +template using mp_is_set = mp_bool::value>; // mp_set_union namespace detail From 13a81c86eef5433ec08897548d088c8e0d19993e Mon Sep 17 00:00:00 2001 From: joaquintides Date: Fri, 8 Nov 2024 19:21:27 +0100 Subject: [PATCH 2/4] added missing #include --- include/boost/mp11/set.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/boost/mp11/set.hpp b/include/boost/mp11/set.hpp index 3df0841e..af18af85 100644 --- a/include/boost/mp11/set.hpp +++ b/include/boost/mp11/set.hpp @@ -13,6 +13,7 @@ #include #include #include +#include #include #include #include From c2bc9788caba1cf3c3c81c977fc0a78189f8c1f0 Mon Sep 17 00:00:00 2001 From: joaquintides Date: Fri, 8 Nov 2024 19:50:48 +0100 Subject: [PATCH 3/4] made mp_is_set robust when S is not a list --- include/boost/mp11/set.hpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/include/boost/mp11/set.hpp b/include/boost/mp11/set.hpp index af18af85..f8c2f26a 100644 --- a/include/boost/mp11/set.hpp +++ b/include/boost/mp11/set.hpp @@ -109,9 +109,19 @@ struct mp_is_set_helper: Base static mp_true contains( mp_identity ); }; +template struct mp_is_set_impl +{ + using type = mp_false; +}; + +template class L, class... T> struct mp_is_set_impl> +{ + using type = mp_bool, detail::mp_is_set_helper_start, detail::mp_is_set_helper>::value>; +}; + } // namespace detail -template using mp_is_set = mp_bool::value>; +template using mp_is_set = typename detail::mp_is_set_impl::type; // mp_set_union namespace detail From 28929d97947ac401fc17a521cbd3ef27f6dd41d4 Mon Sep 17 00:00:00 2001 From: joaquintides Date: Fri, 8 Nov 2024 22:07:10 +0100 Subject: [PATCH 4/4] kept old impl for msvc 12.0 --- include/boost/mp11/set.hpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/include/boost/mp11/set.hpp b/include/boost/mp11/set.hpp index f8c2f26a..d65e4aeb 100644 --- a/include/boost/mp11/set.hpp +++ b/include/boost/mp11/set.hpp @@ -10,6 +10,7 @@ #include #include +#include #include #include #include @@ -95,6 +96,8 @@ template using mp_set_push_front = typename detail::mp_set_ namespace detail { +#if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1900 ) + struct mp_is_set_helper_start { static constexpr bool value = true; @@ -119,6 +122,20 @@ template class L, class... T> struct mp_is_set_impl> using type = mp_bool, detail::mp_is_set_helper_start, detail::mp_is_set_helper>::value>; }; +#else + +template struct mp_is_set_impl +{ + using type = mp_false; +}; + +template class L, class... T> struct mp_is_set_impl> +{ + using type = mp_to_bool, mp_set_push_back, T...> > >; +}; + +#endif // !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1900 ) + } // namespace detail template using mp_is_set = typename detail::mp_is_set_impl::type;