make initialize and finalize symmetric

This commit is contained in:
Jean-Louis Leroy
2025-11-15 16:23:23 -05:00
parent dac3cf7087
commit 4d91aab7fd
4 changed files with 19 additions and 14 deletions

View File

@@ -22,6 +22,8 @@ inaccessible-bases: never
# implementation-defined:
# - 'boost::openmethod::detail::**'
exclude-symbols:
- 'boost::openmethod::registry::initialize'
- 'boost::openmethod::registry::finalize'
- 'boost::openmethod::boost_openmethod_bases'
- 'boost::openmethod::boost_openmethod_registry'

View File

@@ -1657,9 +1657,22 @@ auto registry<Policies...>::finalize(Options... opts) -> void {
initialized = false;
}
//! Finalize the default registry
inline auto finalize() -> void {
BOOST_OPENMETHOD_DEFAULT_REGISTRY::finalize();
//! Release resources held by registry.
//!
//! `finalize` may be called to release any resources allocated by
//! @ref registry::initialize.
//!
//! @note
//! A translation unit that contains a call to `finalize` must include the
//! `<boost/openmethod/initialize.hpp>` header.
//!
//! @tparam Registry The registry to finalize.
//! @tparam Options... Zero or more option types, deduced from the function
//! arguments.
//! @param options Zero or more option objects.
template<class Registry = BOOST_OPENMETHOD_DEFAULT_REGISTRY, class... Options>
inline auto finalize(Options&&... opts) -> void {
Registry::finalize(std::forward<Options>(opts)...);
}
namespace aliases {

View File

@@ -946,16 +946,6 @@ class registry : detail::registry_base {
//! @li @ref not_initialized: The registry is not initialized.
static void require_initialized();
//! Releases the resources held by the registry.
//!
//! `finalize` may be called to release any resources allocated by
//! @ref registry::initialize.
//!
//! @note
//! A translation unit that contains a call to `finalize` must include the
//! `<boost/openmethod/initialize.hpp>` header.
//!
//! @tparam Options A registry.
template<class... Options>
static void finalize(Options... opts);

View File

@@ -339,7 +339,7 @@ BOOST_AUTO_TEST_CASE(simple) {
if constexpr (std::is_same_v<test_registry::vptr, policies::vptr_vector>) {
BOOST_TEST(
!detail::vptr_vector_vptrs<test_registry::registry_type>.empty());
test_registry::finalize();
finalize<test_registry>();
static_assert(detail::has_finalize_aux<
void, test_registry::policy<policies::vptr>,
std::tuple<>>::value);