Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions include/boost/openmethod/interop/boost_any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ namespace boost::openmethod {

namespace detail {

template<class Registry>
struct validate_method_parameter<virtual_<const boost::any&>, Registry, void> :
template<class ParamRegistry, class Registry>
struct validate_method_parameter<
virtual_<const boost::any&, ParamRegistry>, Registry, void> :
std::true_type {};

template<class Registry>
struct validate_method_parameter<virtual_<boost::any&>, Registry, void> :
std::true_type {};
template<class ParamRegistry, class Registry>
struct validate_method_parameter<
virtual_<boost::any&, ParamRegistry>, Registry, void> : std::true_type {};

template<class Registry>
struct validate_method_parameter<virtual_<boost::any&&>, Registry, void> :
std::true_type {};
template<class ParamRegistry, class Registry>
struct validate_method_parameter<
virtual_<boost::any&&, ParamRegistry>, 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
Expand Down
31 changes: 16 additions & 15 deletions include/boost/openmethod/interop/boost_type_erasure.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<class C, typename T, class Registry>
template<class C, typename T, class ParamRegistry, class Registry>
struct validate_method_parameter<
virtual_<const boost::type_erasure::any<C, T>&>, Registry, void> :
std::true_type {};
virtual_<const boost::type_erasure::any<C, T>&, ParamRegistry>, Registry,
void> : std::true_type {};

template<class C, typename T, class Registry>
template<class C, typename T, class ParamRegistry, class Registry>
struct validate_method_parameter<
virtual_<boost::type_erasure::any<C, T>&>, Registry, void> :
virtual_<boost::type_erasure::any<C, T>&, ParamRegistry>, Registry, void> :
std::true_type {};

template<class C, typename T, class Registry>
template<class C, typename T, class ParamRegistry, class Registry>
struct validate_method_parameter<
virtual_<boost::type_erasure::any<C, T>&&>, Registry, void> :
virtual_<boost::type_erasure::any<C, T>&&, ParamRegistry>, Registry, void> :
std::true_type {};

template<class C, typename T, class Registry>
template<class C, typename T, class ParamRegistry, class Registry>
struct validate_method_parameter<
virtual_<boost::type_erasure::any<C, T&>>, Registry, void> :
virtual_<boost::type_erasure::any<C, T&>, ParamRegistry>, Registry, void> :
std::true_type {};

template<class C, typename T, class Registry>
template<class C, typename T, class ParamRegistry, class Registry>
struct validate_method_parameter<
virtual_<boost::type_erasure::any<C, const T&>>, Registry, void> :
std::true_type {};
virtual_<boost::type_erasure::any<C, const T&>, ParamRegistry>, Registry,
void> : std::true_type {};

template<class C, class Registry>
template<class C, class ParamRegistry, class Registry>
struct validate_method_parameter<
virtual_<boost::type_erasure::any<C, boost::type_erasure::_self>>, Registry,
void> : std::false_type {
virtual_<
boost::type_erasure::any<C, boost::type_erasure::_self>, ParamRegistry>,
Registry, void> : std::false_type {
static_assert(
false_t<C>, "an owning type_erasure::any must be passed by reference");
};
Expand Down
17 changes: 9 additions & 8 deletions include/boost/openmethod/interop/std_any.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,18 @@ namespace boost::openmethod {

namespace detail {

template<class Registry>
struct validate_method_parameter<virtual_<const std::any&>, Registry, void> :
template<class ParamRegistry, class Registry>
struct validate_method_parameter<
virtual_<const std::any&, ParamRegistry>, Registry, void> :
std::true_type {};

template<class Registry>
struct validate_method_parameter<virtual_<std::any&>, Registry, void> :
std::true_type {};
template<class ParamRegistry, class Registry>
struct validate_method_parameter<
virtual_<std::any&, ParamRegistry>, Registry, void> : std::true_type {};

template<class Registry>
struct validate_method_parameter<virtual_<std::any&&>, Registry, void> :
std::true_type {};
template<class ParamRegistry, class Registry>
struct validate_method_parameter<
virtual_<std::any&&, ParamRegistry>, 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
Expand Down
12 changes: 12 additions & 0 deletions test/test_dispatch_boost_any.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ static_assert(detail::has_vptr<
virtual_traits<const boost::any&, default_registry>,
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_<const boost::any&, default_registry>, default_registry,
void>::value);
static_assert(detail::validate_method_parameter<
virtual_<boost::any&, default_registry>, default_registry,
void>::value);
static_assert(detail::validate_method_parameter<
virtual_<boost::any&&, default_registry>, default_registry,
void>::value);

MAKE_CLASSES();

BOOST_OPENMETHOD(name, (virtual_<const boost::any&>), std::string);
Expand Down
12 changes: 12 additions & 0 deletions test/test_dispatch_std_any.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,18 @@ static_assert(
detail::has_vptr<
virtual_traits<const std::any&, default_registry>, 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_<const std::any&, default_registry>, default_registry,
void>::value);
static_assert(
detail::validate_method_parameter<
virtual_<std::any&, default_registry>, default_registry, void>::value);
static_assert(
detail::validate_method_parameter<
virtual_<std::any&&, default_registry>, default_registry, void>::value);

MAKE_CLASSES();

BOOST_OPENMETHOD(name, (virtual_<const std::any&>), std::string);
Expand Down
18 changes: 18 additions & 0 deletions test/test_dispatch_type_erasure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ using erased_cref = te::any<Concept, const te::_self&>;
static_assert(detail::has_vptr<
virtual_traits<const erased&, default_registry>, 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_<const erased&, default_registry>, default_registry,
void>::value);
static_assert(
detail::validate_method_parameter<
virtual_<erased&, default_registry>, default_registry, void>::value);
static_assert(
detail::validate_method_parameter<
virtual_<erased&&, default_registry>, default_registry, void>::value);
static_assert(
detail::validate_method_parameter<
virtual_<erased_ref, default_registry>, default_registry, void>::value);
static_assert(detail::validate_method_parameter<
virtual_<erased_cref, default_registry>, default_registry,
void>::value);

#define MAKE_CLASSES() \
struct Dog { \
std::string name; \
Expand Down
Loading