From fb79d23aaccf0ccf0e54f6f8aa8da3c28375242a Mon Sep 17 00:00:00 2001 From: joaquintides Date: Fri, 8 Nov 2024 19:08:50 +0100 Subject: [PATCH] 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 808636b..3df0841 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