File indexing completed on 2025-09-17 08:52:31
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 #include <boost/unordered/detail/type_traits.hpp>
0017
0018 #define BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE(F) \
0019 static_assert(boost::unordered::detail::is_invocable<F, value_type&>::value, \
0020 "The provided Callable must be invocable with value_type&");
0021
0022 #define BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE(F) \
0023 static_assert( \
0024 boost::unordered::detail::is_invocable<F, value_type const&>::value, \
0025 "The provided Callable must be invocable with value_type const&");
0026
0027 #if BOOST_CXX_VERSION >= 202002L
0028
0029 #define BOOST_UNORDERED_STATIC_ASSERT_EXEC_POLICY(P) \
0030 static_assert(!std::is_base_of<std::execution::parallel_unsequenced_policy, \
0031 ExecPolicy>::value, \
0032 "ExecPolicy must be sequenced."); \
0033 static_assert( \
0034 !std::is_base_of<std::execution::unsequenced_policy, ExecPolicy>::value, \
0035 "ExecPolicy must be sequenced.");
0036
0037 #else
0038
0039 #define BOOST_UNORDERED_STATIC_ASSERT_EXEC_POLICY(P) \
0040 static_assert(!std::is_base_of<std::execution::parallel_unsequenced_policy, \
0041 ExecPolicy>::value, \
0042 "ExecPolicy must be sequenced.");
0043 #endif
0044
0045 #define BOOST_UNORDERED_DETAIL_COMMA ,
0046
0047 #define BOOST_UNORDERED_DETAIL_LAST_ARG(Arg, Args) \
0048 mp11::mp_back<mp11::mp_list<Arg BOOST_UNORDERED_DETAIL_COMMA Args> >
0049
0050 #define BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_INVOCABLE(Arg, Args) \
0051 BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE( \
0052 BOOST_UNORDERED_DETAIL_LAST_ARG(Arg, Args))
0053
0054 #define BOOST_UNORDERED_STATIC_ASSERT_LAST_ARG_CONST_INVOCABLE(Arg, Args) \
0055 BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE( \
0056 BOOST_UNORDERED_DETAIL_LAST_ARG(Arg, Args))
0057
0058 #define BOOST_UNORDERED_DETAIL_PENULTIMATE_ARG(Arg1, Arg2, Args) \
0059 mp11::mp_at_c<mp11::mp_list< \
0060 Arg1 BOOST_UNORDERED_DETAIL_COMMA Arg2 BOOST_UNORDERED_DETAIL_COMMA Args \
0061 >, \
0062 mp11::mp_size<mp11::mp_list< \
0063 Arg1 BOOST_UNORDERED_DETAIL_COMMA Arg2 BOOST_UNORDERED_DETAIL_COMMA Args \
0064 >>::value - 2>
0065
0066 #define BOOST_UNORDERED_STATIC_ASSERT_PENULTIMATE_ARG_INVOCABLE( \
0067 Arg1, Arg2, Args) \
0068 BOOST_UNORDERED_STATIC_ASSERT_INVOCABLE( \
0069 BOOST_UNORDERED_DETAIL_PENULTIMATE_ARG(Arg1, Arg2, Args))
0070
0071 #define BOOST_UNORDERED_STATIC_ASSERT_PENULTIMATE_ARG_CONST_INVOCABLE( \
0072 Arg1, Arg2, Args) \
0073 BOOST_UNORDERED_STATIC_ASSERT_CONST_INVOCABLE( \
0074 BOOST_UNORDERED_DETAIL_PENULTIMATE_ARG(Arg1, Arg2, Args))
0075
0076 namespace boost {
0077 namespace unordered {
0078 namespace detail {
0079 template <class...> struct is_invocable_helper : std::false_type
0080 {
0081 };
0082
0083 template <class F, class... Args>
0084 struct is_invocable_helper<
0085 void_t<decltype(std::declval<F>()(std::declval<Args>()...))>, F,
0086 Args...> : std::true_type
0087 {
0088 };
0089
0090 template <class F, class... Args>
0091 using is_invocable = is_invocable_helper<void, F, Args...>;
0092
0093 }
0094
0095 }
0096
0097 }
0098
0099 #if defined(BOOST_NO_CXX20_HDR_CONCEPTS)
0100 #define BOOST_UNORDERED_STATIC_ASSERT_FWD_ITERATOR(Iterator) \
0101 static_assert( \
0102 std::is_base_of< \
0103 std::forward_iterator_tag, \
0104 typename std::iterator_traits<Iterator>::iterator_category>::value, \
0105 "The provided iterator must be at least forward");
0106 #else
0107 #define BOOST_UNORDERED_STATIC_ASSERT_FWD_ITERATOR(Iterator) \
0108 static_assert(std::forward_iterator<Iterator>, \
0109 "The provided iterator must be at least forward");
0110
0111 #endif
0112
0113 #define BOOST_UNORDERED_STATIC_ASSERT_KEY_COMPATIBLE_ITERATOR(Iterator) \
0114 static_assert( \
0115 std::is_same< \
0116 typename std::iterator_traits<Iterator>::value_type, \
0117 key_type>::value || \
0118 detail::are_transparent< \
0119 typename std::iterator_traits<Iterator>::value_type, \
0120 hasher, key_equal>::value, \
0121 "The provided iterator must dereference to a compatible key value");
0122
0123 #define BOOST_UNORDERED_STATIC_ASSERT_BULK_VISIT_ITERATOR(Iterator) \
0124 BOOST_UNORDERED_STATIC_ASSERT_FWD_ITERATOR(Iterator) \
0125 BOOST_UNORDERED_STATIC_ASSERT_KEY_COMPATIBLE_ITERATOR(Iterator)
0126
0127 #endif