Skip to content

Commit

Permalink
more cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jll63 committed Sep 26, 2024
1 parent dcf3471 commit 9d2aa5c
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
14 changes: 7 additions & 7 deletions include/yorel/yomm2/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,8 +143,6 @@ struct requires_dynamic_cast_ref_aux<
B, D, std::void_t<decltype(static_cast<D>(std::declval<B>()))>>
: std::false_type {};

} // namespace detail

template<class B, class D>
constexpr bool requires_dynamic_cast =
detail::requires_dynamic_cast_ref_aux<B, D>::value;
Expand All @@ -158,6 +156,8 @@ auto optimal_cast(B&& obj) -> decltype(auto) {
}
}

} // namespace detail

// =============================================================================
// virtual_traits

Expand All @@ -174,7 +174,7 @@ struct virtual_traits<Policy, T&> {

template<typename D>
static auto cast(T& obj) -> D& {
return optimal_cast<Policy, D&>(obj);
return detail::optimal_cast<Policy, D&>(obj);
}
};

Expand All @@ -188,7 +188,7 @@ struct virtual_traits<Policy, T&&> {

template<typename D>
static auto cast(T&& obj) -> D&& {
return optimal_cast<Policy, D&&>(obj);
return detail::optimal_cast<Policy, D&&>(obj);
}
};

Expand Down Expand Up @@ -463,7 +463,7 @@ class virtual_ptr {
virtual_ptr_traits<Class, Policy>::template cast<Other>(obj);
} else {
result.obj =
&optimal_cast<Policy, typename Other::element_type&>(*obj);
&detail::optimal_cast<Policy, typename Other::element_type&>(*obj);
}

return result;
Expand Down Expand Up @@ -528,11 +528,11 @@ template<class Policy, typename P, typename Q>
using select_spec_polymorphic_type =
typename select_spec_polymorphic_type_aux<Policy, P, Q>::type;

template<class Policy, typename MethodArgList, typename SpecArgList>
template<class Policy, typename MethodParameters, typename OverriderParameters>
using spec_polymorphic_types = boost::mp11::mp_remove<
boost::mp11::mp_transform_q<
boost::mp11::mp_bind_front<select_spec_polymorphic_type, Policy>,
MethodArgList, SpecArgList>,
MethodParameters, OverriderParameters>,
void>;

template<class Container, typename = void>
Expand Down
6 changes: 3 additions & 3 deletions include/yorel/yomm2/virtual_shared_ptr.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ struct virtual_traits<Policy, const std::shared_ptr<T>&> {
static auto cast(const std::shared_ptr<T>& obj) {
check_cast<DERIVED>();

if constexpr (requires_dynamic_cast<T*, DERIVED>) {
if constexpr (detail::requires_dynamic_cast<T*, DERIVED>) {
return std::dynamic_pointer_cast<
typename shared_ptr_traits<DERIVED>::polymorphic_type>(obj);
} else {
Expand Down Expand Up @@ -82,7 +82,7 @@ struct virtual_traits<Policy, std::shared_ptr<T>> {
static auto cast(const std::shared_ptr<T>& obj) {
check_cast<DERIVED>();

if constexpr (requires_dynamic_cast<T*, DERIVED>) {
if constexpr (detail::requires_dynamic_cast<T*, DERIVED>) {
return std::dynamic_pointer_cast<
typename shared_ptr_traits<DERIVED>::polymorphic_type>(obj);
} else {
Expand All @@ -102,7 +102,7 @@ struct virtual_ptr_traits<std::shared_ptr<Class>, Policy> {
using OtherPtr = typename std::remove_reference_t<OtherPtrRef>;
using OtherClass = typename OtherPtr::box_type::element_type;

if constexpr (requires_dynamic_cast<Class&, OtherClass&>) {
if constexpr (detail::requires_dynamic_cast<Class&, OtherClass&>) {
return std::dynamic_pointer_cast<OtherClass>(ptr);
} else {
return std::static_pointer_cast<OtherClass>(ptr);
Expand Down

0 comments on commit 9d2aa5c

Please sign in to comment.