rework policies

This commit is contained in:
Jean-Louis Leroy
2025-05-08 18:33:39 -04:00
committed by Jean-Louis Leroy
parent 40c90777aa
commit 0b44fc5973
61 changed files with 1994 additions and 1876 deletions

View File

@@ -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>