Skip to content

Commit 764c0b9

Browse files
committed
improve documentation
1 parent c64960d commit 764c0b9

File tree

7 files changed

+27
-25
lines changed

7 files changed

+27
-25
lines changed

doc/modules/ROOT/examples/virtual_ptr_alt/2/virtual_ptr_alt.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,15 @@ struct Node {
2222

2323
struct Variable : Node {
2424
Variable(int value) : v(value) {
25-
vptr = boost::openmethod::default_registry::static_vptr<Variable>;
25+
vptr = registry::static_vptr<Variable>;
2626
}
2727

2828
int v;
2929
};
3030

3131
struct Plus : Node {
3232
Plus(const Node& left, const Node& right) : left(left), right(right) {
33-
vptr = boost::openmethod::default_registry::static_vptr<Plus>;
33+
vptr = registry::static_vptr<Plus>;
3434
}
3535

3636
const Node& left;
@@ -39,7 +39,7 @@ struct Plus : Node {
3939

4040
struct Times : Node {
4141
Times(const Node& left, const Node& right) : left(left), right(right) {
42-
vptr = boost::openmethod::default_registry::static_vptr<Times>;
42+
vptr = registry::static_vptr<Times>;
4343
}
4444

4545
const Node& left;

doc/modules/ROOT/pages/basics.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
[#basics]
44

5-
An _open-method_ is a free-standing function that takes one or more _virtual_
5+
An _open-method_ is a free-standing function that has one or more _virtual_
66
_parameters_. When it is called, it forwards to an _overrider_ selected from a
77
set by examining the dynamic types of the virtual parameters.
88

doc/modules/ROOT/pages/error_handling.adoc

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,14 @@
11

22
[#error_handling]
33

4-
Errors can occur during `initialize`, or during method dispatch, if the
5-
method's registry contains the `runtime_checks` policy. If the registry
6-
contains an `error_handler` policy, its `error_handler::error` member
7-
function is called with a variant containing an error object, before terminating
8-
the program with a call to `abort`. `default_registry` contains such a
9-
policy: `default_error_handler`. It wraps the error object in a variant, and
10-
calls a handler via a `std::function`. By default, it prints a short description
11-
of the error to `stderr`, but this can be changed, for example, to throw an
12-
exception:
4+
Errors can occur during `initialize`, or during method dispatch, if the method's
5+
registry contains the `runtime_checks` policy. If the registry contains an
6+
`error_handler` policy, its `error_handler::error` member function is called
7+
with an error object, before terminating the program with a call to `abort`.
8+
`default_registry` contains such a policy: `default_error_handler`. It wraps the
9+
error object in a variant, and calls a handler via a `std::function`,
10+
initialized to a function that prints a short description of the error to
11+
`stderr`. The function can be changed, for example, to throw an exception:
1312

1413
[source,c++]
1514
----
@@ -43,11 +42,14 @@ spin
4342

4443
Stock policy `throw_error_handler` does this for all the error types:
4544

46-
```c++ namespace boost::openmethod::policies {
45+
```c++
46+
namespace boost::openmethod::policies {
4747

48-
struct throw_error_handler : error_handler { template<class Error>
49-
[[noreturn]] static auto error(const Error& error) -> void { throw
50-
error; }
48+
struct throw_error_handler : error_handler {
49+
template<class Error>
50+
[[noreturn]] static auto error(const Error& error) -> void {
51+
throw error;
52+
}
5153
};
5254

5355
} // namespace boost::openmethod::policies

doc/modules/ROOT/pages/friends.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
Note;; This section uses overrider containers, described in the
66
xref:headers.adoc[Headers] section.
77

8-
`friend` is a controversial feature. OpenMethod aims to interact well with
9-
all of C++, as much as feasible for a library, and leave the user the choice of
10-
using `friend`, or not.
8+
`friend` is a controversial feature. OpenMethod aims to interact well with all
9+
of C++, as much as feasible for a library, and leaves the choice of using
10+
`friend`, or not, to the user.
1111

1212
Let's consider yet another variation of the `pay` example. This time, we want to
1313
update a `balance` variable in a `Payroll` class, when an employee is paid. Thus

doc/modules/ROOT/pages/headers.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@ implementation files.
88

99
Let's use a payroll application as an example. We have two roles: `Employee` and
1010
`Salesman`, and a `pay` method that computes the monthly pay of an employee. We
11-
want to override and call `pay` from from multiple translation units, so we put
12-
it in a header:
11+
want to override and call `pay` from multiple translation units, so we put it in
12+
a header:
1313

1414
[source,c++]
1515
----

doc/modules/ROOT/pages/performance.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ than calling the equivalent virtual function, with an empty body and no other
6767
arguments. In most real programs, the overhead would be unnoticeable.
6868

6969
*However*, `call_via_ref` does two things: it constructs a `virtual_ptr<Node>`
70-
from a `const Node&`; and then it calls the method.
70+
from a `const Node&`, then it calls the method.
7171

7272
The construction of the `virtual_ptr` is the costly part. It performs a lookup
7373
in a perfect hash table, indexed by pointers to `std::type_info`, to find the

doc/modules/ROOT/pages/shared_libraries.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ include::{shared}/dynamic_main.cpp[tag=unload]
7979

8080
### Windows
8181

82-
If we try the aboveexample on Windows, the result is disappointing:
82+
If we try the example on Windows, the result is disappointing:
8383

8484
```
8585
Before loading the shared library.
@@ -98,7 +98,7 @@ they add overriders to _their_ copy of the method (the `method::fn` static
9898
variable for the given name and signature). They are ignored when the main
9999
program calls `initialize`.
100100

101-
Likewise, `BOOST_OPENMETHOD_CLASSES(Tiger, Carnivore);` in the DLL adds `Tiger`
101+
Likewise, `BOOST_OPENMETHOD_CLASSES(Tiger, Carnivore)` in the DLL adds `Tiger`
102102
to the DLL's copy of the registry. For the perspective of the program's
103103
registry, the class does not exist.
104104

0 commit comments

Comments
 (0)