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..bc4cbe9c 100644 --- a/example/tutorial6/on_unload_lib.cpp +++ b/example/tutorial6/on_unload_lib.cpp @@ -10,14 +10,14 @@ //[plugcpp_on_unload #include // for BOOST_DLL_ALIAS -#include +#include #include namespace my_namespace { struct on_unload { - typedef boost::function callback_t; - typedef on_unload this_type; + using callback_t = std::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..27169c45 100644 --- a/example/tutorial6/tutorial6.cpp +++ b/example/tutorial6/tutorial6.cpp @@ -9,10 +9,10 @@ //[callplugcpp_tutorial6 #include -#include +#include #include -typedef boost::function callback_t; +using callback_t = std::function ; void print_unloaded() { std::cout << "unloaded" << std::endl; @@ -23,16 +23,15 @@ int main(int argc, char* argv[]) { 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( - shared_library_path, "on_unload" - ); + std::function 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; // Releasing last reference to the library, so that it gets unloaded - on_unload.clear(); + on_unload = {}; 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/example/tutorial9/tutorial9.cpp b/example/tutorial9/tutorial9.cpp index 745c171d..4412cb6b 100644 --- a/example/tutorial9/tutorial9.cpp +++ b/example/tutorial9/tutorial9.cpp @@ -10,7 +10,7 @@ //[callplugcpp_tutorial9 #include // for dll::import #include // for dll::shared_library -#include +#include #include #include @@ -29,15 +29,14 @@ int main() { ); std::cout << "0.0 GetStdHandle() returned " << get_std_handle(STD_OUTPUT_HANDLE) << std::endl; - // You may put the `get_std_handle` into boost::function<>. But boost::function can not compile with + // You may put the `get_std_handle` into std::function<>. But std::function may not compile with // Signature template parameter that contains calling conventions, so you'll have to remove the calling convention. - boost::function get_std_handle2 = get_std_handle; + std::function get_std_handle2 = get_std_handle; std::cout << "0.1 GetStdHandle() returned " << get_std_handle2(STD_OUTPUT_HANDLE) << std::endl; /*<-*/ #endif /*->*/ - // OPTION #1, does not require C++11. But without C++11 dll::import<> can not handle calling conventions, - // so you'll need to hand write the import. + // OPTION #1, hand write the import. dll::shared_library lib("Kernel32.dll", dll::load_mode::search_system_folders); GetStdHandle_t& func = lib.get("GetStdHandle"); 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..5d953134 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 @@ -107,7 +84,7 @@ namespace detail { * \b Examples: * * \code -* boost::function f = import_symbol("test_lib.so", "integer_func_name"); +* std::function f = import_symbol("test_lib.so", "integer_func_name"); * * auto f_cpp11 = import_symbol("test_lib.so", "integer_func_name"); * \endcode @@ -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))); @@ -194,7 +171,7 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(shared_library&& lib, const std::stri * \b Examples: * * \code -* boost::function f = import_alias("test_lib.so", "integer_func_alias_name"); +* std::function f = import_alias("test_lib.so", "integer_func_alias_name"); * * auto f_cpp11 = import_alias("test_lib.so", "integer_func_alias_name"); * \endcode @@ -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/import_mangled.hpp b/include/boost/dll/import_mangled.hpp index a2aa7b22..c4dfe18c 100644 --- a/include/boost/dll/import_mangled.hpp +++ b/include/boost/dll/import_mangled.hpp @@ -185,7 +185,7 @@ struct mangled_import_type, false, false, true> //is variable * \b Examples: * * \code -* boost::function f = import_mangled("test_lib.so", "integer_func_name"); +* std::function f = import_mangled("test_lib.so", "integer_func_name"); * * auto f_cpp11 = import_mangled("test_lib.so", "integer_func_name"); * \endcode 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); } diff --git a/test/cpp_import_class_test.cpp b/test/cpp_import_class_test.cpp index aebeedfc..e3bc7d58 100644 --- a/test/cpp_import_class_test.cpp +++ b/test/cpp_import_class_test.cpp @@ -24,7 +24,7 @@ using namespace std; #include #include #include -#include +#include #define L cout << __LINE__ << endl; @@ -92,7 +92,7 @@ int main(int argc, char* argv[]) BOOST_TEST((cl->*fun2)(5 ,2 ) == 7 ); //test if it binds. - boost::function mem_fn_obj = func; + std::function mem_fn_obj = func; const std::type_info & ti = cl.get_type_info(); diff --git a/test/cpp_import_test.cpp b/test/cpp_import_test.cpp index 85f38cb3..ea457bb8 100644 --- a/test/cpp_import_test.cpp +++ b/test/cpp_import_test.cpp @@ -18,8 +18,8 @@ #include #include #include -#include +#include #include struct override_class @@ -51,7 +51,7 @@ int main(int argc, char* argv[]) ovl(5.0); BOOST_TEST(*sp_variable == 5.0); - boost::function f_test = ovl;//test if it binds + std::function f_test = ovl;//test if it binds f_test(-2); BOOST_TEST(*unscoped_var == -2); diff --git a/test/shared_library_get_symbol_test.cpp b/test/shared_library_get_symbol_test.cpp index 091e9897..a45c8976 100644 --- a/test/shared_library_get_symbol_test.cpp +++ b/test/shared_library_get_symbol_test.cpp @@ -11,7 +11,7 @@ #include "../example/b2_workarounds.hpp" #include #include -#include +#include #include // lib functions @@ -35,7 +35,7 @@ void refcountable_test(boost::dll::fs::path shared_library_path) { std::vector v(1000); { - boost::function sz2 + std::function sz2 = import_symbol(shared_library_path, "say_hello"); sz2(); @@ -52,17 +52,17 @@ void refcountable_test(boost::dll::fs::path shared_library_path) { #endif { - boost::function&)> sz + std::function&)> sz = import_alias&)>(shared_library_path, "foo_bar"); BOOST_TEST(sz(v) == 1000); } { - boost::function f; + std::function f; { - boost::function f2 = import_alias(shared_library_path, "do_share"); + std::function f2 = import_alias(shared_library_path, "do_share"); f = f2; } @@ -91,13 +91,13 @@ void refcountable_test(boost::dll::fs::path shared_library_path) { } { - boost::function f = import_alias(shared_library_path, "ref_returning_function"); + std::function f = import_alias(shared_library_path, "ref_returning_function"); BOOST_TEST(f() == 0); f() = 10; BOOST_TEST(f() == 10); - boost::function f1 = import_alias(shared_library_path, "ref_returning_function"); + std::function f1 = import_alias(shared_library_path, "ref_returning_function"); BOOST_TEST(f1() == 10); f1() += 10; @@ -157,7 +157,7 @@ int main(int argc, char* argv[]) { BOOST_TEST(sl.get("const_integer_g") == 777); - boost::function inc = sl.get("increment"); + std::function inc = sl.get("increment"); BOOST_TEST(inc(1) == 2); BOOST_TEST(inc(2) == 3); BOOST_TEST(inc(3) == 4); @@ -170,7 +170,7 @@ int main(int argc, char* argv[]) { // Checking aliases - boost::function&)> sz + std::function&)> sz = sl.get_alias&)>("foo_bar"); std::vector v(10);