Skip to content

Commit c7bc263

Browse files
committed
improve odr_violation doc
1 parent f1819cd commit c7bc263

File tree

5 files changed

+18
-11
lines changed

5 files changed

+18
-11
lines changed

doc/modules/ROOT/pages/BOOST_OPENMETHOD.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ For each virtual argument `arg`, the dispatch mechanism calls
4545
1. If `result` is a `virtual_ptr`, get the pointer to the v-table from it.
4646
2. If `boost_openmethod_vptr` can be called with `result` and a `Registry*`,
4747
and it returns a `vptr_type`, call it.
48-
3. Call `Registry::rtti::dynamic_vptr(result)`.
48+
3. Call `Registry::vptr::dynamic_vptr(result)`.
4949

5050

5151
The macro creates an ordinary inline function in the current scope, with the
Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
1-
= xref:macros.adoc[Macro] BOOST_OPENMETHOD_ENABLE_RUNTIME_CHECKS
21

3-
Enables runtime checks in default_registry.
2+
## BOOST_OPENMETHOD_ENABLE_RUNTIME_CHECKS
43

5-
== Synopsis
4+
Enables runtime checks in cpp:default_registry[].
5+
6+
### Synopsis
67

78
May be defined by a program before including
89
`<boost/openmethod/default_registry.hpp>` to enable runtime checks.
910

10-
== Description
11+
### Description
1112

1213
See cpp:default_registry[] for details.

include/boost/openmethod/default_registry.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@ namespace boost::openmethod {
3737
//! including those pulled from libraries.
3838
struct default_registry
3939
: registry<
40-
policies::std_rtti, policies::vptr_vector,
40+
policies::std_rtti, policies
41+
::vptr_vector,
4142
policies::fast_perfect_hash, policies::default_error_handler,
4243
policies::stderr_output
4344
#ifdef BOOST_OPENMETHOD_ENABLE_RUNTIME_CHECKS

include/boost/openmethod/initialize.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1575,7 +1575,7 @@ inline auto initialize(Options&&... options) {
15751575
(std::is_base_of_v<detail::option_base, Options> && ...),
15761576
"invalid option type");
15771577

1578-
if (odr_check<Registry>::count > 1) {
1578+
if (detail::odr_check<Registry>::count > 1) {
15791579
// Multiple definitions of default_registry detected.
15801580
// This indicates an ODR violation.
15811581
// Signal a final_error using the error handler, then abort.

include/boost/openmethod/preamble.hpp

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ struct virtual_traits;
7575
//! Base class for all OpenMethod errors.
7676
struct openmethod_error {};
7777

78+
//! One Definition Rule violation.
79+
//!
80+
//! This error is raised if the definition of @ref default_registry is
81+
//! inconsistent across translation units, due to misuse of
82+
//! [BOOST_OPENMETHOD_ENABLE_RUNTIME_CHECKS](../BOOST_OPENMETHOD_ENABLE_RUNTIME_CHECKS.html).
7883
struct odr_violation : openmethod_error {
7984
//! Write a description of the error to a stream.
8085
//! @tparam Registry The registry containing this policy.
@@ -87,6 +92,8 @@ struct odr_violation : openmethod_error {
8792
}
8893
};
8994

95+
namespace detail {
96+
9097
template<class Registry>
9198
struct odr_check {
9299
static std::size_t count;
@@ -98,14 +105,14 @@ struct odr_check {
98105
}
99106
};
100107

101-
#ifndef BOOST_OPENMETHOD_IMPORT
102108
template<class Registry>
103109
std::size_t odr_check<Registry>::count;
104110

105111
template<class Registry>
106112
template<class R>
107113
std::size_t odr_check<Registry>::inc = count++;
108-
#endif
114+
115+
}
109116

110117
//! Registry not initialized
111118
struct not_initialized : openmethod_error {
@@ -1048,7 +1055,6 @@ class registry : detail::registry_base {
10481055
!std::is_same_v<policy<policies::indirect_vptr>, void>;
10491056
};
10501057

1051-
#ifndef BOOST_OPENMETHOD_IMPORT
10521058
template<class... Policies>
10531059
detail::class_catalog registry<Policies...>::classes;
10541060

@@ -1064,7 +1070,6 @@ bool registry<Policies...>::initialized;
10641070
template<class... Policies>
10651071
template<class Class>
10661072
vptr_type registry<Policies...>::static_vptr;
1067-
#endif
10681073

10691074
template<class... Policies>
10701075
void registry<Policies...>::require_initialized() {

0 commit comments

Comments
 (0)