mirror of
https://github.com/boostorg/openmethod.git
synced 2026-01-26 18:52:21 +00:00
rework policies
This commit is contained in:
committed by
Jean-Louis Leroy
parent
40c90777aa
commit
0b44fc5973
@@ -6,7 +6,7 @@
|
||||
// tag::example[]
|
||||
#include <iostream>
|
||||
|
||||
#include <boost/openmethod/policies.hpp>
|
||||
#include <boost/openmethod/default_registry.hpp>
|
||||
|
||||
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<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_policy::fork<throwing_policy>::with<
|
||||
throw_if_not_implemented> {};
|
||||
struct custom_registry : bom::default_registry::with<throw_if_not_implemented> {
|
||||
};
|
||||
|
||||
#define BOOST_OPENMETHOD_DEFAULT_POLICY throwing_policy
|
||||
#define BOOST_OPENMETHOD_DEFAULT_REGISTRY custom_registry
|
||||
|
||||
#include <boost/openmethod.hpp>
|
||||
#include <boost/openmethod/compiler.hpp>
|
||||
|
||||
Reference in New Issue
Block a user