Skip to content

Commit 5777722

Browse files
committed
odrbefore renaming registry.hpp
1 parent 78afa46 commit 5777722

File tree

6 files changed

+62
-49
lines changed

6 files changed

+62
-49
lines changed

doc/modules/ROOT/nav.adoc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,5 +12,6 @@
1212
** xref:custom_rtti.adoc[Custom RTTI]
1313
** xref:dynamic_loading.adoc[Dynamic Loading]
1414
* Reference
15+
** xref:headers.adoc[Headers]
1516
** xref:macros.adoc[Macros]
16-
** xref:reference:boost/openmethod.adoc[boost::openmethod]
17+
** xref:reference:boost/openmethod.adoc[Namespace boost::openmethod]

doc/modules/ROOT/pages/BOOST_OPENMETHOD_DEFAULT_REGISTRY.adoc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,3 +27,6 @@ follows:
2727
1. Include headers under `boost/openmethod/policies/` as needed.
2828
2. Create a REGISTRY class, and set `BOOST_OPENMETHOD_DEFAULT_REGISTRY`.
2929
3. Include `<boost/openmethod/core.hpp>`.
30+
31+
Use this feature with caution, as it can easily lead to ODR violations if
32+
different translation units define different default registries.
Lines changed: 45 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,46 @@
11
[#headers]
2-
= xref:macros.adoc[Headers]
3-
:mrdocs:
4-
5-
[cols=2]
6-
|===
7-
| Name
8-
| Description
9-
| boost/openmethod.hpp
10-
| bla
11-
| boost/openmethod/macros.hpp
12-
| bla
13-
| boost/openmethod/core.hpp
14-
| bla
15-
| boost/openmethod/registry.hpp
16-
| bla
17-
| boost/openmethod/default_registry.hpp
18-
| bla
19-
| boost/openmethod/policies/default_error_handler.hpp
20-
| bla
21-
| boost/openmethod/policies/fast_perfect_hash.hpp
22-
| bla
23-
| boost/openmethod/policies/std_rtti.hpp
24-
| bla
25-
| boost/openmethod/policies/static_rtti.hpp
26-
| bla
27-
| boost/openmethod/policies/stderr_output.hpp
28-
| bla
29-
| boost/openmethod/policies/throw_error_handler.hpp
30-
| bla
31-
| boost/openmethod/policies/vptr_map.hpp
32-
| bla
33-
| boost/openmethod/policies/vptr_vector.hpp
34-
| bla
35-
| boost/openmethod/interop/std_shared_ptr.hpp
36-
| bla
37-
| boost/openmethod/interop/std_unique_ptr.hpp
38-
| bla
39-
|===
2+
= xref:headers.adoc[Headers]
3+
:toc:
4+
5+
### boost/openmethod.hpp
6+
7+
Convenience header. Includes `core.hpp` and `macros.hpp`. This is the header
8+
that most users should use.
9+
10+
### boost/openmethod/core.hpp
11+
12+
Defines all the core constructs of the library: `method`, `virtual_ptr`,
13+
`use_classes`, `virtual_traits`, etc. Does not define any public macros apart
14+
from `BOOST_OPENMETHOD_DEFAULT_REGISTRY`. Users with a severe allergy to macros
15+
should use this header.
16+
17+
### boost/openmethod/macros.hpp
18+
19+
Defines all the public macros of the library, such as `BOOST_OPENMETHOD`,
20+
`BOOST_OPENMETHOD_CLASSES`, etc. This header includes `core.hpp`.
21+
22+
### boost/openmethod/registry.hpp
23+
24+
Defines `registry` and stock policies.
25+
26+
### boost/openmethod/default_registry.hpp
27+
28+
### boost/openmethod/policies/default_error_handler.hpp
29+
30+
### boost/openmethod/policies/fast_perfect_hash.hpp
31+
32+
### boost/openmethod/policies/std_rtti.hpp
33+
34+
### boost/openmethod/policies/static_rtti.hpp
35+
36+
### boost/openmethod/policies/stderr_output.hpp
37+
38+
### boost/openmethod/policies/throw_error_handler.hpp
39+
40+
### boost/openmethod/policies/vptr_map.hpp
41+
42+
### boost/openmethod/policies/vptr_vector.hpp
43+
44+
### boost/openmethod/interop/std_shared_ptr.hpp
45+
46+
### boost/openmethod/interop/std_unique_ptr.hpp

include/boost/openmethod/core.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ constexpr bool has_vptr_fn = std::is_same_v<
507507

508508
template<class Registry, class ArgType>
509509
decltype(auto) acquire_vptr(const ArgType& arg) {
510-
Registry::check_initialized();
510+
Registry::require_initialized();
511511

512512
if constexpr (detail::has_vptr_fn<ArgType, Registry>) {
513513
return boost_openmethod_vptr(arg, static_cast<Registry*>(nullptr));
@@ -2407,7 +2407,7 @@ BOOST_FORCEINLINE
24072407
const ArgType&... args) const {
24082408
using namespace detail;
24092409

2410-
Registry::check_initialized();
2410+
Registry::require_initialized();
24112411

24122412
void (*pf)();
24132413

include/boost/openmethod/registry.hpp

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,9 @@ struct odr_violation : openmethod_error {
8181
//! @param stream The stream to write to.
8282
template<class Registry, class Stream>
8383
auto write(Stream& stream) const -> void {
84-
stream << "conflicting definitions of default_registry";
84+
stream << "conflicting definitions of ";
85+
Registry::rtti::type_name(
86+
Registry::rtti::template static_type<Registry>(), stream);
8587
}
8688
};
8789

@@ -818,25 +820,25 @@ class registry : detail::registry_base {
818820
inline static std::vector<detail::word> dispatch_data;
819821
inline static bool initialized;
820822

821-
protected:
822823
template<class... Options>
823824
struct compiler;
824825

825826
public:
827+
//! The type of this registry.
826828
using registry_type = registry;
827829

828830
template<typename, class...>
829831
friend struct detail::initialize_aux;
830832

831-
//! Checks if the registry is initialized.
833+
//! Check that the registry is initialized.
832834
//!
833-
//! Checks if `initialize` has been called for this registry, and report an
835+
//! Check if `initialize` has been called for this registry, and report an
834836
//! error if not.
835837
//!
836838
//! @par Errors
837839
//!
838840
//! @li @ref not_initialized: The registry is not initialized.
839-
static void check_initialized();
841+
static void require_initialized();
840842

841843
//! Releases the resources held by the registry.
842844
//!
@@ -858,7 +860,7 @@ class registry : detail::registry_base {
858860
template<class Class>
859861
inline static vptr_type static_vptr;
860862

861-
//! The list of policies selected in a registry.
863+
//! List of policies selected in a registry.
862864
//!
863865
//! `policy_list` is a Boost.Mp11 list containing the policies passed to the
864866
//! @ref registry clas template.
@@ -938,7 +940,7 @@ class registry : detail::registry_base {
938940
};
939941

940942
template<class... Policies>
941-
inline void registry<Policies...>::check_initialized() {
943+
inline void registry<Policies...>::require_initialized() {
942944
if constexpr (registry::has_runtime_checks) {
943945
if (!initialized) {
944946
if constexpr (registry::has_error_handler) {

test/test_runtime_errors.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ BOOST_AUTO_TEST_CASE(no_initialization) {
8787
}
8888
} else {
8989
try {
90-
registry::check_initialized();
90+
registry::require_initialized();
9191
} catch (not_initialized&) {
9292
BOOST_TEST_FAIL("should have not thrown in release variant");
9393
}

0 commit comments

Comments
 (0)