File indexing completed on 2025-01-18 09:53:20
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #ifndef BOOST_UNORDERED_DETAIL_CONCURRENT_STATIC_ASSERTS_HPP
0011 #define BOOST_UNORDERED_DETAIL_CONCURRENT_STATIC_ASSERTS_HPP
0012
0013 #include <boost/config.hpp>
0014 #include <boost/mp11/algorithm.hpp>
0015 #include <boost/mp11/list.hpp>
0016
0017 #include <functional>
0018 #include <iterator>
0019 #include <type_traits>
0020
0021 #define BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F) \
0022 static_assert(boost::unordered::detail::is_invocable<F, value_type&>::value, \
0023 "The provided Callable must be invocable with value_type&");
0024
0025 #define BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F) \
0026 static_assert( \
0027 boost::unordered::detail::is_invocable<F, value_type const&>::value, \
0028 "The provided Callable must be invocable with value_type const&");
0029
0030 #if BOOST_CXX_VERSION >= 202002L
0031
0032 #define BOOST_UNORDERED_STATIC_ASSERT_EXEC_POLICY(P) \
0033 static_assert(!std::is_base_of<std::execution::parallel_unsequenced_policy, \
0034 ExecPolicy>::value, \
0035 "ExecPolicy must be sequenced."); \
0036 static_assert( \
0037 !std::is_base_of<std::execution::unsequenced_policy, ExecPolicy>::value, \
0038 "ExecPolicy must be sequenced.");
0039
0040 #else
0041
0042 #define BOOST_UNORDERED_STATIC_ASSERT_EXEC_POLICY(P) \
0043 static_assert(!std::is_base_of<std::execution::parallel_unsequenced_policy, \
0044 ExecPolicy>::value, \
0045 "ExecPolicy must be sequenced.");
0046 #endif
0047
0048 #define BOOST_UNORDERED_DETAIL_COMMA ,
0049
0050 #define BOOST_UNORDERED_DETAIL_LAST_ARG(Arg, Args) \
0051 mp11::mp_back<mp11::mp_list<Arg BOOST_UNORDERED_DETAIL_COMMA Args> >
0052
0053 #define BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_INVOCABLE(Arg, Args) \
0054 BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE( \
0055 BOOST_UNORDERED_DETAIL_LAST_ARG(Arg, Args))
0056
0057 #define BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_CONST_INVOCABLE(Arg, Args) \
0058 BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE( \
0059 BOOST_UNORDERED_DETAIL_LAST_ARG(Arg, Args))
0060
0061 namespace boost {
0062 namespace unordered {
0063 namespace detail {
0064 template <class F, class... Args>
0065 struct is_invocable
0066 : std::is_constructible<std::function<void(Args...)>,
0067 std::reference_wrapper<typename std::remove_reference<F>::type> >
0068 {
0069 };
0070
0071 }
0072
0073 }
0074
0075 }
0076
0077 #if defined(BOOST_NO_CXX20_HDR_CONCEPTS)
0078 #define BOOST_UNORDERED_STATIC_ASSERT_FWD_ITERATOR(Iterator) \
0079 static_assert( \
0080 std::is_base_of< \
0081 std::forward_iterator_tag, \
0082 typename std::iterator_traits<Iterator>::iterator_category>::value, \
0083 "The provided iterator must be at least forward");
0084 #else
0085 #define BOOST_UNORDERED_STATIC_ASSERT_FWD_ITERATOR(Iterator) \
0086 static_assert(std::forward_iterator<Iterator>, \
0087 "The provided iterator must be at least forward");
0088
0089 #endif
0090
0091 #define BOOST_UNORDERED_STATIC_ASSERT_KEY_COMPATIBLE_ITERATOR(Iterator) \
0092 static_assert( \
0093 std::is_same< \
0094 typename std::iterator_traits<Iterator>::value_type, \
0095 key_type>::value || \
0096 detail::are_transparent< \
0097 typename std::iterator_traits<Iterator>::value_type, \
0098 hasher, key_equal>::value, \
0099 "The provided iterator must dereference to a compatible key value");
0100
0101 #define BOOST_UNORDERED_STATIC_ASSERT_BULK_VISIT_ITERATOR(Iterator) \
0102 BOOST_UNORDERED_STATIC_ASSERT_FWD_ITERATOR(Iterator) \
0103 BOOST_UNORDERED_STATIC_ASSERT_KEY_COMPATIBLE_ITERATOR(Iterator)
0104
0105 #endif