@@ -61,30 +61,26 @@ struct aggregate_reports<mp11::mp_list<Reports...>, mp11::mp_list<>, Void> {
6161
6262// Policy initialization helpers
6363
64- // Detect if a policy fn has an initialize function with the expected signature
65- template <typename PolicyFn, typename Context, typename Options, typename = void >
66- struct has_initialize : std::false_type {};
67-
6864#if defined(_MSC_VER) && _MSC_VER <= 1950
69- template <typename PolicyFn, typename Context, typename Options>
70- struct has_initialize <
71- PolicyFn, Context, Options,
72- std::void_t <decltype (&PolicyFn::template initialize<Context, Options>)>>
73- : std::true_type {};
65+ template <typename , class , class ...>
66+ struct has_initialize_aux : std::false_type {};
67+
68+ template <class T , class ... Args>
69+ struct has_initialize_aux <
70+ std::void_t <decltype (&T::template initialize<std::decay_t <Args>...>)>,
71+ T, Args...> : std::true_type {};
72+
73+ template <class T , class ... Args>
74+ constexpr bool has_initialize = has_initialize_aux<void , T, Args...>::value;
7475#else
75- template <typename PolicyFn, typename Context, typename Options>
76- struct has_initialize <
77- PolicyFn, Context, Options,
78- std::void_t <decltype (PolicyFn::initialize(
79- std::declval<const Context&>(), std::declval<const Options&>()))>>
80- : std::true_type {};
76+ BOOST_OPENMETHOD_DETAIL_HAS_STATIC_FN (has_initialize, initialize);
8177#endif
8278
8379// Call initialize on a single policy if it has the function
8480template <typename Policy, typename Registry, typename Context, typename Options>
8581void initialize_policy (const Context& ctx, const Options& options) {
8682 using PolicyFn = typename Policy::template fn<Registry>;
87- if constexpr (has_initialize<PolicyFn, Context, Options>::value ) {
83+ if constexpr (has_initialize<PolicyFn, const Context&, const Options&> ) {
8884 PolicyFn::initialize (ctx, options);
8985 }
9086}
@@ -585,7 +581,7 @@ template<class... Options>
585581void registry<Policies...>::compiler<Options...>::initialize() {
586582 compile ();
587583 install_global_tables ();
588- registry<Policies...>::st.initialized = true ;
584+ registry<Policies...>::static_:: st.initialized = true ;
589585}
590586
591587#ifdef _MSC_VER
@@ -654,7 +650,7 @@ void registry<Policies...>::compiler<Options...>::augment_classes() {
654650 // The standard does not guarantee that there is exactly one
655651 // type_info object per class. However, it guarantees that the
656652 // type_index for a class has a unique value.
657- for (auto & cr : registry::st.classes ) {
653+ for (auto & cr : registry::static_:: st.classes ) {
658654 if constexpr (has_deferred_static_rtti) {
659655 static_cast <deferred_class_info&>(cr).resolve_type_ids ();
660656 }
@@ -691,7 +687,7 @@ void registry<Policies...>::compiler<Options...>::augment_classes() {
691687 // All known classes now have exactly one associated class_* in the
692688 // map. Collect the bases.
693689
694- for (auto & cr : registry::st.classes ) {
690+ for (auto & cr : registry::static_:: st.classes ) {
695691 auto rtc = class_map[rtti::type_index (cr.type )];
696692
697693 for (auto & base : range{cr.first_base , cr.last_base }) {
@@ -820,14 +816,14 @@ void registry<Policies...>::compiler<Options...>::augment_methods() {
820816 using namespace policies ;
821817 using namespace detail ;
822818
823- methods.resize (registry::st.methods .size ());
819+ methods.resize (registry::static_:: st.methods .size ());
824820
825821 ++tr << " Methods:\n " ;
826822 indent _ (tr);
827823
828824 auto meth_iter = methods.begin ();
829825
830- for (auto & meth_info : registry::st.methods ) {
826+ for (auto & meth_info : registry::static_:: st.methods ) {
831827 if constexpr (has_deferred_static_rtti) {
832828 static_cast <deferred_method_info&>(meth_info).resolve_type_ids ();
833829 }
@@ -1530,7 +1526,7 @@ void registry<Policies...>::compiler<Options...>::write_global_data() {
15301526
15311527 detail::initialize_policies<registry>::fn (*this , options);
15321528
1533- new_dispatch_data.swap (st.dispatch_data );
1529+ new_dispatch_data.swap (static_:: st.dispatch_data );
15341530}
15351531
15361532template <class ... Policies>
@@ -1749,14 +1745,7 @@ inline auto initialize(Options&&... options) {
17491745
17501746namespace detail {
17511747
1752- template <typename , class Policy , class ... Options>
1753- struct has_finalize_aux : std::false_type {};
1754-
1755- template <class Policy , class ... Options>
1756- struct has_finalize_aux <
1757- std::void_t <decltype (Policy::finalize(
1758- std::declval<std::tuple<Options...>>()))>,
1759- Policy, Options...> : std::true_type {};
1748+ BOOST_OPENMETHOD_DETAIL_HAS_STATIC_FN (has_finalize, finalize);
17601749
17611750} // namespace detail
17621751
@@ -1766,13 +1755,13 @@ auto registry<Policies...>::finalize(Options... opts) -> void {
17661755 std::tuple<Options...> options (opts...); // gcc-8 doesn't like CTAD here
17671756 mp11::mp_for_each<policy_list>([&options](auto policy) {
17681757 using fn = typename decltype (policy)::template fn<registry>;
1769- if constexpr (detail::has_finalize_aux< void , fn, Options...>::value ) {
1758+ if constexpr (detail::has_finalize< fn, const std::tuple< Options...>&> ) {
17701759 fn::finalize (options);
17711760 }
17721761 });
17731762
1774- st. dispatch_data .clear ();
1775- st. initialized = false ;
1763+ static_:: dispatch_data.clear ();
1764+ static_:: initialized = false ;
17761765}
17771766
17781767// ! Release resources held by registry.
0 commit comments