Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions doc/modules/ROOT/examples/shared_libs/dynamic_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ int main() {
// end::unload[]
std::cout << "Before loading the shared library.\n";

initialize();
boost::openmethod::initialize();

std::cout << "cow meets wolf -> "
<< meet(*std::make_unique<Cow>(), *std::make_unique<Wolf>())
Expand All @@ -60,7 +60,7 @@ int main() {
boost::dll::shared_library lib(
boost::dll::program_location().parent_path() / LIBRARY_NAME,
boost::dll::load_mode::rtld_now);
initialize();
boost::openmethod::initialize();

std::cout << "cow meets wolf -> "
<< meet(*std::make_unique<Cow>(), *std::make_unique<Wolf>())
Expand All @@ -83,7 +83,7 @@ int main() {
std::cout << "\nAfter unloading the shared library.\n";

lib.unload();
initialize();
boost::openmethod::initialize();

std::cout << "cow meets wolf -> "
<< meet(*std::make_unique<Cow>(), *std::make_unique<Wolf>())
Expand Down
4 changes: 2 additions & 2 deletions doc/modules/ROOT/examples/shared_libs/indirect_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ auto main() -> int {
using namespace boost::openmethod::aliases;

std::cout << "Before loading the shared library.\n";
initialize();
boost::openmethod::initialize();

auto gracie = make_unique_virtual<Cow>();
auto willy = make_unique_virtual<Wolf>();
Expand All @@ -53,7 +53,7 @@ auto main() -> int {
boost::dll::program_location().parent_path() / LIBRARY_NAME,
boost::dll::load_mode::rtld_now);

initialize();
boost::openmethod::initialize();

std::cout << "cow meets wolf -> " << meet(*gracie, *willy) << "\n"; // run
std::cout << "wolf meets cow -> " << meet(*willy, *gracie) << "\n"; // hunt
Expand Down
2 changes: 1 addition & 1 deletion doc/modules/ROOT/examples/shared_libs/static_main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ auto make_tiger() -> Animal*;
}

auto main() -> int {
initialize();
boost::openmethod::initialize();

std::unique_ptr<Animal> gracie(new Cow());
std::unique_ptr<Animal> willy(new Wolf());
Expand Down
2 changes: 2 additions & 0 deletions doc/mrdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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'

Expand Down
23 changes: 16 additions & 7 deletions include/boost/openmethod/initialize.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1657,13 +1657,22 @@ auto registry<Policies...>::finalize(Options... opts) -> void {
initialized = false;
}

//! Finalize the default registry
inline auto finalize() -> void {
BOOST_OPENMETHOD_DEFAULT_REGISTRY::finalize();
}

namespace aliases {
using boost::openmethod::initialize;
//! 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 boost::openmethod
Expand Down
10 changes: 0 additions & 10 deletions include/boost/openmethod/preamble.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
2 changes: 1 addition & 1 deletion test/test_dispatch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Loading