diff --git a/include/boost/openmethod/interop/boost_any.hpp b/include/boost/openmethod/interop/boost_any.hpp index 8a1a85cf..320c32a1 100644 --- a/include/boost/openmethod/interop/boost_any.hpp +++ b/include/boost/openmethod/interop/boost_any.hpp @@ -20,17 +20,18 @@ namespace boost::openmethod { namespace detail { -template -struct validate_method_parameter, Registry, void> : +template +struct validate_method_parameter< + virtual_, Registry, void> : std::true_type {}; -template -struct validate_method_parameter, Registry, void> : - std::true_type {}; +template +struct validate_method_parameter< + virtual_, Registry, void> : std::true_type {}; -template -struct validate_method_parameter, Registry, void> : - std::true_type {}; +template +struct validate_method_parameter< + virtual_, Registry, void> : std::true_type {}; // `boost::any::type()` yields a `std::type_info`, which is a valid `type_id` // only for an rtti policy that identifies classes by `&typeid(T)`. Under any diff --git a/include/boost/openmethod/interop/boost_type_erasure.hpp b/include/boost/openmethod/interop/boost_type_erasure.hpp index fea69760..a6f53f9b 100644 --- a/include/boost/openmethod/interop/boost_type_erasure.hpp +++ b/include/boost/openmethod/interop/boost_type_erasure.hpp @@ -94,35 +94,36 @@ constexpr bool te_pass_through = // placeholder of the parameter, so methods and overriders agree on a // single registered root per Concept. -template +template struct validate_method_parameter< - virtual_&>, Registry, void> : - std::true_type {}; + virtual_&, ParamRegistry>, Registry, + void> : std::true_type {}; -template +template struct validate_method_parameter< - virtual_&>, Registry, void> : + virtual_&, ParamRegistry>, Registry, void> : std::true_type {}; -template +template struct validate_method_parameter< - virtual_&&>, Registry, void> : + virtual_&&, ParamRegistry>, Registry, void> : std::true_type {}; -template +template struct validate_method_parameter< - virtual_>, Registry, void> : + virtual_, ParamRegistry>, Registry, void> : std::true_type {}; -template +template struct validate_method_parameter< - virtual_>, Registry, void> : - std::true_type {}; + virtual_, ParamRegistry>, Registry, + void> : std::true_type {}; -template +template struct validate_method_parameter< - virtual_>, Registry, - void> : std::false_type { + virtual_< + boost::type_erasure::any, ParamRegistry>, + Registry, void> : std::false_type { static_assert( false_t, "an owning type_erasure::any must be passed by reference"); }; diff --git a/include/boost/openmethod/interop/std_any.hpp b/include/boost/openmethod/interop/std_any.hpp index 315268c0..e5ee6247 100644 --- a/include/boost/openmethod/interop/std_any.hpp +++ b/include/boost/openmethod/interop/std_any.hpp @@ -20,17 +20,18 @@ namespace boost::openmethod { namespace detail { -template -struct validate_method_parameter, Registry, void> : +template +struct validate_method_parameter< + virtual_, Registry, void> : std::true_type {}; -template -struct validate_method_parameter, Registry, void> : - std::true_type {}; +template +struct validate_method_parameter< + virtual_, Registry, void> : std::true_type {}; -template -struct validate_method_parameter, Registry, void> : - std::true_type {}; +template +struct validate_method_parameter< + virtual_, Registry, void> : std::true_type {}; // `std::any::type()` yields a `std::type_info`, which is a valid `type_id` // only for an rtti policy that identifies classes by `&typeid(T)`. Under any diff --git a/test/test_dispatch_boost_any.cpp b/test/test_dispatch_boost_any.cpp index d2cbfcda..6f0d40de 100644 --- a/test/test_dispatch_boost_any.cpp +++ b/test/test_dispatch_boost_any.cpp @@ -32,6 +32,18 @@ static_assert(detail::has_vptr< virtual_traits, const boost::any&>); +// A registry spelled on the parameter names the same parameter as the default +// one, in each of the three forms. +static_assert(detail::validate_method_parameter< + virtual_, default_registry, + void>::value); +static_assert(detail::validate_method_parameter< + virtual_, default_registry, + void>::value); +static_assert(detail::validate_method_parameter< + virtual_, default_registry, + void>::value); + MAKE_CLASSES(); BOOST_OPENMETHOD(name, (virtual_), std::string); diff --git a/test/test_dispatch_std_any.cpp b/test/test_dispatch_std_any.cpp index 5500b483..b35c805e 100644 --- a/test/test_dispatch_std_any.cpp +++ b/test/test_dispatch_std_any.cpp @@ -32,6 +32,18 @@ static_assert( detail::has_vptr< virtual_traits, const std::any&>); +// A registry spelled on the parameter names the same parameter as the default +// one, in each of the three forms. +static_assert(detail::validate_method_parameter< + virtual_, default_registry, + void>::value); +static_assert( + detail::validate_method_parameter< + virtual_, default_registry, void>::value); +static_assert( + detail::validate_method_parameter< + virtual_, default_registry, void>::value); + MAKE_CLASSES(); BOOST_OPENMETHOD(name, (virtual_), std::string); diff --git a/test/test_dispatch_type_erasure.cpp b/test/test_dispatch_type_erasure.cpp index 83d82755..9554aa24 100644 --- a/test/test_dispatch_type_erasure.cpp +++ b/test/test_dispatch_type_erasure.cpp @@ -30,6 +30,24 @@ using erased_cref = te::any; static_assert(detail::has_vptr< virtual_traits, const erased&>); +// A registry spelled on the parameter names the same parameter as the default +// one, for the owning any by reference and for the any references. +static_assert(detail::validate_method_parameter< + virtual_, default_registry, + void>::value); +static_assert( + detail::validate_method_parameter< + virtual_, default_registry, void>::value); +static_assert( + detail::validate_method_parameter< + virtual_, default_registry, void>::value); +static_assert( + detail::validate_method_parameter< + virtual_, default_registry, void>::value); +static_assert(detail::validate_method_parameter< + virtual_, default_registry, + void>::value); + #define MAKE_CLASSES() \ struct Dog { \ std::string name; \