From f8b11531059133e34a6d673a4085e5f748157fa8 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Tue, 17 Dec 2024 13:15:55 +0300 Subject: [PATCH] Modernize code and drop Boost.Function dependency --- build.jam | 1 - doc/Jamfile.v2 | 7 --- doc/dependencies.qbk | 3 +- doc/getting_started.qbk | 2 +- example/tutorial2/tutorial2.cpp | 5 +- example/tutorial3/tutorial3.cpp | 7 ++- example/tutorial4/load_self.cpp | 3 +- example/tutorial5/load_all.cpp | 7 +-- example/tutorial6/on_unload_lib.cpp | 4 +- example/tutorial6/tutorial6.cpp | 16 ++--- example/tutorial8/refcounting_api.hpp | 4 +- .../boost/dll/detail/aggressive_ptr_cast.hpp | 8 +-- include/boost/dll/detail/elf_info.hpp | 2 +- include/boost/dll/detail/pe_info.hpp | 2 +- .../dll/detail/posix/path_from_handle.hpp | 2 +- include/boost/dll/detail/system_error.hpp | 2 +- .../dll/detail/windows/path_from_handle.hpp | 2 +- include/boost/dll/import.hpp | 59 ++++++------------- include/boost/dll/library_info.hpp | 2 +- .../boost/dll/shared_library_load_mode.hpp | 14 ++--- include/boost/dll/smart_library.hpp | 39 ++++++------ 21 files changed, 77 insertions(+), 114 deletions(-) diff --git a/build.jam b/build.jam index 91c4eeb3..5e67738b 100644 --- a/build.jam +++ b/build.jam @@ -10,7 +10,6 @@ constant boost_dependencies : /boost/config//boost_config /boost/core//boost_core /boost/filesystem//boost_filesystem - /boost/function//boost_function /boost/predef//boost_predef /boost/smart_ptr//boost_smart_ptr /boost/spirit//boost_spirit diff --git a/doc/Jamfile.v2 b/doc/Jamfile.v2 index 013e6cd2..4f0c5d37 100644 --- a/doc/Jamfile.v2 +++ b/doc/Jamfile.v2 @@ -35,15 +35,8 @@ local doxygen_params = \"forcedlinkfs{1}=\\xmlonlyboost::dll::fs::\\1\\endxmlonly\" \\ \"forcedmacrolink{1}=\\xmlonly\\1\\endxmlonly\" " "PREDEFINED= \\ - \"BOOST_RV_REF(T)=T&&\" \\ - \"BOOST_RV_REF(shared_library)=shared_library&&\" \\ - \"BOOST_COPY_ASSIGN_REF(shared_library)=const shared_library&\" \\ - \"BOOST_MOVABLE_BUT_NOT_COPYABLE(shared_library)= \\ - shared_library(const shared_library&) = delete; \\ - shared_library& operator=(const shared_library&) = delete; \" \\ \"BOOST_DLL_IMPORT_RESULT_TYPE=result_type\" \\ \"BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE=result_type\" \\ - \"BOOST_EXPLICIT_OPERATOR_BOOL()=explicit operator bool() const noexcept;\" \\ \"BOOST_DLL_DOXYGEN\" " ; diff --git a/doc/dependencies.qbk b/doc/dependencies.qbk index c82db9f2..3c8416d5 100644 --- a/doc/dependencies.qbk +++ b/doc/dependencies.qbk @@ -10,12 +10,11 @@ The Boost.DLL is a header only library, but it depends on the following libraries and they must be available in order to compile programs that use Boost.DLL: -* Boost.System for the boost::system::error_code and boost::system::system_error classes. +* Boost.System for the boost::system::system_error class. * Boost.Filesystem for directory manipulation. Refcountable part of Boost.DLL also depends on: -* Boost.Function for creation of a callback system. * Boost.SharedPtr for reference counting. [endsect] diff --git a/doc/getting_started.qbk b/doc/getting_started.qbk index 4f900fc2..27a78fcc 100644 --- a/doc/getting_started.qbk +++ b/doc/getting_started.qbk @@ -17,7 +17,7 @@ boost::dll::shared_library lib("/test/boost/application/libtest_library.so"); Now you can easily import symbols from that library using the `get` and `get_alias` member functions: ``` int plugin_constant = lib.get("integer_variable"); -boost::function f = lib.get("function_returning_int"); +auto function_ptr = lib.get("function_returning_int"); int& i = lib.get_alias("alias_to_int_variable"); ``` In case of `boost::dll::shared_library` it is safe to use imported symbols only until `boost::dll::shared_library` diff --git a/example/tutorial2/tutorial2.cpp b/example/tutorial2/tutorial2.cpp index ca49b49c..29e6d256 100644 --- a/example/tutorial2/tutorial2.cpp +++ b/example/tutorial2/tutorial2.cpp @@ -19,10 +19,9 @@ int main(int argc, char* argv[]) { /*<-*/ b2_workarounds::argv_to_path_guard guard(argc, argv); /*->*/ boost::dll::fs::path shared_library_path(argv[1]); // argv[1] contains path to directory with our plugin library shared_library_path /= "my_plugin_aggregator"; - typedef boost::shared_ptr (pluginapi_create_t)(); - boost::function creator; - creator = boost::dll::import_alias( // type of imported symbol must be explicitly specified + using pluginapi_create_t = boost::shared_ptr(); + auto creator = boost::dll::import_alias( // type of imported symbol must be explicitly specified shared_library_path, // path to library "create_plugin", // symbol to import dll::load_mode::append_decorations // do append extensions and prefixes diff --git a/example/tutorial3/tutorial3.cpp b/example/tutorial3/tutorial3.cpp index b048d9f2..165956f3 100644 --- a/example/tutorial3/tutorial3.cpp +++ b/example/tutorial3/tutorial3.cpp @@ -27,9 +27,10 @@ std::size_t search_for_symbols(const std::vector& plugins) } // library has symbol, importing... - typedef boost::shared_ptr (pluginapi_create_t)(); - boost::function creator - = dll::import_alias(std::move(lib), "create_plugin"); + using pluginapi_create_t = boost::shared_ptr(); + auto creator = dll::import_alias( + std::move(lib), "create_plugin" + ); std::cout << "Matching plugin name: " << creator()->name() << std::endl; ++ plugins_found; diff --git a/example/tutorial4/load_self.cpp b/example/tutorial4/load_self.cpp index 80528e1e..7b8e83a4 100644 --- a/example/tutorial4/load_self.cpp +++ b/example/tutorial4/load_self.cpp @@ -21,8 +21,7 @@ int main() { dll::shared_library self(dll::program_location()); std::cout << "Call function" << std::endl; - boost::function()> creator - = self.get_alias()>("create_plugin"); + auto creator = self.get_alias()>("create_plugin"); std::cout << "Computed Value: " << creator()->calculate(2, 2) << std::endl; //<- diff --git a/example/tutorial5/load_all.cpp b/example/tutorial5/load_all.cpp index 3b04f3a8..4a1464c1 100644 --- a/example/tutorial5/load_all.cpp +++ b/example/tutorial5/load_all.cpp @@ -22,7 +22,7 @@ namespace dll = boost::dll; class plugins_collector { // Name => plugin - typedef boost::container::map plugins_t; + using plugins_t = boost::container::map; boost::dll::fs::path plugins_directory_; plugins_t plugins_; @@ -52,8 +52,7 @@ class plugins_collector { //[plugcpp_plugins_collector_load_all void plugins_collector::load_all() { namespace fs = ::boost::dll::fs; - typedef fs::path::string_type string_type; - const string_type extension = dll::shared_library::suffix().native(); + const auto extension = dll::shared_library::suffix().native(); // Searching a folder for files with '.so' or '.dll' extension fs::recursive_directory_iterator endit; @@ -67,7 +66,7 @@ void plugins_collector::load_all() { } /*->*/ // We found a file. Trying to load it - boost::dll::fs::error_code error; + std::error_code error; dll::shared_library plugin(it->path(), error); if (error) { continue; diff --git a/example/tutorial6/on_unload_lib.cpp b/example/tutorial6/on_unload_lib.cpp index 0b972266..1ee3fcbf 100644 --- a/example/tutorial6/on_unload_lib.cpp +++ b/example/tutorial6/on_unload_lib.cpp @@ -16,8 +16,8 @@ namespace my_namespace { struct on_unload { - typedef boost::function callback_t; - typedef on_unload this_type; + using callback_t = boost::function ; + using this_type = on_unload; ~on_unload() { for (std::size_t i = 0; i < callbacks_.size(); ++i) { diff --git a/example/tutorial6/tutorial6.cpp b/example/tutorial6/tutorial6.cpp index 11117e28..928be684 100644 --- a/example/tutorial6/tutorial6.cpp +++ b/example/tutorial6/tutorial6.cpp @@ -12,7 +12,7 @@ #include #include -typedef boost::function callback_t; +using callback_t = boost::function; 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 on_unload - = boost::dll::import_alias( + { + // loading library and getting a function from it + auto on_unload = boost::dll::import_alias( 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; } //] diff --git a/example/tutorial8/refcounting_api.hpp b/example/tutorial8/refcounting_api.hpp index e9e415da..b06d06e7 100644 --- a/example/tutorial8/refcounting_api.hpp +++ b/example/tutorial8/refcounting_api.hpp @@ -54,8 +54,8 @@ inline boost::shared_ptr bind(my_refcounting_api* plugin) { inline boost::shared_ptr get_plugin( boost::dll::fs::path path, const char* func_name) { - typedef my_refcounting_api*(func_t)(); - boost::function creator = boost::dll::import_alias( + using func_t = my_refcounting_api*(); + auto creator = boost::dll::import_alias( path, func_name, boost::dll::load_mode::append_decorations // will be ignored for executable diff --git a/include/boost/dll/detail/aggressive_ptr_cast.hpp b/include/boost/dll/detail/aggressive_ptr_cast.hpp index b9efc297..75ddc654 100644 --- a/include/boost/dll/detail/aggressive_ptr_cast.hpp +++ b/include/boost/dll/detail/aggressive_ptr_cast.hpp @@ -33,7 +33,7 @@ namespace boost { namespace dll { namespace detail { // This method suppress the warnings and ensures that such casts are safe. template BOOST_FORCEINLINE typename boost::disable_if_c::value || boost::is_reference::value || boost::is_member_pointer::value, To>::type - aggressive_ptr_cast(From v) BOOST_NOEXCEPT + aggressive_ptr_cast(From v) noexcept { static_assert( boost::is_pointer::value && boost::is_pointer::value, @@ -61,7 +61,7 @@ BOOST_FORCEINLINE typename boost::disable_if_c::val template BOOST_FORCEINLINE typename boost::disable_if_c::value || boost::is_member_pointer::value, To>::type - aggressive_ptr_cast(From v) BOOST_NOEXCEPT + aggressive_ptr_cast(From v) noexcept { static_assert( boost::is_pointer::value, @@ -90,7 +90,7 @@ BOOST_FORCEINLINE typename boost::disable_if_c::value | template BOOST_FORCEINLINE typename boost::disable_if_c::value || boost::is_member_pointer::value, To>::type - aggressive_ptr_cast(From v) BOOST_NOEXCEPT + aggressive_ptr_cast(From v) noexcept { static_assert( boost::is_pointer::value, @@ -109,7 +109,7 @@ BOOST_FORCEINLINE typename boost::disable_if_c::va template BOOST_FORCEINLINE typename boost::disable_if_c::value || !boost::is_member_pointer::value, To>::type - aggressive_ptr_cast(From /* v */) BOOST_NOEXCEPT + aggressive_ptr_cast(From /* v */) noexcept { static_assert( boost::is_pointer::value, diff --git a/include/boost/dll/detail/elf_info.hpp b/include/boost/dll/detail/elf_info.hpp index 6e3849ec..cf308710 100644 --- a/include/boost/dll/detail/elf_info.hpp +++ b/include/boost/dll/detail/elf_info.hpp @@ -259,7 +259,7 @@ class elf_info { read_raw(fs, symbols[0], static_cast(symtab_size - (symtab_size % sizeof(symbol_t))) ); } - static bool is_visible(const symbol_t& sym) BOOST_NOEXCEPT { + static bool is_visible(const symbol_t& sym) noexcept { const unsigned char visibility = (sym.st_other & 0x03); // `(sym.st_info >> 4) != STB_LOCAL_ && !!sym.st_size` check also workarounds the // GCC's issue https://sourceware.org/bugzilla/show_bug.cgi?id=13621 diff --git a/include/boost/dll/detail/pe_info.hpp b/include/boost/dll/detail/pe_info.hpp index a6e7aad9..18b50cf1 100644 --- a/include/boost/dll/detail/pe_info.hpp +++ b/include/boost/dll/detail/pe_info.hpp @@ -380,7 +380,7 @@ class pe_info { MSVCR110D.dll */ /* - static std::vector depend_of(boost::dll::fs::error_code &ec) BOOST_NOEXCEPT { + static std::vector depend_of(boost::dll::fs::error_code &ec) noexcept { std::vector ret; IMAGE_DOS_HEADER* image_dos_header = (IMAGE_DOS_HEADER*)native(); diff --git a/include/boost/dll/detail/posix/path_from_handle.hpp b/include/boost/dll/detail/posix/path_from_handle.hpp index 9e0840c5..dd118e6a 100644 --- a/include/boost/dll/detail/posix/path_from_handle.hpp +++ b/include/boost/dll/detail/posix/path_from_handle.hpp @@ -24,7 +24,7 @@ # include // for std::ptrdiff_t namespace boost { namespace dll { namespace detail { - inline void* strip_handle(void* handle) BOOST_NOEXCEPT { + inline void* strip_handle(void* handle) noexcept { return reinterpret_cast( (reinterpret_cast(handle) >> 2) << 2 ); diff --git a/include/boost/dll/detail/system_error.hpp b/include/boost/dll/detail/system_error.hpp index c95bc9dc..ccedc441 100644 --- a/include/boost/dll/detail/system_error.hpp +++ b/include/boost/dll/detail/system_error.hpp @@ -22,7 +22,7 @@ namespace boost { namespace dll { namespace detail { - inline void reset_dlerror() BOOST_NOEXCEPT { + inline void reset_dlerror() noexcept { #if !BOOST_OS_WINDOWS const char* const error_txt = dlerror(); (void)error_txt; diff --git a/include/boost/dll/detail/windows/path_from_handle.hpp b/include/boost/dll/detail/windows/path_from_handle.hpp index 77c86ad8..505cd32f 100644 --- a/include/boost/dll/detail/windows/path_from_handle.hpp +++ b/include/boost/dll/detail/windows/path_from_handle.hpp @@ -19,7 +19,7 @@ namespace boost { namespace dll { namespace detail { - inline std::error_code last_error_code() BOOST_NOEXCEPT { + inline std::error_code last_error_code() noexcept { boost::winapi::DWORD_ err = boost::winapi::GetLastError(); return std::error_code( static_cast(err), diff --git a/include/boost/dll/import.hpp b/include/boost/dll/import.hpp index 7b10307f..51858364 100644 --- a/include/boost/dll/import.hpp +++ b/include/boost/dll/import.hpp @@ -15,10 +15,6 @@ #include #include -#if defined(BOOST_NO_CXX11_TRAILING_RESULT_TYPES) || defined(BOOST_NO_CXX11_DECLTYPE) || defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES) -# include -#endif - #ifdef BOOST_HAS_PRAGMA_ONCE # pragma once #endif @@ -43,12 +39,6 @@ namespace detail { : f_(lib, func_ptr) {} -#if defined(BOOST_NO_CXX11_TRAILING_RESULT_TYPES) || defined(BOOST_NO_CXX11_DECLTYPE) || defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - operator T*() const noexcept { - return f_.get(); - } -#else - // Compilation error at this point means that imported function // was called with unmatching parameters. // @@ -63,33 +53,20 @@ namespace detail { { return (*f_)(static_cast(args)...); } -#endif }; - template - struct import_type; template - struct import_type >::type> { - typedef boost::dll::detail::library_function base_type; - -#if defined(BOOST_NO_CXX11_TRAILING_RESULT_TYPES) || defined(BOOST_NO_CXX11_DECLTYPE) || defined(BOOST_NO_CXX11_VARIADIC_TEMPLATES) || defined(BOOST_NO_CXX11_RVALUE_REFERENCES) - typedef boost::function type; -#else - typedef boost::dll::detail::library_function type; -#endif - }; - - template - struct import_type >::type> { - typedef boost::shared_ptr base_type; - typedef boost::shared_ptr type; - }; + using import_type = typename std::conditional< + boost::is_object::value, + boost::shared_ptr, + boost::dll::detail::library_function + >::type; } // namespace detail #ifndef BOOST_DLL_DOXYGEN -# define BOOST_DLL_IMPORT_RESULT_TYPE inline typename boost::dll::detail::import_type::type +# define BOOST_DLL_IMPORT_RESULT_TYPE inline boost::dll::detail::import_type #endif @@ -131,9 +108,9 @@ template BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(const boost::dll::fs::path& lib, const char* name, load_mode::type mode = load_mode::default_mode) { - typedef typename boost::dll::detail::import_type::base_type type; + using type = boost::dll::detail::import_type; - boost::shared_ptr p = boost::make_shared(lib, mode); + auto p = boost::make_shared(lib, mode); return type(p, boost::addressof(p->get(name))); } @@ -148,9 +125,9 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(const boost::dll::fs::path& lib, cons //! \overload boost::dll::import_symbol(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) template BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(const shared_library& lib, const char* name) { - typedef typename boost::dll::detail::import_type::base_type type; + using type = boost::dll::detail::import_type; - boost::shared_ptr p = boost::make_shared(lib); + auto p = boost::make_shared(lib); return type(p, boost::addressof(p->get(name))); } @@ -163,9 +140,9 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(const shared_library& lib, const std: //! \overload boost::dll::import_symbol(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) template BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(shared_library&& lib, const char* name) { - typedef typename boost::dll::detail::import_type::base_type type; + using type = boost::dll::detail::import_type; - boost::shared_ptr p = boost::make_shared( + auto p = boost::make_shared( std::move(lib) ); return type(p, boost::addressof(p->get(name))); @@ -221,9 +198,9 @@ template BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const boost::dll::fs::path& lib, const char* name, load_mode::type mode = load_mode::default_mode) { - typedef typename boost::dll::detail::import_type::base_type type; + using type = boost::dll::detail::import_type; - boost::shared_ptr p = boost::make_shared(lib, mode); + auto p = boost::make_shared(lib, mode); return type(p, p->get(name)); } @@ -238,9 +215,9 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const boost::dll::fs::path& lib, const //! \overload boost::dll::import_alias(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) template BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const shared_library& lib, const char* name) { - typedef typename boost::dll::detail::import_type::base_type type; + using type = boost::dll::detail::import_type; - boost::shared_ptr p = boost::make_shared(lib); + auto p = boost::make_shared(lib); return type(p, p->get(name)); } @@ -253,9 +230,9 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const shared_library& lib, const std:: //! \overload boost::dll::import_alias(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) template BOOST_DLL_IMPORT_RESULT_TYPE import_alias(shared_library&& lib, const char* name) { - typedef typename boost::dll::detail::import_type::base_type type; + using type = boost::dll::detail::import_type; - boost::shared_ptr p = boost::make_shared( + auto p = boost::make_shared( std::move(lib) ); return type(p, p->get(name)); diff --git a/include/boost/dll/library_info.hpp b/include/boost/dll/library_info.hpp index ca317c96..95747e0c 100644 --- a/include/boost/dll/library_info.hpp +++ b/include/boost/dll/library_info.hpp @@ -54,7 +54,7 @@ class library_info: private boost::noncopyable { boost::throw_exception(std::runtime_error("Not native format: 64bit binary")); } - inline static void throw_if_in_32bit_impl(boost::false_type /* is_32bit_platform */) BOOST_NOEXCEPT {} + inline static void throw_if_in_32bit_impl(boost::false_type /* is_32bit_platform */) noexcept {} inline static void throw_if_in_32bit() { diff --git a/include/boost/dll/shared_library_load_mode.hpp b/include/boost/dll/shared_library_load_mode.hpp index c47ab541..b92084ec 100644 --- a/include/boost/dll/shared_library_load_mode.hpp +++ b/include/boost/dll/shared_library_load_mode.hpp @@ -207,37 +207,37 @@ enum type { /// Free operators for load_mode::type flag manipulation. -BOOST_CONSTEXPR inline type operator|(type left, type right) BOOST_NOEXCEPT { +BOOST_CONSTEXPR inline type operator|(type left, type right) noexcept { return static_cast( static_cast(left) | static_cast(right) ); } -BOOST_CXX14_CONSTEXPR inline type& operator|=(type& left, type right) BOOST_NOEXCEPT { +BOOST_CXX14_CONSTEXPR inline type& operator|=(type& left, type right) noexcept { left = left | right; return left; } -BOOST_CONSTEXPR inline type operator&(type left, type right) BOOST_NOEXCEPT { +BOOST_CONSTEXPR inline type operator&(type left, type right) noexcept { return static_cast( static_cast(left) & static_cast(right) ); } -BOOST_CXX14_CONSTEXPR inline type& operator&=(type& left, type right) BOOST_NOEXCEPT { +BOOST_CXX14_CONSTEXPR inline type& operator&=(type& left, type right) noexcept { left = left & right; return left; } -BOOST_CONSTEXPR inline type operator^(type left, type right) BOOST_NOEXCEPT { +BOOST_CONSTEXPR inline type operator^(type left, type right) noexcept { return static_cast( static_cast(left) ^ static_cast(right) ); } -BOOST_CXX14_CONSTEXPR inline type& operator^=(type& left, type right) BOOST_NOEXCEPT { +BOOST_CXX14_CONSTEXPR inline type& operator^=(type& left, type right) noexcept { left = left ^ right; return left; } -BOOST_CONSTEXPR inline type operator~(type left) BOOST_NOEXCEPT { +BOOST_CONSTEXPR inline type operator~(type left) noexcept { return static_cast( ~static_cast(left) ); diff --git a/include/boost/dll/smart_library.hpp b/include/boost/dll/smart_library.hpp index 2be91bff..12b14bbf 100644 --- a/include/boost/dll/smart_library.hpp +++ b/include/boost/dll/smart_library.hpp @@ -93,7 +93,7 @@ class smart_library { mangled_storage &symbol_storage() {return _storage;} //! \copydoc shared_library::shared_library() - smart_library() BOOST_NOEXCEPT {}; + smart_library() noexcept {}; //! \copydoc shared_library::shared_library(const boost::dll::fs::path& lib_path, load_mode::type mode = load_mode::default_mode) smart_library(const boost::dll::fs::path& lib_path, load_mode::type mode = load_mode::default_mode) { @@ -117,7 +117,7 @@ class smart_library { * * \throw Nothing. */ - smart_library(const smart_library & lib) BOOST_NOEXCEPT + smart_library(const smart_library & lib) noexcept : _lib(lib._lib), _storage(lib._storage) {} /*! @@ -127,7 +127,7 @@ class smart_library { * * \throw Nothing. */ - smart_library(smart_library&& lib) BOOST_NOEXCEPT + smart_library(smart_library&& lib) noexcept : _lib(std::move(lib._lib)), _storage(std::move(lib._storage)) {} @@ -138,7 +138,7 @@ class smart_library { * * \throw Nothing. */ - explicit smart_library(const shared_library & lib) BOOST_NOEXCEPT + explicit smart_library(const shared_library & lib) noexcept : _lib(lib) { _storage.load(lib.location()); @@ -150,7 +150,7 @@ class smart_library { * * \throw Nothing. */ - explicit smart_library(shared_library&& lib) BOOST_NOEXCEPT + explicit smart_library(shared_library&& lib) noexcept : _lib(std::move(lib)) { _storage.load(lib.location()); @@ -164,7 +164,7 @@ class smart_library { * * \throw Nothing. */ - ~smart_library() BOOST_NOEXCEPT {}; + ~smart_library() noexcept {}; //! \copydoc shared_library::load(const boost::dll::fs::path& lib_path, load_mode::type mode = load_mode::default_mode) void load(const boost::dll::fs::path& lib_path, load_mode::type mode = load_mode::default_mode) { @@ -356,31 +356,28 @@ class smart_library { } //! \copydoc shared_library::unload() - void unload() BOOST_NOEXCEPT { + void unload() noexcept { _storage.clear(); _lib.unload(); } //! \copydoc shared_library::is_loaded() const - bool is_loaded() const BOOST_NOEXCEPT { + bool is_loaded() const noexcept { return _lib.is_loaded(); } - //! \copydoc shared_library::operator!() const - bool operator!() const BOOST_NOEXCEPT { - return !is_loaded(); - } - //! \copydoc shared_library::operator bool() const - BOOST_EXPLICIT_OPERATOR_BOOL() + explicit operator bool() const noexcept { + return is_loaded(); + } //! \copydoc shared_library::has(const char* symbol_name) const - bool has(const char* symbol_name) const BOOST_NOEXCEPT { + bool has(const char* symbol_name) const noexcept { return _lib.has(symbol_name); } //! \copydoc shared_library::has(const std::string& symbol_name) const - bool has(const std::string& symbol_name) const BOOST_NOEXCEPT { + bool has(const std::string& symbol_name) const noexcept { return _lib.has(symbol_name); } @@ -392,29 +389,29 @@ class smart_library { } //! \copydoc shared_library::swap(shared_library& rhs) - void swap(smart_library& rhs) BOOST_NOEXCEPT { + void swap(smart_library& rhs) noexcept { _lib.swap(rhs._lib); _storage.swap(rhs._storage); } }; /// Very fast equality check that compares the actual DLL/DSO objects. Throws nothing. -inline bool operator==(const smart_library& lhs, const smart_library& rhs) BOOST_NOEXCEPT { +inline bool operator==(const smart_library& lhs, const smart_library& rhs) noexcept { return lhs.shared_lib().native() == rhs.shared_lib().native(); } /// Very fast inequality check that compares the actual DLL/DSO objects. Throws nothing. -inline bool operator!=(const smart_library& lhs, const smart_library& rhs) BOOST_NOEXCEPT { +inline bool operator!=(const smart_library& lhs, const smart_library& rhs) noexcept { return lhs.shared_lib().native() != rhs.shared_lib().native(); } /// Compare the actual DLL/DSO objects without any guarantee to be stable between runs. Throws nothing. -inline bool operator<(const smart_library& lhs, const smart_library& rhs) BOOST_NOEXCEPT { +inline bool operator<(const smart_library& lhs, const smart_library& rhs) noexcept { return lhs.shared_lib().native() < rhs.shared_lib().native(); } /// Swaps two shared libraries. Does not invalidate symbols and functions loaded from libraries. Throws nothing. -inline void swap(smart_library& lhs, smart_library& rhs) BOOST_NOEXCEPT { +inline void swap(smart_library& lhs, smart_library& rhs) noexcept { lhs.swap(rhs); }