Skip to content

Commit c338761

Browse files
committed
wip
1 parent 8e7fec7 commit c338761

File tree

3 files changed

+41
-64
lines changed

3 files changed

+41
-64
lines changed

doc/modules/ROOT/pages/reference.adoc

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
|===
88
| Name
99
| Description
10-
| xref::BOOST_OPENMETHOD.adoc[BOOST_OPENMETHOD]
10+
| xref:BOOST_OPENMETHOD.adoc[BOOST_OPENMETHOD]
1111
| declares a method
1212
| xref:BOOST_OPENMETHOD_CLASSES.adoc[BOOST_OPENMETHOD_CLASSES]
1313
| registers classes
@@ -81,10 +81,6 @@
8181
|
8282
| xref:reference:boost/openmethod/release_registry.adoc[`release_registry`]
8383
|
84-
| xref:reference:boost/openmethod/same_smart_ptr_aux-0f.adoc[`same_smart_ptr_aux`]
85-
|
86-
| xref:reference:boost/openmethod/same_smart_ptr_aux-02.adoc[`same_smart_ptr_aux<Class, Other, Registry, std::void_t<virtual_traits<Class, Registry>::rebind<Other::element_type>>>`]
87-
|
8884
| xref:reference:boost/openmethod/static_offset_error.adoc[`static_offset_error`]
8985
|
9086
| xref:reference:boost/openmethod/static_slot_error.adoc[`static_slot_error`]
@@ -98,8 +94,8 @@
9894
| xref:reference:boost/openmethod/virtual_.adoc[`virtual_`]
9995
|
10096
| xref:reference:boost/openmethod/virtual_ptr-0a.adoc[`virtual_ptr`]
101-
| A virtual_ptr.
102-
| xref:reference:boost/openmethod/virtual_ptr-02.adoc[`virtual_ptr<Class, Registry, void>`]
97+
| A wide pointer combining a pointer to an object and a pointer to its v‐table.
98+
| xref:reference:boost/openmethod/virtual_ptr-02.adoc[`virtual_ptr<Class, Registry>`]
10399
|
104100
| xref:reference:boost/openmethod/virtual_traits-0be.adoc[`virtual_traits`]
105101
|
@@ -162,7 +158,7 @@
162158
| Name
163159
| xref:reference:boost/openmethod/is_method.adoc[`is_method`]
164160
| xref:reference:boost/openmethod/is_polymorphic.adoc[`is_polymorphic`]
165-
| xref:reference:boost/openmethod/is_virtual_smart_ptr.adoc[`is_virtual_smart_ptr`]
161+
| xref:reference:boost/openmethod/is_smart_ptr.adoc[`is_smart_ptr`]
166162
| xref:reference:boost/openmethod/same_smart_ptr.adoc[`same_smart_ptr`]
167163
|===
168164

doc/tagfiles/boost-openmethod-doxygen.tag.xml

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,6 @@
2525
<class kind="class">boost::openmethod::openmethod_error</class>
2626
<class kind="class">boost::openmethod::registry</class>
2727
<class kind="class">boost::openmethod::release_registry</class>
28-
<class kind="class">boost::openmethod::same_smart_ptr_aux</class>
29-
<class kind="class">boost::openmethod::same_smart_ptr_aux</class>
3028
<class kind="class">boost::openmethod::static_offset_error</class>
3129
<class kind="class">boost::openmethod::static_slot_error</class>
3230
<class kind="class">boost::openmethod::static_stride_error</class>
@@ -47,7 +45,7 @@
4745
<class kind="class">boost::openmethod::final_virtual_ptr</class>
4846
<class kind="class">boost::openmethod::is_method</class>
4947
<class kind="class">boost::openmethod::is_polymorphic</class>
50-
<class kind="class">boost::openmethod::is_virtual_smart_ptr</class>
48+
<class kind="class">boost::openmethod::is_smart_ptr</class>
5149
<class kind="class">boost::openmethod::same_smart_ptr</class>
5250
<class kind="class">boost::openmethod::virtual_ptr</class>
5351
<class kind="class">boost::openmethod::virtual_ptr</class>
@@ -617,14 +615,6 @@
617615
<arglist>()</arglist>
618616
</member>
619617
</compound>
620-
<compound kind="class">
621-
<name>boost::openmethod::same_smart_ptr_aux</name>
622-
<filename>boost/openmethod/same_smart_ptr_aux-0f.adoc</filename>
623-
</compound>
624-
<compound kind="class">
625-
<name>boost::openmethod::same_smart_ptr_aux</name>
626-
<filename>boost/openmethod/same_smart_ptr_aux-02.adoc</filename>
627-
</compound>
628618
<compound kind="class">
629619
<name>boost::openmethod::static_offset_error</name>
630620
<filename>boost/openmethod/static_offset_error.adoc</filename>
@@ -937,8 +927,8 @@
937927
<filename>boost/openmethod/is_polymorphic.adoc</filename>
938928
</compound>
939929
<compound kind="class">
940-
<name>boost::openmethod::is_virtual_smart_ptr</name>
941-
<filename>boost/openmethod/is_virtual_smart_ptr.adoc</filename>
930+
<name>boost::openmethod::is_smart_ptr</name>
931+
<filename>boost/openmethod/is_smart_ptr.adoc</filename>
942932
</compound>
943933
<compound kind="class">
944934
<name>boost::openmethod::same_smart_ptr</name>

include/boost/openmethod/core.hpp

Lines changed: 34 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
namespace boost::openmethod {
3636

37-
template<class Registry, class Class>
37+
template<class Class, class Registry>
3838
constexpr bool is_polymorphic = Registry::rtti::template is_polymorphic<Class>;
3939

4040
template<
@@ -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+
579569
template<class Class, class Other, class Registry, typename = void>
580570
struct 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+
592587
template<class Class, class Other, class Registry>
593588
constexpr bool same_smart_ptr =
594-
same_smart_ptr_aux<Class, Other, Registry>::value;
589+
detail::same_smart_ptr_aux<Class, Other, Registry>::value;
595590

596591
template<class Class, class Registry>
597-
BOOST_OPENMETHOD_DETAIL_CXX20(requires(is_virtual_smart_ptr<Class, Registry>))
598592
class 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

Comments
 (0)