2
0
mirror of https://github.com/boostorg/dll.git synced 2026-01-28 07:02:20 +00:00

Modernize code and drop Boost.Function dependency

This commit is contained in:
Antony Polukhin
2024-12-17 13:15:55 +03:00
parent c66dfab77f
commit f8b1153105
21 changed files with 77 additions and 114 deletions

View File

@@ -12,7 +12,7 @@
#include <boost/function.hpp>
#include <iostream>
typedef boost::function<void()> callback_t;
using callback_t = boost::function<void()>;
void print_unloaded() {
std::cout << "unloaded" << std::endl;
@@ -22,17 +22,17 @@ int main(int argc, char* argv[]) {
// argv[1] contains full path to our plugin library
boost::dll::fs::path shared_library_path = /*<-*/ b2_workarounds::first_lib_from_argv(argc, argv); /*->*/ //=argv[1];
// loading library and getting a function from it
boost::function<void(const callback_t&)> on_unload
= boost::dll::import_alias<void(const callback_t&)>(
{
// loading library and getting a function from it
auto on_unload = boost::dll::import_alias<void(const callback_t&)>(
shared_library_path, "on_unload"
);
on_unload(&print_unloaded); // adding a callback
std::cout << "Before library unload." << std::endl;
on_unload(&print_unloaded); // adding a callback
// Releasing last reference to the library, so that it gets unloaded
on_unload.clear();
std::cout << "Before library unload." << std::endl;
// Releasing last reference to the library, so that it gets unloaded
}
std::cout << "After library unload." << std::endl;
}
//]