Skip to content

Commit dbac5cb

Browse files
committed
basic_domain -> domain, doc
1 parent b72e077 commit dbac5cb

File tree

6 files changed

+67
-19
lines changed

6 files changed

+67
-19
lines changed

doc/basic_domain.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11

2-
## basic_domain
2+
## domain
33

44
### Synopsis
55

@@ -9,7 +9,7 @@ Defined in <boost/openmethod/policies/core.hpp>.
99
namespace boost::openmethod::policies {
1010

1111
template<class Policy>
12-
struct basic_domain {
12+
struct domain {
1313
template<class Class> static vptr_type static_vptr;
1414
// unspecified members
1515
};
@@ -19,7 +19,7 @@ struct basic_domain {
1919

2020
### Description
2121

22-
`basic_domain` is a registry of classes and methods registered in a _Policy_,
22+
`domain` is a registry of classes and methods registered in a _Policy_,
2323
and their dispatch tables.
2424

2525
### Members

doc/basic_policy.adoc

Lines changed: 44 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,13 @@
66
Defined in <boost/openmethod/policies/core.hpp>.
77

88
```c++
9-
namespace boost::openmethod::policies {
9+
namespace boost::openmethod {
10+
11+
namespace policies {
1012

1113
template<class Policy, class... Facets>
1214
struct basic_policy : virtual abstract_policy,
13-
virtual basic_domain<Policy>,
15+
virtual domain<Policy>,
1416
virtual Facets... {
1517
template<class Facet>
1618
static constexpr bool has_facet = /*unspecified*/;
@@ -28,7 +30,19 @@ struct basic_policy : virtual abstract_policy,
2830
using remove = /*unspecified*/;
2931
};
3032

31-
}
33+
struct release : basic_policy<release, ...> {};
34+
35+
struct debug : release::add<...> {};
36+
37+
} // policies
38+
39+
#ifdef NDEBUG
40+
using default_policy = policies::release;
41+
#else
42+
using default_policy = policies::debug;
43+
#endif
44+
45+
} // boost::openmethod
3246
```
3347

3448
### Description
@@ -101,3 +115,30 @@ It is not an error if _policy_ does not contain such a facet; in that case, the
101115
new policy contains the same facet as the original one.
102116

103117
The original policy and the new one share static variables.
118+
119+
### Non-members
120+
121+
#### release
122+
123+
```c++
124+
struct release;
125+
```
126+
127+
A policy that contains facet implementations `std_rtti`, `fast_perfect_hash`,
128+
`vptr_vector` and `vectored_error_handler`.
129+
130+
#### debug
131+
132+
```c++
133+
struct debug;
134+
```
135+
136+
The `release` policy with additional facet implementations `runtime_checks`,
137+
`basic_error_output` and basic_trace_output.
138+
139+
NOTE: `debug` extends `release` but it does not a fork it. Both policies use the
140+
same `domain`.
141+
142+
#### default_policy
143+
144+
An alias for `release` if `NDEBUG` is defined, and for `debug` otherwise.

doc/reference.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ include::virtual_ptr.adoc[]
2323
include::virtual_ptr_traits.adoc[]
2424

2525
include::abstract_policy.adoc[]
26-
include::basic_domain.adoc[]
26+
include::.adoc[]
2727
include::basic_policy.adoc[]
2828
include::rtti.adoc[]
2929
include::std_rtti.adoc[]

doc/type_hash.adoc

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,10 @@ static auto hash_type_id(type_id type) -> type_id;
7070
Returns `(type * M) >> S`, where `M` and `S` are factors found by
7171
`hash_initialize`.
7272

73+
If the policy has a `runtime_checks` facet, `hash_type_id` checks that `type`
74+
corresponds to a registered class. If not, it reports a `unknown_class_error`
75+
using the policy's error_handler facet, if present, then calls `abort`.
76+
7377
#### hash_initialize
7478

7579
```c++
@@ -79,3 +83,10 @@ auto hash_initialize(ForwardIterator first, ForwardIterator last) -> Report;
7983

8084
Finds factors `M` and `S` such that `hash_type_id` is a collision-free hash
8185
function.
86+
87+
If no such factors cannot be found, `hash_initialize` reports a
88+
`hash_search_error` using the policy's error_handler facet, if present, the
89+
calls `abort`.
90+
91+
If the policy has a `trace_output` facet, `hash_initialize` uses it to write a
92+
summary of the search.

include/boost/openmethod/policies/core.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,10 @@ struct debug;
6060
struct release;
6161

6262
// -----------------------------------------------------------------------------
63-
// basic_domain
63+
// domain
6464

6565
template<class Policy>
66-
struct basic_domain {
66+
struct domain {
6767
static detail::class_catalog classes;
6868
static detail::method_catalog methods;
6969
template<class Class>
@@ -72,17 +72,17 @@ struct basic_domain {
7272
};
7373

7474
template<class Policy>
75-
detail::class_catalog basic_domain<Policy>::classes;
75+
detail::class_catalog domain<Policy>::classes;
7676

7777
template<class Policy>
78-
detail::method_catalog basic_domain<Policy>::methods;
78+
detail::method_catalog domain<Policy>::methods;
7979

8080
template<class Policy>
8181
template<class Class>
82-
vptr_type basic_domain<Policy>::static_vptr;
82+
vptr_type domain<Policy>::static_vptr;
8383

8484
template<class Policy>
85-
std::vector<std::uintptr_t> basic_domain<Policy>::dispatch_data;
85+
std::vector<std::uintptr_t> domain<Policy>::dispatch_data;
8686

8787
template<typename Policy, class Facet>
8888
struct rebind_facet {
@@ -98,7 +98,7 @@ struct rebind_facet<NewPolicy, GenericFacet<OldPolicy, Args...>> {
9898

9999
template<class Policy, class... Facets>
100100
struct basic_policy : virtual abstract_policy,
101-
virtual basic_domain<Policy>,
101+
virtual domain<Policy>,
102102
virtual Facets... {
103103
using facets = detail::types<Facets...>;
104104

include/boost/openmethod/policies/fast_perfect_hash.hpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ class fast_perfect_hash : type_hash {
2020

2121
static type_id hash_mult;
2222
static std::size_t hash_shift;
23-
static std::size_t hash_span;
2423
static std::size_t hash_min;
2524
static std::size_t hash_max;
2625
static std::vector<type_id> control;
@@ -104,7 +103,6 @@ void fast_perfect_hash<Policy>::hash_initialize(
104103
bool found = false;
105104
std::size_t attempts = 0;
106105
buckets.resize(hash_size);
107-
hash_span = 0;
108106

109107
while (!found && attempts < 100000) {
110108
std::fill(buckets.begin(), buckets.end(), static_cast<type_id>(-1));
@@ -160,7 +158,7 @@ void fast_perfect_hash<Policy>::hash_initialize(
160158

161159
template<class Policy>
162160
void fast_perfect_hash<Policy>::check(std::size_t index, type_id type) {
163-
if (index >= hash_span || control[index] != type) {
161+
if (index < hash_min || index >= hash_max || control[index] != type) {
164162
if constexpr (Policy::template has_facet<error_handler>) {
165163
unknown_class_error error;
166164
error.type = type;
@@ -176,8 +174,6 @@ type_id fast_perfect_hash<Policy>::hash_mult;
176174
template<class Policy>
177175
std::size_t fast_perfect_hash<Policy>::hash_shift;
178176
template<class Policy>
179-
std::size_t fast_perfect_hash<Policy>::hash_span;
180-
template<class Policy>
181177
std::size_t fast_perfect_hash<Policy>::hash_min;
182178
template<class Policy>
183179
std::size_t fast_perfect_hash<Policy>::hash_max;

0 commit comments

Comments
 (0)