11#ifndef BOOST_MP11_SET_HPP_INCLUDED
22#define BOOST_MP11_SET_HPP_INCLUDED
33
4- // Copyright 2015, 2019 Peter Dimov.
4+ // Copyright 2015, 2019, 2024 Peter Dimov.
55//
66// Distributed under the Boost Software License, Version 1.0.
77//
1010
1111#include < boost/mp11/utility.hpp>
1212#include < boost/mp11/function.hpp>
13+ #include < boost/mp11/detail/config.hpp>
1314#include < boost/mp11/detail/mp_list.hpp>
1415#include < boost/mp11/detail/mp_append.hpp>
1516#include < boost/mp11/detail/mp_copy_if.hpp>
17+ #include < boost/mp11/detail/mp_fold.hpp>
1618#include < boost/mp11/detail/mp_remove_if.hpp>
1719#include < boost/mp11/detail/mp_is_list.hpp>
1820#include < type_traits>
@@ -94,6 +96,34 @@ template<class S, class... T> using mp_set_push_front = typename detail::mp_set_
9496namespace detail
9597{
9698
99+ #if !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1900 )
100+
101+ struct mp_is_set_helper_start
102+ {
103+ static constexpr bool value = true ;
104+ template <class T > static mp_false contains ( T );
105+ };
106+
107+ template <class Base , class T >
108+ struct mp_is_set_helper : Base
109+ {
110+ static constexpr bool value = Base::value && !decltype ( Base::contains( mp_identity<T>{} ) )::value;
111+ using Base::contains;
112+ static mp_true contains ( mp_identity<T> );
113+ };
114+
115+ template <class S > struct mp_is_set_impl
116+ {
117+ using type = mp_false;
118+ };
119+
120+ template <template <class ...> class L , class ... T> struct mp_is_set_impl <L<T...>>
121+ {
122+ using type = mp_bool<mp_fold<mp_list<T...>, detail::mp_is_set_helper_start, detail::mp_is_set_helper>::value>;
123+ };
124+
125+ #else
126+
97127template <class S > struct mp_is_set_impl
98128{
99129 using type = mp_false;
@@ -104,6 +134,8 @@ template<template<class...> class L, class... T> struct mp_is_set_impl<L<T...>>
104134 using type = mp_to_bool<std::is_same<mp_list<T...>, mp_set_push_back<mp_list<>, T...> > >;
105135};
106136
137+ #endif // !BOOST_MP11_WORKAROUND( BOOST_MP11_MSVC, < 1900 )
138+
107139} // namespace detail
108140
109141template <class S > using mp_is_set = typename detail::mp_is_set_impl<S>::type;
0 commit comments