3434
3535namespace boost ::openmethod {
3636
37- template <class Registry , class Class >
37+ template <class Class , class Registry >
3838constexpr bool is_polymorphic = Registry::rtti::template is_polymorphic<Class>;
3939
4040template <
@@ -280,24 +280,6 @@ struct use_classes {
280280 tuple_type tuple;
281281};
282282
283- namespace detail {
284-
285- template <typename , class , typename = void >
286- struct is_virtual_smart_ptr_aux : std::false_type {};
287-
288- template <typename Class, class Registry >
289- struct is_virtual_smart_ptr_aux <
290- Class, Registry,
291- std::void_t <
292- typename virtual_traits<Class, Registry>::template rebind<Class>>>
293- : std::true_type {};
294-
295- } // namespace detail
296-
297- template <typename T, class Registry >
298- constexpr bool is_virtual_smart_ptr =
299- detail::is_virtual_smart_ptr_aux<T, Registry>::value;
300-
301283// =============================================================================
302284// virtual_ptr
303285
@@ -374,7 +356,7 @@ inline auto final_virtual_ptr(Arg&& obj) {
374356 using Class = typename VirtualPtr::element_type;
375357 using Traits = virtual_traits<Arg, Registry>;
376358
377- if constexpr (Registry::runtime_checks && is_polymorphic<Registry, Class >) {
359+ if constexpr (Registry::runtime_checks && is_polymorphic<Class, Registry >) {
378360
379361 // check that dynamic type == static type
380362 auto static_type = Registry::rtti::template static_type<Class>();
@@ -448,7 +430,7 @@ class virtual_ptr {
448430 class Other ,
449431 typename = std::enable_if_t <
450432 std::is_constructible_v<Class*, Other*> &&
451- is_polymorphic<Registry, Class >>>
433+ is_polymorphic<Class, Registry >>>
452434 virtual_ptr (Other& other)
453435 : vp(detail::box_vptr<use_indirect_vptrs>(
454436 detail::acquire_vptr<Registry>(other))),
@@ -459,9 +441,8 @@ class virtual_ptr {
459441 class Other ,
460442 typename = std::enable_if_t <
461443 std::is_constructible_v<
462- Class*,
463- typename virtual_ptr<Other, Registry>::element_type*> &&
464- is_polymorphic<Registry, Class>>>
444+ Class*, typename virtual_ptr<Other, Registry>::element_type*> &&
445+ is_polymorphic<Class, Registry>>>
465446 virtual_ptr (Other* other)
466447 : vp(detail::box_vptr<use_indirect_vptrs>(
467448 detail::acquire_vptr<Registry>(*other))),
@@ -471,17 +452,15 @@ class virtual_ptr {
471452 template <
472453 class Other ,
473454 typename = std::enable_if_t <std::is_constructible_v<
474- Class*,
475- typename virtual_ptr<Other, Registry>::element_type*>>>
455+ Class*, typename virtual_ptr<Other, Registry>::element_type*>>>
476456 virtual_ptr (const virtual_ptr<Other, Registry>& other)
477457 : vp(other.vp), obj(other.get()) {
478458 }
479459
480460 template <
481461 class Other ,
482462 typename = std::enable_if_t <std::is_constructible_v<
483- Class*,
484- typename virtual_ptr<Other, Registry>::element_type*>>>
463+ Class*, typename virtual_ptr<Other, Registry>::element_type*>>>
485464 virtual_ptr (virtual_ptr<Other, Registry>& other)
486465 : vp(other.vp), obj(other.get()) {
487466 // Why is this needed? Consider this conversion conversion from
@@ -504,7 +483,7 @@ class virtual_ptr {
504483 class Other ,
505484 typename = std::enable_if_t <
506485 std::is_assignable_v<Class*, Other*> &&
507- is_polymorphic<Registry, Class >>>
486+ is_polymorphic<Class, Registry >>>
508487 virtual_ptr& operator =(Other& other) {
509488 obj = &other;
510489 vp = detail::box_vptr<use_indirect_vptrs>(
@@ -516,7 +495,7 @@ class virtual_ptr {
516495 class Other ,
517496 typename = std::enable_if_t <
518497 std::is_assignable_v<Class*, Other*> &&
519- is_polymorphic<Registry, Class >>>
498+ is_polymorphic<Class, Registry >>>
520499 virtual_ptr& operator =(Other* other) {
521500 obj = other;
522501 vp = detail::box_vptr<use_indirect_vptrs>(
@@ -527,8 +506,7 @@ class virtual_ptr {
527506 template <
528507 class Other ,
529508 typename = std::enable_if_t <std::is_assignable_v<
530- Class*,
531- typename virtual_ptr<Other, Registry>::element_type*>>>
509+ Class*, typename virtual_ptr<Other, Registry>::element_type*>>>
532510 virtual_ptr& operator =(const virtual_ptr<Other, Registry>& other) {
533511 obj = other.get ();
534512 vp = other.vp ;
@@ -576,6 +554,18 @@ class virtual_ptr {
576554 }
577555};
578556
557+ namespace detail {
558+
559+ template <typename , class , typename = void >
560+ struct is_smart_ptr_aux : std::false_type {};
561+
562+ template <typename Class, class Registry >
563+ struct is_smart_ptr_aux <
564+ Class, Registry,
565+ std::void_t <
566+ typename virtual_traits<Class, Registry>::template rebind<Class>>>
567+ : std::true_type {};
568+
579569template <class Class , class Other , class Registry , typename = void >
580570struct same_smart_ptr_aux : std::false_type {};
581571
@@ -589,17 +579,18 @@ struct same_smart_ptr_aux<
589579 typename virtual_traits<Class, Registry>::template rebind<
590580 typename Other::element_type>> {};
591581
582+ } // namespace detail
583+
584+ template <typename T, class Registry >
585+ constexpr bool is_smart_ptr = detail::is_smart_ptr_aux<T, Registry>::value;
586+
592587template <class Class , class Other , class Registry >
593588constexpr bool same_smart_ptr =
594- same_smart_ptr_aux<Class, Other, Registry>::value;
589+ detail:: same_smart_ptr_aux<Class, Other, Registry>::value;
595590
596591template <class Class , class Registry >
597- BOOST_OPENMETHOD_DETAIL_CXX20 (requires (is_virtual_smart_ptr<Class, Registry>))
598592class virtual_ptr <
599- Class, Registry,
600- BOOST_OPENMETHOD_DETAIL_CXX17 (
601- std::void_t <typename virtual_traits<Class, Registry>::template rebind<
602- Class>>) BOOST_OPENMETHOD_DETAIL_CXX20(void )> {
593+ Class, Registry, std::enable_if_t <is_smart_ptr<Class, Registry>>> {
603594
604595 template <class , class , typename >
605596 friend class virtual_ptr ;
@@ -637,7 +628,7 @@ class virtual_ptr<
637628 typename = std::enable_if_t <
638629 same_smart_ptr<Class, Other, Registry> &&
639630 std::is_constructible_v<Class, const Other&> &&
640- is_polymorphic<Registry, element_type >>>
631+ is_polymorphic<element_type, Registry >>>
641632 virtual_ptr (const Other& other)
642633 : vp(detail::box_vptr<use_indirect_vptrs>(
643634 other ? detail::acquire_vptr<Registry>(*other)
@@ -650,7 +641,7 @@ class virtual_ptr<
650641 typename = std::enable_if_t <
651642 same_smart_ptr<Class, Other, Registry> &&
652643 std::is_constructible_v<Class, Other&> &&
653- is_polymorphic<Registry, element_type >>>
644+ is_polymorphic<element_type, Registry >>>
654645 virtual_ptr (Other& other)
655646 : vp(detail::box_vptr<use_indirect_vptrs>(
656647 other ? detail::acquire_vptr<Registry>(*other)
@@ -669,7 +660,7 @@ class virtual_ptr<
669660 typename = std::enable_if_t <
670661 same_smart_ptr<Class, Other, Registry> &&
671662 std::is_constructible_v<Class, Other&&> &&
672- is_polymorphic<Registry, element_type >>>
663+ is_polymorphic<element_type, Registry >>>
673664 virtual_ptr (Other&& other)
674665 : vp(detail::box_vptr<use_indirect_vptrs>(
675666 other ? detail::acquire_vptr<Registry>(*other)
@@ -725,7 +716,7 @@ class virtual_ptr<
725716 typename = std::enable_if_t <
726717 same_smart_ptr<Class, Other, Registry> &&
727718 std::is_assignable_v<Class, const Other&> &&
728- is_polymorphic<Registry, element_type >>>
719+ is_polymorphic<element_type, Registry >>>
729720 virtual_ptr& operator =(const Other& other) {
730721 obj = other;
731722 vp = detail::box_vptr<use_indirect_vptrs>(
@@ -738,7 +729,7 @@ class virtual_ptr<
738729 typename = std::enable_if_t <
739730 same_smart_ptr<Class, Other, Registry> &&
740731 std::is_assignable_v<Class, Other&&> &&
741- is_polymorphic<Registry, element_type >>>
732+ is_polymorphic<element_type, Registry >>>
742733 virtual_ptr& operator =(Other&& other) {
743734 vp = detail::box_vptr<use_indirect_vptrs>(
744735 other ? detail::acquire_vptr<Registry>(*other) : detail::null_vptr);
0 commit comments