namespace boost::openmethod {
-template<class Policy = BOOST_OPENMETHOD_DEFAULT_POLICY>
+template<class Policy = BOOST_OPENMETHOD_DEFAULT_REGISTRY>
auto initialize() -> /*unspecified*/;
}
@@ -3789,7 +3789,7 @@ combination of virtual arguments.
namespace boost::openmethod {
-template<class Policy = BOOST_OPENMETHOD_DEFAULT_POLICY>
+template<class Policy = BOOST_OPENMETHOD_DEFAULT_REGISTRY>
auto finalize() -> void;
}
@@ -3866,7 +3866,7 @@ using vptr_type = const /*unspecified*/ *;
template<
typename Method, typename ReturnType,
- class Policy = BOOST_OPENMETHOD_DEFAULT_POLICY>
+ class Policy = BOOST_OPENMETHOD_DEFAULT_REGISTRY>
class method;
template<typename Name, typename... Parameters, typename ReturnType, class Policy>
@@ -4154,7 +4154,7 @@ or, if it is a polymorphic type, covariant with the method’s return type.<
namespace boost::openmethod {
-template<class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_POLICY>
+template<class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_REGISTRY>
class virtual_ptr {
public:
static constexpr bool is_smart_ptr = /* see below */;
@@ -4184,11 +4184,11 @@ class virtual_ptr {
};
template<class Class>
-virtual_ptr(Class&) -> virtual_ptr<Class, BOOST_OPENMETHOD_DEFAULT_POLICY>;
+virtual_ptr(Class&) -> virtual_ptr<Class, BOOST_OPENMETHOD_DEFAULT_REGISTRY>;
template<class Class>
inline auto final_virtual_ptr(Class& obj) -> virtual_ptr<
- Class, BOOST_OPENMETHOD_DEFAULT_POLICY>;
+ Class, BOOST_OPENMETHOD_DEFAULT_REGISTRY>;
template<class Policy, class Class>
inline auto final_virtual_ptr(Class& obj) -> virtual_ptr<Class, Policy>;
@@ -4213,11 +4213,11 @@ auto operator!=(
namespace boost::openmethod {
-template<class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_POLICY>
+template<class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_REGISTRY>
using shared_virtual_ptr = virtual_ptr<std::shared_ptr<Class>, Policy>;
template<
- class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_POLICY, typename... T>
+ class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_REGISTRY, typename... T>
inline auto make_shared_virtual(T&&... args)
-> shared_virtual_ptr<Class, Policy>;
@@ -4231,11 +4231,11 @@ inline auto make_shared_virtual(T&&... args)
namespace boost::openmethod {
-template<class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_POLICY>
+template<class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_REGISTRY>
using unique_virtual_ptr = virtual_ptr<std::unique_ptr<Class>, Policy>;
template<
- class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_POLICY, typename... T>
+ class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_REGISTRY, typename... T>
inline auto make_unique_virtual(T&&... args)
-> unique_virtual_ptr<Class, Policy>;
}
@@ -4435,7 +4435,7 @@ auto cast() const -> virtual_ptr<Other, Policy>;
template<class Class>
-virtual_ptr(Class&) -> virtual_ptr<Class, BOOST_OPENMETHOD_DEFAULT_POLICY>;
+virtual_ptr(Class&) -> virtual_ptr<Class, BOOST_OPENMETHOD_DEFAULT_REGISTRY>;
@@ -4446,7 +4446,7 @@ virtual_ptr(Class&) -> virtual_ptr<Class, BOOST_OPENMETHOD_DEFAULT_POL
virtual_shared_ptr
-template<class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_POLICY>
+template<class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_REGISTRY>
using virtual_shared_ptr = virtual_ptr<std::shared_ptr<Class>, Policy>;
@@ -4458,7 +4458,7 @@ using virtual_shared_ptr = virtual_ptr<std::shared_ptr<Class>, Policy&g
virtual_unique_ptr
-template<class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_POLICY>
+template<class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_REGISTRY>
using virtual_unique_ptr = virtual_ptr<std::unique_ptr<Class>, Policy>;
@@ -4481,7 +4481,7 @@ inline auto final_virtual_ptr(Class&& obj);
Utility functions, forwarding to virtual_ptr<Class, Policy>::final.
-If Policy is not specified, BOOST_OPENMETHOD_DEFAULT_POLICY is used.
+If Policy is not specified, BOOST_OPENMETHOD_DEFAULT_REGISTRY is used.
@@ -4489,7 +4489,7 @@ inline auto final_virtual_ptr(Class&& obj);
template<
- class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_POLICY, typename... T>
+ class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_REGISTRY, typename... T>
inline auto make_shared_virtual(T&&... args)
-> shared_virtual_ptr<Class, Policy>;
@@ -4505,7 +4505,7 @@ the class, which needs not be polymorphic.
template<
- class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_POLICY, typename... T>
+ class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_REGISTRY, typename... T>
inline auto make_unique_virtual(T&&... args)
-> unique_virtual_ptr<Class, Policy>;
@@ -4703,7 +4703,7 @@ example, virtual_traits<std::shared_ptr<T>, Policy>::rebind<
namespace boost::openmethod {
-template<class... Classes, class Policy = BOOST_OPENMETHOD_DEFAULT_POLICY>
+template<class... Classes, class Policy = BOOST_OPENMETHOD_DEFAULT_REGISTRY>
struct use_classes {
use_classes();
~use_classes();
@@ -4744,7 +4744,7 @@ a class lattice that contains repeated inheritance.
The default value for Policy is the value of
-BOOST_OPENMETHOD_DEFAULT_POLICY when <boost/openmethod/core.hpp> is
+BOOST_OPENMETHOD_DEFAULT_REGISTRY when <boost/openmethod/core.hpp> is
included. Subsequently changing it has no retroactive effect.
@@ -4817,7 +4817,7 @@ more information.
namespace boost::openmethod {
-template<class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_POLICY>
+template<class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_REGISTRY>
class with_vptr {
protected:
with_vptr();
@@ -4982,7 +4982,7 @@ namespace policies {
template<class Policy, class... Facets>
struct basic_policy : abstract_policy, domain<Policy>, Facets... {
template<class Facet>
- static constexpr bool has_facet = /*unspecified*/;
+ static constexpr bool has = /*unspecified*/;
template<class NewPolicy>
using fork = /*unspecified*/;
@@ -5001,9 +5001,9 @@ struct debug : release::add<...> {};
} // policies
#ifdef NDEBUG
-using default_policy = policies::release;
+using default_registry = policies::release;
#else
-using default_policy = policies::debug;
+using default_registry = policies::debug;
#endif
} // boost::openmethod
@@ -5033,11 +5033,11 @@ allow distinct policies to have distinct sets of static variables.
Members
-has_facet
+has
template<class Facet>
-static constexpr bool has_facet;
+static constexpr bool has;
@@ -5088,8 +5088,8 @@ that do not have the same category as Facets.
-
-
struct dyn_load : default_policy::fork<dyn_load>::with<indirect_vptr> {};
-Creates a policy just like default_policy, with an extra indirection added
+
struct dyn_load : default_registry::fork<dyn_load>::with<indirect_vptr> {};
+Creates a policy just like default_registry, with an extra indirection added
to the v-table pointers. This policy is suitable for use with dynamic loading.
-
@@ -5098,8 +5098,8 @@ Creates a policy just like
release, except that it prints a diagnos
message before terminating with abort().
-
-
struct default_throw : default_policy::fork<default_throw>::with<throw_error_handler> {};
-Creates a policy just like default_policy, except that it reports errors by
+
struct default_throw : default_registry::fork<default_throw>::with<throw_error_handler> {};
+Creates a policy just like default_registry, except that it reports errors by
throwing exceptions, instead of calling a std::function like the default
error handler does.
@@ -5133,8 +5133,8 @@ the same category as Facets.
-
-
struct use_map : default_policy::fork<use_map>::with<vptr_map<use_map>>::without<type_hash> {};
-Creates a policy just like default_policy, except that it stores pointers to
+
struct use_map : default_registry::fork<use_map>::with<vptr_map<use_map>>::without<type_hash> {};
+Creates a policy just like default_registry, except that it stores pointers to
v-table in a std::unordered_map. Also removes the hash function, since it
will not be used.
@@ -5185,7 +5185,7 @@ same domain.
-default_policy
+default_registry
An alias for release if NDEBUG is defined, and for debug otherwise.
@@ -5891,7 +5891,7 @@ function.
calls abort.
-If the policy has a trace_output facet, hash_initialize uses it to write a
+
If the policy has a trace facet, hash_initialize uses it to write a
summary of the search.
@@ -6015,7 +6015,7 @@ static auto error(const Error& error) -> void;
Calls the function last set via set_error_handler or, if it was never called,
-and if Policy contains an error_output facet, use it to print a description
+and if Policy contains an output facet, use it to print a description
of error.
@@ -6076,7 +6076,7 @@ throws the error as an exception.
-error_output
+output
Synopsis
@@ -6086,7 +6086,7 @@ throws the error as an exception.
namespace boost::openmethod::policies {
-struct error_output : facet {};
+struct output : facet {};
} // boost::openmethod::policies
@@ -6095,7 +6095,7 @@ struct error_output : facet {};
Description
-error_output is a facet that provides a stream for writing error messages.
+output is a facet that provides a stream for writing error messages.
@@ -6125,7 +6125,7 @@ struct error_output : facet {};
namespace boost::openmethod::policies {
template<class Policy, typename Stream = /*unspecified*/>
-struct basic_error_output : error_output {
+struct basic_error_output : output {
static Stream error_stream;
};
@@ -6136,7 +6136,7 @@ struct basic_error_output : error_output {
Description
-basic_error_output is an implementation of error_output that writes error
+
basic_error_output is an implementation of output that writes error
messages to a RestrictedOutputStream.
@@ -6158,7 +6158,7 @@ it.
-trace_output
+trace
Synopsis
@@ -6168,7 +6168,7 @@ it.
namespace boost::openmethod::policies {
-struct trace_output : facet {};
+struct trace : facet {};
}
@@ -6178,7 +6178,7 @@ struct trace_output : facet {};
Description
-trace_output is a facet used to write trace messages.
+trace is a facet used to write trace messages.
initialize can be directed to describe the classes and methods in a policy,
@@ -6227,7 +6227,7 @@ and patch versions.
namespace boost::openmethod::policies {
template<class Policy, typename Stream = /*unspecified*/>
-struct basic_trace_output : trace_output {
+struct basic_trace_output : trace {
static bool trace_enabled;
static Stream trace_stream;
};
@@ -6239,7 +6239,7 @@ struct basic_trace_output : trace_output {
Description
-basic_error_output is an implementation of trace_output that writes error
+
basic_error_output is an implementation of trace that writes error
messages to a RestrictedOutputStream.
diff --git a/doc/initialize.adoc b/doc/initialize.adoc
index 021216e..9489635 100644
--- a/doc/initialize.adoc
+++ b/doc/initialize.adoc
@@ -8,7 +8,7 @@ Defined in ``.
```c++
namespace boost::openmethod {
-template
+template
auto initialize() -> /*unspecified*/;
}
@@ -42,7 +42,7 @@ Defined in ``.
```c++
namespace boost::openmethod {
-template
+template
auto finalize() -> void;
}
diff --git a/doc/method.adoc b/doc/method.adoc
index 6f36da6..5f66cb9 100644
--- a/doc/method.adoc
+++ b/doc/method.adoc
@@ -9,7 +9,7 @@ namespace boost::openmethod {
template<
typename Method, typename ReturnType,
- class Policy = BOOST_OPENMETHOD_DEFAULT_POLICY>
+ class Policy = BOOST_OPENMETHOD_DEFAULT_REGISTRY>
class method;
template
diff --git a/doc/overview.adoc b/doc/overview.adoc
index f7bff48..3fc4236 100644
--- a/doc/overview.adoc
+++ b/doc/overview.adoc
@@ -24,7 +24,7 @@ the `include` directory to your project's include path.
#### boost::openmethod
The library's main namespace. Contains `method`, `virtual_ptr` and
-`virtual_ptr_traits`, `use_classes`, the `default_policy`, etc.
+`virtual_ptr_traits`, `use_classes`, the `default_registry`, etc.
#### boost::openmethod::policies
@@ -37,10 +37,10 @@ Contains the policy framework.
The library's main header. Provides `method`, `virtual_ptr` and
`virtual_ptr_traits`, `use_classes`, the default policy, etc.
-If `BOOST_OPENMETHOD_DEFAULT_POLICY` is defined before including this header,
+If `BOOST_OPENMETHOD_DEFAULT_REGISTRY` is defined before including this header,
its value is used as the default value for the `Policy` template parameter
-throughout the code. Otherwise, `boost::openmethod::default_policy` is used.
-Setting `BOOST_OPENMETHOD_DEFAULT_POLICY` after including the core header has no
+throughout the code. Otherwise, `boost::openmethod::default_registry` is used.
+Setting `BOOST_OPENMETHOD_DEFAULT_REGISTRY` after including the core header has no
effect.
####
@@ -91,7 +91,7 @@ manner as native virtual functions.
####
Provides the `debug` and `release` policies in the `boost::openmethod::policies`
-namespace, and `default_policy` in the `boost::openmethod` namespace, which is
+namespace, and `default_registry` in the `boost::openmethod` namespace, which is
an alias to either `debug` or `release`, depending on the value of the
preprocessor symbol `NDEBUG`.
@@ -135,10 +135,10 @@ Implements the `error_handler` facet by throwing an exception.
####
-Implements the `error_output` facet using a lightweight version of
+Implements the `output` facet using a lightweight version of
`std::ostream`.
####
-Implements the `trace_output` facet using a lightweight version of
+Implements the `trace` facet using a lightweight version of
`std::ostream`.
diff --git a/doc/policies.adoc b/doc/policies.adoc
index 47fe486..b5c5859 100644
--- a/doc/policies.adoc
+++ b/doc/policies.adoc
@@ -53,11 +53,11 @@ The `debug` policy contains the same facets as `release`, plus a few more:
| (itself)
| enables runtime checks
-| error_output
+| output
| basic_error_output
| prints error descriptions to `stderr`
-| trace_output
+| trace
| basic_trace_output
| enables `initialize` to print information about dispatch table construction to `stderr`
@@ -81,11 +81,11 @@ struct debug : release::fork::with<
}
----
-`boost::openmethod::default_policy` is an alias to `release` or `debug`,
+`boost::openmethod::default_registry` is an alias to `release` or `debug`,
depending on the value of preprocessor symbols `NDEBUG`. The default policy can
be overriden by defining the macroprocessor symbol
-`BOOST_OPENMETHOD_DEFAULT_POLICY` _before_ including
+`BOOST_OPENMETHOD_DEFAULT_REGISTRY` _before_ including
``. The value of the symbol is used as a default
template parameter for `use_classes`, `method`, `virtual_ptr`, and others. Once
-the `core` header has been included, changing `BOOST_OPENMETHOD_DEFAULT_POLICY`
+the `core` header has been included, changing `BOOST_OPENMETHOD_DEFAULT_REGISTRY`
has no effect.
diff --git a/doc/reference.adoc b/doc/reference.adoc
index f6f75ec..8e96b62 100644
--- a/doc/reference.adoc
+++ b/doc/reference.adoc
@@ -17,7 +17,7 @@ include::BOOST_OPENMETHOD_GUIDE.adoc[]
include::BOOST_OPENMETHOD_OVERRIDERS.adoc[]
include::BOOST_OPENMETHOD_REGISTER.adoc[]
include::BOOST_OPENMETHOD_CLASSES.adoc[]
-include::BOOST_OPENMETHOD_DEFAULT_POLICY.adoc[]
+include::BOOST_OPENMETHOD_DEFAULT_REGISTRY.adoc[]
include::initialize.adoc[]
include::typedefs.adoc[]
@@ -43,8 +43,8 @@ include::type_hash.adoc[]
include::error_handler.adoc[]
include::vectored_error_handler.adoc[]
include::throw_error_handler.adoc[]
-include::error_output.adoc[]
+include::output.adoc[]
include::basic_error_output.adoc[]
-include::trace_output.adoc[]
+include::trace.adoc[]
include::basic_trace_output.adoc[]
include::restricted_output_stream.adoc[]
diff --git a/doc/trace_output.adoc b/doc/trace_output.adoc
index cbd88fa..45dfd08 100644
--- a/doc/trace_output.adoc
+++ b/doc/trace_output.adoc
@@ -1,5 +1,5 @@
-## trace_output
+## trace
### Synopsis
@@ -8,7 +8,7 @@ Defined in .
```c++
namespace boost::openmethod::policies {
-struct trace_output : facet {};
+struct trace : facet {};
}
```
@@ -17,7 +17,7 @@ struct trace_output : facet {};
### Description
-`trace_output` is a facet used to write trace messages.
+`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,
diff --git a/doc/type_hash.adoc b/doc/type_hash.adoc
index d95c637..a04badc 100644
--- a/doc/type_hash.adoc
+++ b/doc/type_hash.adoc
@@ -95,5 +95,5 @@ If no such factors cannot be found, `hash_initialize` reports a
`hash_search_error` using the policy's error_handler facet, if present, the
calls `abort`.
-If the policy has a `trace_output` facet, `hash_initialize` uses it to write a
+If the policy has a `trace` facet, `hash_initialize` uses it to write a
summary of the search.
diff --git a/doc/use_classes.adoc b/doc/use_classes.adoc
index eb3f2cb..adebb26 100644
--- a/doc/use_classes.adoc
+++ b/doc/use_classes.adoc
@@ -8,7 +8,7 @@ Defined in .
```c++
namespace boost::openmethod {
-template
+template
struct use_classes {
use_classes();
~use_classes();
@@ -36,7 +36,7 @@ Virtual and multiple inheritance are supported, as long as they don't result in
a class lattice that contains repeated inheritance.
NOTE: The default value for `Policy` is the value of
-`BOOST_OPENMETHOD_DEFAULT_POLICY` when `` is
+`BOOST_OPENMETHOD_DEFAULT_REGISTRY` when `` is
included. Subsequently changing it has no retroactive effect.
### Members
diff --git a/doc/vectored_error_handler.adoc b/doc/vectored_error_handler.adoc
index 10b5625..507b910 100644
--- a/doc/vectored_error_handler.adoc
+++ b/doc/vectored_error_handler.adoc
@@ -40,7 +40,7 @@ static auto error(const Error& error) -> void;
```
Calls the function last set via `set_error_handler` or, if it was never called,
-and if _Policy_ contains an `error_output` facet, use it to print a description
+and if _Policy_ contains an `output` facet, use it to print a description
of `error`.
#### error
diff --git a/doc/virtual_ptr.adoc b/doc/virtual_ptr.adoc
index 056d605..5f1f17d 100644
--- a/doc/virtual_ptr.adoc
+++ b/doc/virtual_ptr.adoc
@@ -11,7 +11,7 @@
```c++
namespace boost::openmethod {
-template
+template
class virtual_ptr {
public:
static constexpr bool is_smart_ptr = /* see below */;
@@ -41,11 +41,11 @@ class virtual_ptr {
};
template
-virtual_ptr(Class&) -> virtual_ptr;
+virtual_ptr(Class&) -> virtual_ptr;
template
inline auto final_virtual_ptr(Class& obj) -> virtual_ptr<
- Class, BOOST_OPENMETHOD_DEFAULT_POLICY>;
+ Class, BOOST_OPENMETHOD_DEFAULT_REGISTRY>;
template
inline auto final_virtual_ptr(Class& obj) -> virtual_ptr;
@@ -68,11 +68,11 @@ Defined in ``:
```c++
namespace boost::openmethod {
-template
+template
using shared_virtual_ptr = virtual_ptr, Policy>;
template<
- class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_POLICY, typename... T>
+ class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_REGISTRY, typename... T>
inline auto make_shared_virtual(T&&... args)
-> shared_virtual_ptr;
@@ -83,11 +83,11 @@ Defined in ``:
```c++
namespace boost::openmethod {
-template
+template
using unique_virtual_ptr = virtual_ptr, Policy>;
template<
- class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_POLICY, typename... T>
+ class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_REGISTRY, typename... T>
inline auto make_unique_virtual(T&&... args)
-> unique_virtual_ptr;
}
@@ -245,7 +245,7 @@ Returns a `virtual_ptr` to the same object, cast to `Other`.
```c++
template
-virtual_ptr(Class&) -> virtual_ptr;
+virtual_ptr(Class&) -> virtual_ptr;
```
---
@@ -255,7 +255,7 @@ virtual_ptr(Class&) -> virtual_ptr;
#### virtual_shared_ptr
```c++
-template
+template
using virtual_shared_ptr = virtual_ptr, Policy>;
```
@@ -264,7 +264,7 @@ Convenience alias for `virtual_ptr, Policy>`.
#### virtual_unique_ptr
```c++
-template
+template
using virtual_unique_ptr = virtual_ptr, Policy>;
```
@@ -282,13 +282,13 @@ inline auto final_virtual_ptr(Class&& obj);
Utility functions, forwarding to `virtual_ptr::final`.
-If `Policy` is not specified, `BOOST_OPENMETHOD_DEFAULT_POLICY` is used.
+If `Policy` is not specified, `BOOST_OPENMETHOD_DEFAULT_REGISTRY` is used.
#### make_shared_virtual
```c++
template<
- class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_POLICY, typename... T>
+ class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_REGISTRY, typename... T>
inline auto make_shared_virtual(T&&... args)
-> shared_virtual_ptr;
```
@@ -301,7 +301,7 @@ the class, which needs not be polymorphic.
```c++
template<
- class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_POLICY, typename... T>
+ class Class, class Policy = BOOST_OPENMETHOD_DEFAULT_REGISTRY, typename... T>
inline auto make_unique_virtual(T&&... args)
-> unique_virtual_ptr;
```
diff --git a/doc/virtual_ptr_alt.adoc b/doc/virtual_ptr_alt.adoc
index e4f0573..3c1911d 100644
--- a/doc/virtual_ptr_alt.adoc
+++ b/doc/virtual_ptr_alt.adoc
@@ -31,7 +31,7 @@ However, we can now customize how the vptr is obtained. When the method sees a
`virtual_` parameter, it looks for a `boost_openmethod_vptr` function that takes
the parameter (by const reference), and returns a `vptr_type`. If one is found,
it is called to obtain the vptr. The vptr for a specific registered class can be
-obtained via a variable template `static_vptr`, nested in class `default_policy`
+obtained via a variable template `static_vptr`, nested in class `default_registry`
(more on policies below).
In the following example, we embed a vptr in the object, just like the vptr for
diff --git a/doc/with_vptr.adoc b/doc/with_vptr.adoc
index 94f82f9..93865c5 100644
--- a/doc/with_vptr.adoc
+++ b/doc/with_vptr.adoc
@@ -8,7 +8,7 @@ Defined in .
```c++
namespace boost::openmethod {
-template
+template
class with_vptr {
protected:
with_vptr();
diff --git a/examples/accept_no_visitors.cpp b/examples/accept_no_visitors.cpp
index bb7f3c8..0f5d502 100644
--- a/examples/accept_no_visitors.cpp
+++ b/examples/accept_no_visitors.cpp
@@ -116,7 +116,7 @@ auto main() -> int {
cout << as_forth(expr) << " = " << as_lisp(expr) << " = " << value(expr)
<< "\n";
- // error_output:
+ // output:
// 2 3 4 + * = (times 2 (plus 3 4)) = 14
return 0;
diff --git a/examples/custom_rtti.cpp b/examples/custom_rtti.cpp
index 79ca732..83aebea 100644
--- a/examples/custom_rtti.cpp
+++ b/examples/custom_rtti.cpp
@@ -27,42 +27,44 @@ struct Dog : Animal {
static constexpr unsigned static_type = 3;
};
-#include
+#include
#include
// tag::facet[]
namespace bom = boost::openmethod;
struct custom_rtti : bom::policies::rtti {
- template
- static constexpr bool is_polymorphic = std::is_base_of_v;
+ template
+ struct fn : bom::policies::rtti::fn {
+ template
+ static constexpr bool is_polymorphic = std::is_base_of_v;
- template
- static auto static_type() -> bom::type_id {
- if constexpr (is_polymorphic) {
- return T::static_type;
- } else {
- return 0;
+ template
+ static auto static_type() -> bom::type_id {
+ if constexpr (is_polymorphic) {
+ return T::static_type;
+ } else {
+ return 0;
+ }
}
- }
- template
- static auto dynamic_type(const T& obj) -> bom::type_id {
- if constexpr (is_polymorphic) {
- return obj.type;
- } else {
- return 0;
+ template
+ static auto dynamic_type(const T& obj) -> bom::type_id {
+ if constexpr (is_polymorphic) {
+ return obj.type;
+ } else {
+ return 0;
+ }
}
- }
+ };
};
// end::facet[]
// tag::policy[]
-struct custom_policy : bom::policies::basic_policy<
- custom_policy, custom_rtti,
- bom::policies::vptr_vector> {};
+struct custom_policy
+ : bom::registry {};
-#define BOOST_OPENMETHOD_DEFAULT_POLICY custom_policy
+#define BOOST_OPENMETHOD_DEFAULT_REGISTRY custom_policy
// end::policy[]
// tag::example[]
diff --git a/examples/deferred_custom_rtti.cpp b/examples/deferred_custom_rtti.cpp
index 5145a9c..ec5bb45 100644
--- a/examples/deferred_custom_rtti.cpp
+++ b/examples/deferred_custom_rtti.cpp
@@ -72,53 +72,55 @@ struct Dog : virtual Animal {
static custom_type_info type_info;
};
-#include
+#include
#include
namespace bom = boost::openmethod;
struct custom_rtti : bom::policies::rtti {
- template
- static constexpr bool is_polymorphic = std::is_base_of_v;
+ template
+ struct fn : bom::policies::rtti::fn {
+ template
+ static constexpr bool is_polymorphic = std::is_base_of_v;
- template
- static auto static_type() -> bom::type_id {
- if constexpr (std::is_base_of_v) {
- return T::type_info.id;
- } else {
- return 0;
+ template
+ static auto static_type() -> bom::type_id {
+ if constexpr (std::is_base_of_v) {
+ return T::type_info.id;
+ } else {
+ return 0;
+ }
}
- }
- template
- static auto dynamic_type(const T& obj) -> bom::type_id {
- if constexpr (std::is_base_of_v) {
- return obj.type;
- } else {
- return 0;
+ template
+ static auto dynamic_type(const T& obj) -> bom::type_id {
+ if constexpr (std::is_base_of_v) {
+ return obj.type;
+ } else {
+ return 0;
+ }
}
- }
- // tag::dynamic_cast_ref[]
- // to support virtual inheritance:
- template
- static auto dynamic_cast_ref(Base&& obj) -> Derived {
- using base_type = std::remove_reference_t ;
- if constexpr (std::is_base_of_v) {
- return *obj.template cast>();
- } else {
- abort(); // not supported
+ // tag::dynamic_cast_ref[]
+ // to support virtual inheritance:
+ template
+ static auto dynamic_cast_ref(Base&& obj) -> Derived {
+ using base_type = std::remove_reference_t ;
+ if constexpr (std::is_base_of_v) {
+ return *obj.template cast>();
+ } else {
+ abort(); // not supported
+ }
}
- }
- // end::dynamic_cast_ref[]
+ // end::dynamic_cast_ref[]
+ };
};
-struct custom_policy
- : bom::policies::basic_policy<
- custom_policy, custom_rtti, bom::policies::deferred_static_rtti,
- bom::policies::vptr_vector> {};
+struct custom_policy : bom::registry<
+ custom_rtti, bom::policies::deferred_static_rtti,
+ bom::policies::vptr_vector> {};
-#define BOOST_OPENMETHOD_DEFAULT_POLICY custom_policy
+#define BOOST_OPENMETHOD_DEFAULT_REGISTRY custom_policy
#include
diff --git a/examples/dl.hpp b/examples/dl.hpp
index 5af22e3..b12a532 100644
--- a/examples/dl.hpp
+++ b/examples/dl.hpp
@@ -26,9 +26,8 @@ struct Carnivore : Animal {};
struct Cow : Herbivore {};
struct Wolf : Carnivore {};
-struct dynamic_policy
- : boost::openmethod::default_policy::fork::with<
- boost::openmethod::policies::indirect_vptr> {};
+struct dynamic_policy : boost::openmethod::default_registry::with<
+ boost::openmethod::policies::indirect_vptr> {};
template
using dyn_vptr = boost::openmethod::virtual_ptr;
diff --git a/examples/throw_error_handler.cpp b/examples/throw_error_handler.cpp
index 5062d73..0de26b2 100644
--- a/examples/throw_error_handler.cpp
+++ b/examples/throw_error_handler.cpp
@@ -6,7 +6,7 @@
// tag::example[]
#include
-#include
+#include
struct Animal {
virtual ~Animal() = default;
@@ -18,18 +18,21 @@ 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
+ 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_policy::fork::with<
- throw_if_not_implemented> {};
+struct custom_registry : bom::default_registry::with {
+};
-#define BOOST_OPENMETHOD_DEFAULT_POLICY throwing_policy
+#define BOOST_OPENMETHOD_DEFAULT_REGISTRY custom_registry
#include
#include
diff --git a/examples/vectored_error_handler.cpp b/examples/vectored_error_handler.cpp
index 37b1a1e..f15c77d 100644
--- a/examples/vectored_error_handler.cpp
+++ b/examples/vectored_error_handler.cpp
@@ -30,8 +30,8 @@ auto main() -> int {
namespace bom = boost::openmethod;
bom::initialize();
- bom::default_policy::set_error_handler(
- [](const bom::default_policy::error_variant& error) {
+ bom::default_registry::ErrorHandler::set_error_handler(
+ [](const auto& error) {
if (std::holds_alternative(error)) {
throw std::runtime_error("not implemented");
}
diff --git a/examples/virtual_.cpp b/examples/virtual_.cpp
index 11435cf..0ec57ea 100644
--- a/examples/virtual_.cpp
+++ b/examples/virtual_.cpp
@@ -47,14 +47,14 @@ class Animal {
public:
Animal() {
- vptr = boost::openmethod::default_policy::static_vptr;
+ vptr = boost::openmethod::default_registry::static_vptr;
}
};
class Cat : public Animal {
public:
Cat() {
- vptr = boost::openmethod::default_policy::static_vptr;
+ vptr = boost::openmethod::default_registry::static_vptr;
}
};
diff --git a/include/boost/openmethod/compiler.hpp b/include/boost/openmethod/compiler.hpp
index 77ae5e7..a7c12a3 100644
--- a/include/boost/openmethod/compiler.hpp
+++ b/include/boost/openmethod/compiler.hpp
@@ -169,22 +169,23 @@ struct generic_compiler {
bool compilation_done = false;
};
-template
-auto operator<<(trace_type& trace, const generic_compiler::class_& cls)
- -> trace_type& {
- if constexpr (Policy::template has_facet) {
+template
+auto operator<<(
+ trace_type& trace, const generic_compiler::class_& cls)
+ -> trace_type& {
+ if constexpr (Registry::template has_policy) {
trace << type_name(cls.type_ids[0]);
}
return trace;
}
-template class Container, typename... T>
+template class Container, typename... T>
auto operator<<(
- trace_type& trace,
+ trace_type& trace,
Container& classes)
- -> trace_type& {
- if constexpr (Policy::template has_facet) {
+ -> trace_type& {
+ if constexpr (Registry::template has_policy) {
trace << "(";
const char* sep = "";
for (auto cls : classes) {
@@ -208,9 +209,9 @@ struct spec_name {
const detail::generic_compiler::overrider* def;
};
-template
-auto operator<<(trace_type& trace, const spec_name& sn)
- -> trace_type& {
+template
+auto operator<<(trace_type& trace, const spec_name& sn)
+ -> trace_type& {
if (sn.def == &sn.method.not_implemented) {
trace << "not implemented";
} else {
@@ -222,13 +223,13 @@ auto operator<<(trace_type& trace, const spec_name& sn)
} // namespace detail
-template
+template
struct compiler : detail::generic_compiler {
- using policy_type = Policy;
- using type_index_type = decltype(Policy::type_index(0));
+ using type_index_type =
+ decltype(Registry::template policy::type_index(0));
typename detail::aggregate_reports<
- mp11::mp_list, typename Policy::facets>::type report;
+ mp11::mp_list, typename Registry::policies>::type report;
std::unordered_map class_map;
@@ -260,16 +261,16 @@ struct compiler : detail::generic_compiler {
-> bool;
static auto is_base(const overrider* a, const overrider* b) -> bool;
- mutable detail::trace_type trace;
+ mutable detail::trace_type trace;
static constexpr bool trace_enabled =
- Policy::template has_facet;
- using indent = typename detail::trace_type::indent;
+ Registry::template has_policy;
+ using indent = typename detail::trace_type::indent;
};
-compiler() -> compiler;
+compiler() -> compiler;
-template
-void compiler::install_global_tables() {
+template
+void compiler::install_global_tables() {
if (!compilation_done) {
abort();
}
@@ -280,8 +281,8 @@ void compiler::install_global_tables() {
++trace << "Finished\n";
}
-template
-auto compiler::compile() {
+template
+auto compiler::compile() {
resolve_static_type_ids();
augment_classes();
augment_methods();
@@ -293,29 +294,30 @@ auto compiler::compile() {
return report;
}
-template
-auto compiler::initialize() {
+template
+auto compiler::initialize() {
compile();
install_global_tables();
return *this;
}
-template
-compiler::compiler() {
+template
+compiler::compiler() {
}
-template
-void compiler::resolve_static_type_ids() {
- using namespace detail;
+template
+void compiler::resolve_static_type_ids() {
+ if constexpr (Registry::template has_policy<
+ policies::deferred_static_rtti>) {
+ using namespace detail;
- auto resolve = [](type_id* p) {
- auto pf = reinterpret_cast(*p);
- *p = pf();
- };
+ auto resolve = [](type_id* p) {
+ auto pf = reinterpret_cast(*p);
+ *p = pf();
+ };
- if constexpr (std::is_base_of_v) {
- for (auto& ci : Policy::classes) {
+ for (auto& ci : Registry::classes) {
resolve(&ci.type);
if (*ci.last_base == 0) {
@@ -327,7 +329,7 @@ void compiler::resolve_static_type_ids() {
}
}
- for (auto& method : Policy::methods) {
+ for (auto& method : Registry::methods) {
for (auto& ti : range{method.vp_begin, method.vp_end}) {
if (*method.vp_end == 0) {
resolve(&ti);
@@ -350,8 +352,8 @@ void compiler::resolve_static_type_ids() {
}
}
-template
-void compiler::collect_transitive_bases(class_* cls, class_* base) {
+template
+void compiler::collect_transitive_bases(class_* cls, class_* base) {
if (base->mark == class_mark) {
return;
}
@@ -364,8 +366,8 @@ void compiler::collect_transitive_bases(class_* cls, class_* base) {
}
}
-template
-void compiler::augment_classes() {
+template
+void compiler::augment_classes() {
using namespace detail;
// scope
@@ -375,14 +377,16 @@ void compiler::augment_classes() {
// The standard does not guarantee that there is exactly one
// type_info object per class. However, it guarantees that the
// type_index for a class has a unique value.
- for (auto& cr : Policy::classes) {
+ for (auto& cr : Registry::classes) {
{
indent _(trace);
++trace << type_name(cr.type) << ": "
<< range{cr.first_base, cr.last_base} << "\n";
}
- auto& rtc = class_map[Policy::type_index(cr.type)];
+ auto& rtc =
+ class_map[Registry::template policy::type_index(
+ cr.type)];
if (rtc == nullptr) {
rtc = &classes.emplace_back();
@@ -406,19 +410,24 @@ void compiler::augment_classes() {
// All known classes now have exactly one associated class_* in the
// map. Collect the bases.
- for (auto& cr : Policy::classes) {
- auto rtc = class_map[Policy::type_index(cr.type)];
+ for (auto& cr : Registry::classes) {
+ auto rtc =
+ class_map[Registry::template policy::type_index(
+ cr.type)];
for (auto& base : range{cr.first_base, cr.last_base}) {
- auto rtb = class_map[Policy::type_index(base)];
+ auto rtb =
+ class_map[Registry::template policy::type_index(
+ base)];
if (!rtb) {
unknown_class_error error;
error.type = base;
- if constexpr (Policy::template has_facet<
+ if constexpr (Registry::template has_policy<
policies::error_handler>) {
- Policy::error(error);
+ Registry::template policy::error(
+ error);
}
abort();
@@ -507,8 +516,8 @@ void compiler::augment_classes() {
}
}
-template
-void compiler::calculate_transitive_derived(class_& cls) {
+template
+void compiler::calculate_transitive_derived(class_& cls) {
if (!cls.transitive_derived.empty()) {
return;
}
@@ -528,19 +537,19 @@ void compiler::calculate_transitive_derived(class_& cls) {
}
}
-template
-void compiler::augment_methods() {
+template
+void compiler::augment_methods() {
using namespace policies;
using namespace detail;
- methods.resize(Policy::methods.size());
+ methods.resize(Registry::methods.size());
++trace << "Methods:\n";
indent _(trace);
auto meth_iter = methods.begin();
- for (auto& meth_info : Policy::methods) {
+ for (auto& meth_info : Registry::methods) {
++trace << type_name(meth_info.method_type) << " "
<< range{meth_info.vp_begin, meth_info.vp_end} << "\n";
@@ -552,15 +561,19 @@ void compiler::augment_methods() {
std::size_t param_index = 0;
for (auto ti : range{meth_info.vp_begin, meth_info.vp_end}) {
- auto class_ = class_map[Policy::type_index(ti)];
+ auto class_ =
+ class_map[Registry::template policy::type_index(
+ ti)];
if (!class_) {
++trace << "unknown class " << ti << "(" << type_name(ti)
<< ") for parameter #" << (param_index + 1) << "\n";
unknown_class_error error;
error.type = ti;
- if constexpr (Policy::template has_facet) {
- Policy::error(error);
+ if constexpr (Registry::template has_policy<
+ policies::error_handler>) {
+ Registry::template policy::error(
+ error);
}
abort();
@@ -569,10 +582,14 @@ void compiler::augment_methods() {
meth_iter->vp.push_back(class_);
}
- if (Policy::type_index(meth_info.return_type) !=
- Policy::type_index(Policy::template static_type())) {
- auto covariant_return_iter =
- class_map.find(Policy::type_index(meth_info.return_type));
+ if (Registry::template policy::type_index(
+ meth_info.return_type) !=
+ Registry::template policy::type_index(
+ Registry::template policy::template static_type<
+ void>())) {
+ auto covariant_return_iter = class_map.find(
+ Registry::template policy::type_index(
+ meth_info.return_type));
if (covariant_return_iter != class_map.end()) {
meth_iter->covariant_return_type =
@@ -605,7 +622,8 @@ void compiler::augment_methods() {
for (auto type :
range{overrider_info.vp_begin, overrider_info.vp_end}) {
indent _(trace);
- auto class_ = class_map[Policy::type_index(type)];
+ auto class_ = class_map[Registry::template policy<
+ policies::rtti>::type_index(type)];
if (!class_) {
++trace << "unknown class error for *virtual* parameter #"
@@ -613,8 +631,10 @@ void compiler::augment_methods() {
unknown_class_error error;
error.type = type;
- if constexpr (Policy::template has_facet) {
- Policy::error(error);
+ if constexpr (Registry::template has_policy<
+ policies::error_handler>) {
+ Registry::template policy<
+ policies::error_handler>::error(error);
}
abort();
@@ -626,7 +646,8 @@ void compiler::augment_methods() {
if (meth_iter->covariant_return_type) {
auto covariant_return_iter = class_map.find(
- Policy::type_index(overrider_info.return_type));
+ Registry::template policy::type_index(
+ overrider_info.return_type));
if (covariant_return_iter != class_map.end()) {
spec_iter->covariant_return_type =
@@ -635,8 +656,10 @@ void compiler::augment_methods() {
unknown_class_error error;
error.type = overrider_info.return_type;
- if constexpr (Policy::template has_facet) {
- Policy::error(error);
+ if constexpr (Registry::template has_policy<
+ policies::error_handler>) {
+ Registry::template policy<
+ policies::error_handler>::error(error);
}
abort();
@@ -658,8 +681,8 @@ void compiler::augment_methods() {
}
}
-template
-void compiler::assign_slots() {
+template
+void compiler::assign_slots() {
++trace << "Allocating slots...\n";
{
@@ -705,8 +728,8 @@ void compiler::assign_slots() {
}
}
-template
-void compiler::assign_tree_slots(class_& cls, std::size_t base_slot) {
+template
+void compiler::assign_tree_slots(class_& cls, std::size_t base_slot) {
auto next_slot = base_slot;
using namespace detail;
@@ -725,8 +748,8 @@ void compiler::assign_tree_slots(class_& cls, std::size_t base_slot) {
}
}
-template
-void compiler