diff --git a/CMakeLists.txt b/CMakeLists.txt
index 121b895..7cc1363 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -49,5 +49,5 @@ endif()
if(BUILD_EXAMPLES)
message(STATUS "Building examples")
- add_subdirectory(examples)
+ add_subdirectory(example)
endif()
diff --git a/doc/BOOST_OPENMETHOD_DEFAULT_POLICY.adoc b/doc/BOOST_OPENMETHOD_DEFAULT_REGISTRY.adoc
similarity index 100%
rename from doc/BOOST_OPENMETHOD_DEFAULT_POLICY.adoc
rename to doc/BOOST_OPENMETHOD_DEFAULT_REGISTRY.adoc
diff --git a/doc/basic_policy.adoc b/doc/basic_policy.adoc
index 1d39301..374f58a 100644
--- a/doc/basic_policy.adoc
+++ b/doc/basic_policy.adoc
@@ -131,7 +131,7 @@ struct release;
```
A policy that contains facets `std_rtti`, `fast_perfect_hash`, `vptr_vector` and
-`vectored_error_handler`.
+`default_error_handler`.
#### debug
diff --git a/doc/core_api.adoc b/doc/core_api.adoc
index fb2eeee..7d44ff1 100644
--- a/doc/core_api.adoc
+++ b/doc/core_api.adoc
@@ -29,7 +29,7 @@ name can get tedious, so OpenMethod provides a macro for that:
[source,c++]
----
-include::{examplesdir}/core_api.cpp[tag=method]
+include::{exampledir}/core_api.cpp[tag=method]
----
NOTE: BOOST_OPENMETHOD and associated macros use `BOOST_OPENMETHOD_NAME` in
@@ -48,7 +48,7 @@ Overriders are ordinary functions, added to a method using the nested template
[source,c++]
----
-include::{examplesdir}/core_api.cpp[tag=poke_cat]
+include::{exampledir}/core_api.cpp[tag=poke_cat]
----
NOTE: `override` can register multiple overriders.
@@ -58,14 +58,14 @@ identifier. In the meantime, OpenMethod provides a small convenience macro:
[source,c++]
----
-include::{examplesdir}/core_api.cpp[tag=poke_dog]
+include::{exampledir}/core_api.cpp[tag=poke_dog]
----
`next` is available from the method's nested `next` template:
[source,c++]
----
-include::{examplesdir}/core_api.cpp[tag=poke_bulldog]
+include::{exampledir}/core_api.cpp[tag=poke_bulldog]
----
NOTE: Since the function uses itself as a template argument in its body, its
@@ -81,12 +81,12 @@ We register the classes with `use_classes`:
[source,c++]
----
-include::{examplesdir}/core_api.cpp[tag=use_classes]
+include::{exampledir}/core_api.cpp[tag=use_classes]
----
Finally, we call the method via the static member of the method class `fn`:
[source,c++]
----
-include::{examplesdir}/core_api.cpp[tag=main]
+include::{exampledir}/core_api.cpp[tag=main]
----
diff --git a/doc/custom_rtti.adoc b/doc/custom_rtti.adoc
index 04ff726..8775810 100644
--- a/doc/custom_rtti.adoc
+++ b/doc/custom_rtti.adoc
@@ -101,7 +101,7 @@ Here is the facet implementation:
[source,c++]
----
-include::{examplesdir}/custom_rtti.cpp[tag=facet]
+include::{exampledir}/custom_rtti.cpp[tag=facet]
----
This facet is quite minimal. It does not support virtual inheritance. It would
@@ -113,7 +113,7 @@ CRTP template:
[source,c++]
----
-include::{examplesdir}/custom_rtti.cpp[tag=policy]
+include::{exampledir}/custom_rtti.cpp[tag=policy]
----
Next, we include the main header. Because `BOOST_OPENMETHOD_DEFAULT_REGISTRY` is
@@ -121,7 +121,7 @@ defined, its value is used for the default policy. Then comes the usual example.
[source,c++]
----
-include::{examplesdir}/custom_rtti.cpp[tag=example]
+include::{exampledir}/custom_rtti.cpp[tag=example]
----
This programs works even if standard RTTI is disabled.
@@ -141,7 +141,7 @@ This time let's support virtual inheritance as well. First the domain classes:
[source,c++]
----
-include::{examplesdir}/deferred_custom_rtti.cpp[tag=classes]
+include::{exampledir}/deferred_custom_rtti.cpp[tag=classes]
// ditto for Dog
----
@@ -152,7 +152,7 @@ The rtti facet is the same, with one more function:
struct custom_rtti : bom::policies::rtti {
// as before
-include::{examplesdir}/deferred_custom_rtti.cpp[tag=dynamic_cast_ref]
+include::{exampledir}/deferred_custom_rtti.cpp[tag=dynamic_cast_ref]
};
----
diff --git a/doc/vectored_error_handler.adoc b/doc/default_error_handler.adoc
similarity index 82%
rename from doc/vectored_error_handler.adoc
rename to doc/default_error_handler.adoc
index 507b910..71fcae7 100644
--- a/doc/vectored_error_handler.adoc
+++ b/doc/default_error_handler.adoc
@@ -1,15 +1,15 @@
-## vectored_error_handler
+## default_error_handler
### Synopsis
-Defined in .
+Defined in .
```c++
namespace boost::openmethod::policies {
template
-class vectored_error_handler : public error_handler {
+class default_error_handler : public error_handler {
public:
using error_variant = std::variant<
openmethod_error, not_implemented_error, unknown_class_error,
@@ -27,7 +27,7 @@ class vectored_error_handler : public error_handler {
### Description
-`vectored_error_handler` is an implementation of `error_handler` that calls a
+`default_error_handler` is an implementation of `error_handler` that calls a
`std::function` to handle the error.
### Members
diff --git a/doc/dynamic_loading.adoc b/doc/dynamic_loading.adoc
index 0955101..47c843d 100644
--- a/doc/dynamic_loading.adoc
+++ b/doc/dynamic_loading.adoc
@@ -21,7 +21,7 @@ Here is an example:
[source,c++]
----
-include::{examplesdir}/dl.hpp[tag=header]
+include::{exampledir}/dl.hpp[tag=header]
----
NOTE: The policy must be passed to the method as well as the
@@ -35,7 +35,7 @@ We can now register the classes and and provide an overrider:
[source,c++]
----
-include::{examplesdir}/dl_main.cpp[tag=main]
+include::{exampledir}/dl_main.cpp[tag=main]
----
At this point we only have one overrider. Animals of all species ignore one
@@ -43,26 +43,26 @@ another:
[source,c++]
----
-include::{examplesdir}/dl_main.cpp[tag=before_dlopen]
+include::{exampledir}/dl_main.cpp[tag=before_dlopen]
----
Let's load a dynamic library containing this code:
[source,c++]
----
-include::{examplesdir}/dl_shared.cpp[tag=dl_shared]
+include::{exampledir}/dl_shared.cpp[tag=dl_shared]
----
Now back to `main`:
[source,c++]
----
-include::{examplesdir}/dl_main.cpp[tag=dlopen]
+include::{exampledir}/dl_main.cpp[tag=dlopen]
----
After unloading the library, we must call `initialize` again:
[source,c++]
----
-include::{examplesdir}/dl_main.cpp[tag=after_dlclose]
+include::{exampledir}/dl_main.cpp[tag=after_dlclose]
----
diff --git a/doc/error_handling.adoc b/doc/error_handling.adoc
index 9f1acf0..3337d6a 100644
--- a/doc/error_handling.adoc
+++ b/doc/error_handling.adoc
@@ -5,14 +5,14 @@ When an error is encountered, the program is terminated by a call to `abort`. If
the policy contains an `error_handler` facet, it provides an `error` member
function (or overloaded functions) to be called with an object identifying the
error. The `release` and `debug` policies implement the error facet with
-`vectored_error_handler`, which wraps the error object in a variant, and calls a
+`default_error_handler`, which wraps the error object in a variant, and calls a
handler via a `std::function`. By default, it prints a description of the error
to `stderr` in the `debug` policy, and does nothing in the `release` policy. The
handler can be set with `set_error_handler`:
[source,c++]
----
-include::{examplesdir}/vectored_error_handler.cpp[tag=example]
+include::{exampledir}/default_error_handler.cpp[tag=example]
----
Output:
@@ -29,7 +29,7 @@ We can also replace the `error_handler` facet with our own. For example:
[source,c++]
----
-include::{examplesdir}/throw_error_handler.cpp[tag=example]
+include::{exampledir}/throw_error_handler.cpp[tag=example]
----
[source,console]
diff --git a/doc/friendship.adoc b/doc/friendship.adoc
index ce7d91d..1590db2 100644
--- a/doc/friendship.adoc
+++ b/doc/friendship.adoc
@@ -17,7 +17,7 @@ We can thus grant friendship to all the overriders of `poke`:
[source,c++]
----
-include::{examplesdir}/friendship.cpp[tag=friend_all]
+include::{exampledir}/friendship.cpp[tag=friend_all]
----
Be aware, though, that the overriders of _any_ method called `poke` - with any
@@ -27,5 +27,5 @@ We can also befriend individual overriders:
[source,c++]
----
-include::{examplesdir}/friendship.cpp[tag=friend]
+include::{exampledir}/friendship.cpp[tag=friend]
----
diff --git a/doc/headers_namespaces.adoc b/doc/headers_namespaces.adoc
index f6cb59b..536d28e 100644
--- a/doc/headers_namespaces.adoc
+++ b/doc/headers_namespaces.adoc
@@ -11,7 +11,7 @@ Let's break the Animals example into headers and namespaces. First we put
[source,c++]
----
-include::{examplesdir}/headers_namespaces/animal.hpp[]
+include::{exampledir}/headers_namespaces/animal.hpp[]
----
`BOOST_OPENMETHOD` can be placed in a header file. It adds several constructs to
@@ -32,12 +32,12 @@ Next, let's implement the `Cat` class, and a derived class, `Cheetah`, in the
[source,c++]
----
-include::{examplesdir}/headers_namespaces/cat.hpp[]
+include::{exampledir}/headers_namespaces/cat.hpp[]
----
[source,c++]
----
-include::{examplesdir}/headers_namespaces/cat.cpp[]
+include::{exampledir}/headers_namespaces/cat.cpp[]
----
`BOOST_OPENMETHOD_CLASSES` should be placed in an implementation file. It can
@@ -83,7 +83,7 @@ the static function `fn` just yet.
[source,c++]
----
-include::{examplesdir}/headers_namespaces/dog.hpp[]
+include::{exampledir}/headers_namespaces/dog.hpp[]
----
Unlike function declarations, which can occur multiple times in a TU, an
@@ -101,7 +101,7 @@ Now we use `BOOST_OPENMETHOD_DEFINE_OVERRIDER` to define the overrider:
[source,c++]
----
-include::{examplesdir}/headers_namespaces/dog.cpp[]
+include::{exampledir}/headers_namespaces/dog.cpp[]
----
Let's look at the main program now. It derived `Bulldog` from `Dog` and provides
@@ -109,7 +109,7 @@ an overrider for the new class:
[source,c++]
----
-include::{examplesdir}/headers_namespaces/main.cpp[]
+include::{exampledir}/headers_namespaces/main.cpp[]
----
Again ADL plays a role: it helps the overrider (and `main`) to locate the `poke`
diff --git a/doc/hello_world.adoc b/doc/hello_world.adoc
index b78b17f..52e0755 100644
--- a/doc/hello_world.adoc
+++ b/doc/hello_world.adoc
@@ -6,7 +6,7 @@ functions:
[source,c++]
----
-include::{examplesdir}/virtual_func.cpp[tag=code]
+include::{exampledir}/virtual_func.cpp[tag=code]
----
We are going to rewrite this using open-methods.
@@ -15,7 +15,7 @@ First we remove the `poke` virtual functions from the domain classes:
[source,c++]
----
-include::{examplesdir}/hello_world.cpp[tag=domain_classes]
+include::{exampledir}/hello_world.cpp[tag=domain_classes]
----
Note that the Animal classes do not depend on iostreams anymore. This is a major
@@ -28,7 +28,7 @@ namespace.
[source,c++]
----
-include::{examplesdir}/hello_world.cpp[tag=method]
+include::{exampledir}/hello_world.cpp[tag=method]
----
This defines a free function called `poke`, which takes two arguments. The first
@@ -45,7 +45,7 @@ Let's add overriders for `Cat` and `Dog`:
[source,c++]
----
-include::{examplesdir}/hello_world.cpp[tag=overriders]
+include::{exampledir}/hello_world.cpp[tag=overriders]
----
`Bulldog::poke` calls the `poke` it overrides in its `Dog` base. The equivalent
@@ -55,7 +55,7 @@ been called if the overrider did not exist.
[source,c++]
----
-include::{examplesdir}/hello_world.cpp[tag=next]
+include::{exampledir}/hello_world.cpp[tag=next]
----
All classes involved in open-method calls need to be registered using the
@@ -63,7 +63,7 @@ All classes involved in open-method calls need to be registered using the
[source,c++]
----
-include::{examplesdir}/hello_world.cpp[tag=classes]
+include::{exampledir}/hello_world.cpp[tag=classes]
----
Classes can be registered incrementally, as long as all the direct bases of a
@@ -85,7 +85,7 @@ It builds the dispatch tables. Typically this is done in `main`:
[source,c++]
----
-include::{examplesdir}/hello_world.cpp[tag=main,indent=0]
+include::{exampledir}/hello_world.cpp[tag=main,indent=0]
----
We call `poke` like any ordinary function. We can pass it the animals by
@@ -94,5 +94,5 @@ reference, because `virtual_ptr` has a conversion constructor for that:
[source,c++]
----
-include::{examplesdir}/hello_world.cpp[tag=call]
+include::{exampledir}/hello_world.cpp[tag=call]
----
diff --git a/doc/html/index.html b/doc/html/index.html
index a0bb1ec..c7a1539 100644
--- a/doc/html/index.html
+++ b/doc/html/index.html
@@ -719,7 +719,7 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
Requirements
-vectored_error_handler
+default_error_handler
- Synopsis
- Description
@@ -733,37 +733,23 @@ body.book #toc,body.book #preamble,body.book h1.sect0,body.book .sect1>h2{page-b
- Members
-output
+basic_error_output
-
-basic_error_output
-
-trace
-
-
basic_trace_output
RestrictedOutputStream
@@ -984,6 +970,8 @@ namespace.
#include <iostream>
#include <boost/openmethod.hpp>
+using boost::openmethod::virtual_ptr;
+
BOOST_OPENMETHOD(
poke, // method name
(std::ostream&, virtual_ptr<Animal>), // method signature
@@ -1115,7 +1103,7 @@ BOOST_OPENMETHOD_OVERRIDE(
// Add definitions for specific pairs of animals.
BOOST_OPENMETHOD_OVERRIDE(
encounter,
- (std::ostream & os, virtual_ptr<Dog> dog1, virtual_ptr<Dog> dog2), void) {
+ (std::ostream & os, virtual_ptr<Dog> /*dog1*/, virtual_ptr<Dog> /*dog2*/), void) {
os << "Both wag tails";
}
@@ -1191,7 +1179,8 @@ struct Animal {
virtual ~Animal() = default;
};
-BOOST_OPENMETHOD(poke, (std::ostream&, virtual_ptr<Animal>), void);
+BOOST_OPENMETHOD(
+ poke, (std::ostream&, boost::openmethod::virtual_ptr<Animal>), void);
} // namespace animals
@@ -1220,7 +1209,7 @@ method (with the virtual_ decorators stripped).
-
Next, let’s implement the Cat class, and a derived class, Chhetah, in the
+
Next, let’s implement the Cat class, and a derived class, Cheetah, in the
felines namespace:
@@ -1256,6 +1245,8 @@ struct Cheetah : Cat {
#include "cat.hpp"
+using boost::openmethod::virtual_ptr;
+
namespace felines {
BOOST_OPENMETHOD_CLASSES(animals::Animal, Cat, Cheetah);
@@ -1355,7 +1346,7 @@ struct Dog : animals::Animal {
};
BOOST_OPENMETHOD_DECLARE_OVERRIDER(
- poke, (std::ostream & os, virtual_ptr<Dog> dog), void);
+ poke, (std::ostream & os, boost::openmethod::virtual_ptr<Dog> dog), void);
} // namespace canines
@@ -1390,7 +1381,7 @@ namespace canines {
BOOST_OPENMETHOD_CLASSES(animals::Animal, Dog);
BOOST_OPENMETHOD_DEFINE_OVERRIDER(
- poke, (std::ostream & os, virtual_ptr<Dog> dog), void) {
+ poke, (std::ostream & os, boost::openmethod::virtual_ptr<Dog> dog), void) {
os << dog->name << " barks";
}
@@ -1411,6 +1402,8 @@ an overrider for the new class:
#include "cat.hpp"
#include "dog.hpp"
+using boost::openmethod::virtual_ptr;
+
struct Bulldog : canines::Dog {
using Dog::Dog;
};
@@ -1482,7 +1475,7 @@ BOOST_OPENMETHOD_OVERRIDE(
…will fail to compile, with an error like "reference to
'poke_boost_openmethod_overriders' is ambiguous". That is because the overrider
-containers exist in both the canines and felides namespaces, with the same name.
+containers exist in both the canines and felines namespaces, with the same name.
Finally, the names passed as first arguments to the BOOST_OPENMETHOD and
@@ -1662,6 +1655,8 @@ stored in variables in place of plain pointers.
#include <boost/openmethod.hpp>
#include <boost/openmethod/compiler.hpp>
+using boost::openmethod::virtual_ptr;
+
struct Node {
virtual ~Node() {}
};
@@ -1799,8 +1794,7 @@ pointers:
#include <boost/openmethod/unique_ptr.hpp>
#include <boost/openmethod/compiler.hpp>
-using boost::openmethod::unique_virtual_ptr;
-using boost::openmethod::make_unique_virtual;
+using namespace boost::openmethod::aliases;
struct Node {
virtual ~Node() {}
@@ -1878,7 +1872,7 @@ using boost::openmethod::virtual_;
BOOST_OPENMETHOD(poke, (std::ostream&, virtual_<Animal&>), void);
-BOOST_OPENMETHOD_OVERRIDE(poke, (std::ostream & os, Cat& cat), void) {
+BOOST_OPENMETHOD_OVERRIDE(poke, (std::ostream & os, Cat& /*cat*/), void) {
os << "hiss";
}
@@ -1919,7 +1913,7 @@ native virtual functions:
class Animal {
protected:
boost::openmethod::vptr_type vptr;
- friend auto boost_openmethod_vptr(const Animal& a) {
+ friend auto boost_openmethod_vptr(const Animal& a, void*) {
return a.vptr;
}
@@ -1938,7 +1932,7 @@ class Cat : public Animal {
BOOST_OPENMETHOD(poke, (std::ostream&, virtual_<Animal&>), void);
-BOOST_OPENMETHOD_OVERRIDE(poke, (std::ostream & os, Cat& cat), void) {
+BOOST_OPENMETHOD_OVERRIDE(poke, (std::ostream & os, Cat& /*cat*/), void) {
os << "hiss\n";
}
@@ -1982,7 +1976,7 @@ class Cat : public Animal, public boost::openmethod::with_vptr<Cat, Animal>
BOOST_OPENMETHOD(poke, (std::ostream&, virtual_<Animal&>), void);
-BOOST_OPENMETHOD_OVERRIDE(poke, (std::ostream & os, Cat& cat), void) {
+BOOST_OPENMETHOD_OVERRIDE(poke, (std::ostream & os, Cat& /*cat*/), void) {
os << "hiss\n";
}
@@ -2039,7 +2033,8 @@ name can get tedious, so OpenMethod provides a macro for that:
class BOOST_OPENMETHOD_NAME(poke);
using poke = method<
- BOOST_OPENMETHOD_NAME(poke)(std::ostream&, virtual_ptr<Animal>), void>;
+ BOOST_OPENMETHOD_NAME(poke),
+ auto(std::ostream&, virtual_ptr<Animal>)->void>;
@@ -2070,7 +2065,7 @@ styles.
-
auto poke_cat(std::ostream& os, virtual_ptr<Cat> cat) {
+auto poke_cat(std::ostream& os, virtual_ptr<Cat> /*cat*/) {
os << "hiss";
}
@@ -2097,7 +2092,7 @@ identifier. In the meantime, OpenMethod provides a small convenience macro:
#include <boost/openmethod/macros.hpp>
-auto poke_dog(std::ostream& os, virtual_ptr<Dog> dog) {
+auto poke_dog(std::ostream& os, virtual_ptr<Dog> /*dog*/) {
os << "bark";
}
@@ -2226,7 +2221,7 @@ library: release and debug.
error_handler |
-vectored_error_handler |
+default_error_handler |
handles errors |
@@ -2303,7 +2298,7 @@ has no effect.
the policy contains an error_handler facet, it provides an error member
function (or overloaded functions) to be called with an object identifying the
error. The release and debug policies implement the error facet with
-vectored_error_handler, which wraps the error object in a variant, and calls a
+default_error_handler, which wraps the error object in a variant, and calls a
handler via a std::function. By default, it prints a description of the error
to stderr in the debug policy, and does nothing in the release policy. The
handler can be set with set_error_handler:
@@ -2316,6 +2311,8 @@ handler can be set with set_error_handler:
#include <boost/openmethod.hpp>
#include <boost/openmethod/compiler.hpp>
+using boost::openmethod::virtual_ptr;
+
struct Animal {
virtual ~Animal() = default;
};
@@ -2328,7 +2325,7 @@ BOOST_OPENMETHOD_CLASSES(Animal, Cat, Dog);
BOOST_OPENMETHOD(trick, (std::ostream&, virtual_ptr<Animal>), void);
BOOST_OPENMETHOD_OVERRIDE(
- trick, (std::ostream & os, virtual_ptr<Dog> dog), void) {
+ trick, (std::ostream & os, virtual_ptr<Dog> /*dog*/), void) {
os << "spin\n";
}
@@ -2336,12 +2333,11 @@ auto main() -> int {
namespace bom = boost::openmethod;
bom::initialize();
- bom::default_registry::set_error_handler(
- [](const bom::default_registry::error_variant& error) {
- if (std::holds_alternative<bom::not_implemented_error>(error)) {
- throw std::runtime_error("not implemented");
- }
- });
+ bom::default_registry::error_handler::set([](const auto& error) {
+ if (std::holds_alternative<bom::not_implemented_error>(error)) {
+ throw std::runtime_error("not implemented");
+ }
+ });
Cat felix;
Dog hector, snoopy;
@@ -2376,7 +2372,7 @@ spin
#include <iostream>
-#include <boost/openmethod/policies.hpp>
+#include <boost/openmethod/default_registry.hpp>
struct Animal {
virtual ~Animal() = default;
@@ -2388,28 +2384,33 @@ struct Dog : Animal {};
namespace bom = boost::openmethod;
struct throw_if_not_implemented : bom::policies::error_handler {
- static auto error(const bom::openmethod_error&) -> void {
- }
+ template<class Registry>
+ struct fn {
+ static auto error(const bom::openmethod_error&) -> void {
+ }
- static auto error(const bom::not_implemented_error& err) -> void {
- throw err;
- }
+ static auto error(const bom::not_implemented_error& err) -> void {
+ throw err;
+ }
+ };
};
-struct throwing_policy : bom::default_registry::fork<throwing_policy>::with<
- throw_if_not_implemented> {};
+struct custom_registry : bom::default_registry::with<throw_if_not_implemented> {
+};
-#define BOOST_OPENMETHOD_DEFAULT_REGISTRY throwing_policy
+#define BOOST_OPENMETHOD_DEFAULT_REGISTRY custom_registry
#include <boost/openmethod.hpp>
#include <boost/openmethod/compiler.hpp>
+using boost::openmethod::virtual_ptr;
+
BOOST_OPENMETHOD_CLASSES(Animal, Cat, Dog);
BOOST_OPENMETHOD(trick, (std::ostream&, virtual_ptr<Animal>), void);
BOOST_OPENMETHOD_OVERRIDE(
- trick, (std::ostream & os, virtual_ptr<Dog> dog), void) {
+ trick, (std::ostream & os, virtual_ptr<Dog> /*dog*/), void) {
os << "spin\n";
}
@@ -2423,7 +2424,7 @@ auto main() -> int {
for (auto animal : animals) {
try {
trick(std::cout, *animal);
- } catch (bom::not_implemented_error) {
+ } catch (bom::not_implemented_error&) {
std::cout << "not implemented\n";
}
}
@@ -2577,26 +2578,29 @@ define the custom RTTI facet. We must not include
namespace bom = boost::openmethod;
struct custom_rtti : bom::policies::rtti {
- template<class T>
- static constexpr bool is_polymorphic = std::is_base_of_v<Animal, T>;
+ template<class Registry>
+ struct fn : bom::policies::rtti::fn<Registry> {
+ template<class T>
+ static constexpr bool is_polymorphic = std::is_base_of_v<Animal, T>;
- template<typename T>
- static auto static_type() -> bom::type_id {
- if constexpr (is_polymorphic<T>) {
- return T::static_type;
- } else {
- return 0;
+ template<typename T>
+ static auto static_type() -> bom::type_id {
+ if constexpr (is_polymorphic<T>) {
+ return reinterpret_cast<bom::type_id>(T::static_type);
+ } else {
+ return nullptr;
+ }
}
- }
- template<typename T>
- static auto dynamic_type(const T& obj) -> bom::type_id {
- if constexpr (is_polymorphic<T>) {
- return obj.type;
- } else {
- return 0;
+ template<typename T>
+ static auto dynamic_type(const T& obj) -> bom::type_id {
+ if constexpr (is_polymorphic<T>) {
+ return reinterpret_cast<bom::type_id>(obj.type);
+ } else {
+ return nullptr;
+ }
}
- }
+ };
};
@@ -2611,9 +2615,8 @@ CRTP template:
-
struct custom_policy : bom::policies::basic_policy<
- custom_policy, custom_rtti,
- bom::policies::vptr_vector<custom_policy>> {};
+struct custom_policy : bom::registry<custom_rtti, bom::policies::vptr_vector> {
+};
#define BOOST_OPENMETHOD_DEFAULT_REGISTRY custom_policy
@@ -2629,15 +2632,17 @@ defined, its value is used for the default policy. Then comes the usual example.
#include <boost/openmethod.hpp>
#include <boost/openmethod/compiler.hpp>
+using boost::openmethod::virtual_ptr;
+
BOOST_OPENMETHOD(poke, (std::ostream&, virtual_ptr<Animal>), void);
BOOST_OPENMETHOD_OVERRIDE(
- poke, (std::ostream & os, virtual_ptr<Cat> cat), void) {
+ poke, (std::ostream & os, virtual_ptr<Cat> /*cat*/), void) {
os << "hiss";
}
BOOST_OPENMETHOD_OVERRIDE(
- poke, (std::ostream & os, virtual_ptr<Dog> dog), void) {
+ poke, (std::ostream & os, virtual_ptr<Dog> /*dog*/), void) {
os << "bark";
}
@@ -2742,16 +2747,16 @@ custom_type_info Cat::type_info;
struct custom_rtti : bom::policies::rtti {
// as before
- // to support virtual inheritance:
- template<typename Derived, typename Base>
- static auto dynamic_cast_ref(Base&& obj) -> Derived {
- using base_type = std::remove_reference_t<Base>;
- if constexpr (std::is_base_of_v<Animal, base_type>) {
- return *obj.template cast<std::remove_reference_t<Derived>>();
- } else {
- abort(); // not supported
+ // to support virtual inheritance:
+ template<typename Derived, typename Base>
+ static auto dynamic_cast_ref(Base&& obj) -> Derived {
+ using base_type = std::remove_reference_t<Base>;
+ if constexpr (std::is_base_of_v<Animal, base_type>) {
+ return *obj.template cast<std::remove_reference_t<Derived>>();
+ } else {
+ abort(); // not supported
+ }
}
- }
};
@@ -2823,9 +2828,8 @@ struct Carnivore : Animal {};
struct Cow : Herbivore {};
struct Wolf : Carnivore {};
-struct dynamic_policy
- : boost::openmethod::default_registry::fork<dynamic_policy>::with<
- boost::openmethod::policies::indirect_vptr> {};
+struct dynamic_policy : boost::openmethod::default_registry::with<
+ boost::openmethod::policies::indirect_vptr> {};
template<class Class>
using dyn_vptr = boost::openmethod::virtual_ptr<Class, dynamic_policy>;
@@ -3185,7 +3189,7 @@ etc).
-
<boost/openmethod/policies/vectored_error_handler.hpp>
+
<boost/openmethod/policies/default_error_handler.hpp>
Implements the error_handler facet by routing the error through a
std::function.
@@ -5156,7 +5160,7 @@ will not be used.
A policy that contains facets std_rtti, fast_perfect_hash, vptr_vector and
-vectored_error_handler.
+
default_error_handler.
@@ -5968,18 +5972,18 @@ termination by throwing an exception.
-
vectored_error_handler
+
default_error_handler
Synopsis
-
Defined in <boost/openmethod/policies/vectored_error_handler.hpp>.
+
Defined in <boost/openmethod/policies/default_error_handler.hpp>.
namespace boost::openmethod::policies {
template<class Policy>
-class vectored_error_handler : public error_handler {
+class default_error_handler : public error_handler {
public:
using error_variant = std::variant<
openmethod_error, not_implemented_error, unknown_class_error,
@@ -5999,7 +6003,7 @@ class vectored_error_handler : public error_handler {
Description
-
vectored_error_handler is an implementation of error_handler that calls a
+
default_error_handler is an implementation of error_handler that calls a
std::function to handle the error.
@@ -6076,47 +6080,9 @@ throws the error as an exception.
-
output
-
-
Synopsis
-
-
Defined in <boost/openmethod/policies/basic_policy.hpp>.
-
-
-
-
namespace boost::openmethod::policies {
-
-struct output : facet {};
-
-} // boost::openmethod::policies
-
-
-
-
-
Description
-
-
output is a facet that provides a stream for writing error messages.
-
-
-
-
Requirements
-
-
error_stream
-
-
-
static RestrictedOutputStream error_stream;
-
-
-
-
A static variable that satisfies the requirements of RestrictedOutputStream.
-
-
-
-
-
basic_error_output
-
Synopsis
+
Synopsis
Defined in <boost/openmethod/policies/basic_error_output.hpp>.
@@ -6134,7 +6100,7 @@ struct basic_error_output : output {
-
Description
+
Description
basic_error_output is an implementation of output that writes error
messages to a RestrictedOutputStream.
@@ -6143,7 +6109,7 @@ messages to a
RestrictedOutputStream.
Members
-
error_stream
+
error_stream
Stream error_stream;
@@ -6158,67 +6124,9 @@ it.
-
trace
-
-
Synopsis
-
-
Defined in <boost/openmethod/policies/basic_policy.hpp>.
-
-
-
-
namespace boost::openmethod::policies {
-
-struct trace : facet {};
-
-}
-
-
-
-
-
-
Description
-
-
trace is a facet used to write trace messages.
-
-
-
initialize can be directed to describe the classes and methods in a policy,
-and how the dispatch tables are built, by including this facet in the policy,
-and setting trace_enabled to true. The content and the format of the
-description is not documented, beyond the guarantee that it provides an
-exhaustive account of table construction, and may change between major, minor
-and patch versions.
-
-
-
-
Requirements
-
-
trace_enabled
-
-
-
static bool trace_enabled;
-
-
-
-
true if tracing is enabled, false otherwise.
-
-
-
-
trace_stream
-
-
-
static RestrictedOutputStream trace_stream;
-
-
-
-
A static variable that satisfies the requirements of RestrictedOutputStream.
-
-
-
-
-
basic_trace_output
-
Synopsis
+
Synopsis
Defined in <boost/openmethod/policies/basic_trace_output.hpp>.
@@ -6237,7 +6145,7 @@ struct basic_trace_output : trace {
-
Description
+
Description
basic_error_output is an implementation of trace that writes error
messages to a RestrictedOutputStream.
@@ -6246,7 +6154,7 @@ messages to a
RestrictedOutputStream.
Members
-
trace_enabled
+
trace_enabled
static bool trace_enabled;
@@ -6257,7 +6165,7 @@ messages to a
RestrictedOutputStream.
-
trace_stream
+
trace_stream
static Stream trace_stream;
@@ -6274,7 +6182,7 @@ open it.
RestrictedOutputStream
-
Description
+
Description
RestrictedOutputStream is a concept describing a std::ostream-like class with
a reduced set of operations.
@@ -6345,4 +6253,4 @@ Last updated 2025-03-08 15:24:21 -0500