From 013633d375b8e33b86a4495a9aba132cf5e90de2 Mon Sep 17 00:00:00 2001 From: Antony Polukhin Date: Thu, 30 Jan 2025 21:42:48 +0300 Subject: [PATCH] =?UTF-8?q?Switch=20to=20std::shared=5Fptr=20from=20boost:?= =?UTF-8?q?:shared=5Fptr=20and=20provide=20a=20BOOST=5F=E2=80=A6=20(#90)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit …DLL_USE_BOOST_SHARED_PTR compatibility macro to restore the old behavior Fixes https://github.com/boostorg/dll/issues/75 --- .github/workflows/ci.yml | 28 ++++++------ CMakeLists.txt | 1 - build.jam | 1 - example/getting_started.cpp | 4 +- example/tutorial5/load_all.cpp | 1 - include/boost/dll/config.hpp | 27 ++++++++++++ include/boost/dll/import.hpp | 51 ++++++++++++---------- include/boost/dll/import_mangled.hpp | 58 ++++++++++++------------- test/Jamfile.v2 | 4 +- test/shared_library_get_symbol_test.cpp | 25 ++++++----- test/test_library.cpp | 7 ++- 11 files changed, 121 insertions(+), 86 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 3cf0d8f..6035625 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -12,6 +12,11 @@ on: env: UBSAN_OPTIONS: print_stacktrace=1 + # ASAN complains: + # ==5457==ERROR: AddressSanitizer: odr-violation (0x7f6112f03b00): + # [1] size=8 'rvalue_reference_to_internal_integer' test/test_library.cpp:122:7 in bin.v2/libs/dll/test/gcc-14/debug/x86_64/cxxstd-17-iso/threading-multi/visibility-hidden/libtest_library.so + # [2] size=8 'rvalue_reference_to_internal_integer' test/test_library.cpp:122:7 in bin.v2/libs/dll/test/gcc-14/debug/x86_64/cxxstd-17-iso/threading-multi/visibility-hidden/libtest_library.so.1.88.0 + ASAN_OPTIONS: detect_odr_violation=0 jobs: posix: @@ -19,28 +24,30 @@ jobs: fail-fast: false matrix: include: - - toolset: gcc-12 + - toolset: gcc-14 cxxstd: "11,14,17,2a" - os: ubuntu-22.04 + os: ubuntu-24.04 # UBSAN complains on vtables and fails. No ',undefined -fno-sanitize-recover=undefined' flags! cxxflags: "cxxflags=--coverage -fsanitize=address,leak -DBOOST_TRAVISCI_BUILD" linkflags: "linkflags=--coverage -lasan" launcher: "testing.launcher=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.8" - gcov_tool: "gcov-12" + gcov_tool: "gcov-14" ignore_coverage: "*/detail/pe_info.hpp */detail/macho_info.hpp */filesystem/src/*" - - toolset: gcc-12 + - toolset: gcc-14 cxxstd: "17,2a" - os: ubuntu-22.04 + os: ubuntu-24.04 # UBSAN complains on vtables and fails. No ',undefined -fno-sanitize-recover=undefined' flags! cxxflags: "cxxflags=--coverage -fsanitize=address,leak -DBOOST_DLL_USE_STD_FS -DBOOST_TRAVISCI_BUILD" linkflags: "linkflags=--coverage -lasan" launcher: "testing.launcher=LD_PRELOAD=/usr/lib/x86_64-linux-gnu/libasan.so.8" - gcov_tool: "gcov-12" + gcov_tool: "gcov-14" ignore_coverage: "*/detail/pe_info.hpp */detail/macho_info.hpp */filesystem/src/*" - toolset: clang - compiler: clang++-10 cxxstd: "11,14,17,2a" - os: ubuntu-20.04 + os: ubuntu-22.04 + - toolset: clang-18 + cxxstd: "11,14,17,2a" + os: ubuntu-24.04 #- toolset: clang # cxxstd: "11,14,17,2a" # os: macos-10.15 @@ -85,11 +92,6 @@ jobs: ./b2 -d0 headers ./b2 -j4 variant=debug tools/inspect/build - - name: Create user-config.jam - if: matrix.compiler - run: | - echo "using ${{matrix.toolset}} : : ${{matrix.compiler}} ;" > ~/user-config.jam - - name: Run tests run: | cd ../boost-root diff --git a/CMakeLists.txt b/CMakeLists.txt index 6853a65..cb91c0b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -20,7 +20,6 @@ target_link_libraries(boost_dll Boost::core Boost::filesystem Boost::predef - Boost::smart_ptr Boost::system Boost::throw_exception Boost::type_index diff --git a/build.jam b/build.jam index f5d93e2..a3508fc 100644 --- a/build.jam +++ b/build.jam @@ -11,7 +11,6 @@ constant boost_dependencies : /boost/core//boost_core /boost/filesystem//boost_filesystem /boost/predef//boost_predef - /boost/smart_ptr//boost_smart_ptr /boost/system//boost_system /boost/throw_exception//boost_throw_exception /boost/type_index//boost_type_index diff --git a/example/getting_started.cpp b/example/getting_started.cpp index 25fb3fc..a43c7f3 100644 --- a/example/getting_started.cpp +++ b/example/getting_started.cpp @@ -30,7 +30,7 @@ int main(int argc, char* argv[]) { //[getting_started_imports_c_variable // Importing pure C variable - shared_ptr c_var = dll::import_symbol( + std::shared_ptr c_var = dll::import_symbol( path_to_shared_library, "c_variable_name" ); //] @@ -64,7 +64,7 @@ int main(int argc, char* argv[]) { //[getting_started_imports_cpp_variable // Importing variable. - shared_ptr cpp_var = dll::import_symbol( + std::shared_ptr cpp_var = dll::import_symbol( path_to_shared_library, "cpp_variable_name" ); //] diff --git a/example/tutorial5/load_all.cpp b/example/tutorial5/load_all.cpp index 488d9b6..6839cd2 100644 --- a/example/tutorial5/load_all.cpp +++ b/example/tutorial5/load_all.cpp @@ -12,7 +12,6 @@ #include "../tutorial4/static_plugin.hpp" #include // for program_location() #include -#include #include #include diff --git a/include/boost/dll/config.hpp b/include/boost/dll/config.hpp index df79ab6..5ad304a 100644 --- a/include/boost/dll/config.hpp +++ b/include/boost/dll/config.hpp @@ -19,6 +19,10 @@ /// Define this macro to make Boost.DLL use C++17's std::filesystem::path and std::system_error. #define BOOST_DLL_USE_STD_FS BOOST_DLL_USE_STD_FS +/// Define this macro to make Boost.DLL use boost::shared_ptr instead of std::shared_ptr. This macro will be removed +/// after a few releases, consider migrating to std::shared_ptr. +#define BOOST_DLL_USE_BOOST_SHARED_PTR BOOST_DLL_USE_BOOST_SHARED_PTR + /// This namespace contains aliases to the Boost or C++17 classes. Aliases are configured using BOOST_DLL_USE_STD_FS macro. namespace boost { namespace dll { namespace fs { @@ -69,5 +73,28 @@ using boost::system::system_error; #endif // BOOST_DLL_USE_STD_FS + +#ifdef BOOST_DLL_USE_BOOST_SHARED_PTR + +#include + +namespace boost { namespace dll { namespace detail { + template + using shared_ptr = boost::shared_ptr; + using boost::make_shared; +}}} + +#else // BOOST_DLL_USE_STD_FS + +#include + +namespace boost { namespace dll { namespace detail { + template + using shared_ptr = std::shared_ptr; + using std::make_shared; +}}} + +#endif // BOOST_DLL_USE_STD_FS + #endif // BOOST_DLL_DETAIL_PUSH_OPTIONS_HPP diff --git a/include/boost/dll/import.hpp b/include/boost/dll/import.hpp index ea31bbd..9c7ce06 100644 --- a/include/boost/dll/import.hpp +++ b/include/boost/dll/import.hpp @@ -9,7 +9,6 @@ #define BOOST_DLL_IMPORT_HPP #include -#include #include #include // std::addressof @@ -32,10 +31,10 @@ namespace detail { template class library_function { // Copying of `boost::dll::shared_library` is very expensive, so we use a `shared_ptr` to make it faster. - boost::shared_ptr f_; + boost::dll::detail::shared_ptr f_; public: - inline library_function(const boost::shared_ptr& lib, T* func_ptr) noexcept + inline library_function(const boost::dll::detail::shared_ptr& lib, T* func_ptr) noexcept : f_(lib, func_ptr) {} @@ -55,11 +54,10 @@ namespace detail { } }; - template using import_type = typename std::conditional< std::is_object::value, - boost::shared_ptr, + boost::dll::detail::shared_ptr, boost::dll::detail::library_function >::type; } // namespace detail @@ -71,7 +69,8 @@ namespace detail { /*! -* Returns callable object or boost::shared_ptr that holds the symbol imported +* Returns callable object or std::shared_ptr (boost::shared_ptr if +* BOOST_DLL_USE_BOOST_SHARED_PTR is defined) that holds the symbol imported * from the loaded library. Returned value refcounts usage * of the loaded shared library, so that it won't get unload until all copies of return value * are not destroyed. @@ -90,7 +89,7 @@ namespace detail { * \endcode * * \code -* boost::shared_ptr i = import_symbol("test_lib.so", "integer_name"); +* std::shared_ptr i = import_symbol("test_lib.so", "integer_name"); * \endcode * * \b Template \b parameter \b T: Type of the symbol that we are going to import. Must be explicitly specified. @@ -99,7 +98,8 @@ namespace detail { * \param name Null-terminated C or C++ mangled name of the function to import. Can handle std::string, char*, const char*. * \param mode An mode that will be used on library load. * -* \return callable object if T is a function type, or boost::shared_ptr if T is an object type. +* \return callable object if T is a function type, or std::shared_ptr (boost::shared_ptr if +* BOOST_DLL_USE_BOOST_SHARED_PTR is defined) if T is an object type. * * \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded. * Overload that accepts path also throws std::bad_alloc in case of insufficient memory. @@ -110,8 +110,9 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(const boost::dll::fs::path& lib, cons { using type = boost::dll::detail::import_type; - auto p = boost::make_shared(lib, mode); - return type(p, std::addressof(p->get(name))); + auto p = boost::dll::detail::make_shared(lib, mode); + auto* addr = std::addressof(p->get(name)); + return type(std::move(p), addr); } //! \overload boost::dll::import_symbol(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) @@ -127,7 +128,7 @@ template BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(const shared_library& lib, const char* name) { using type = boost::dll::detail::import_type; - auto p = boost::make_shared(lib); + auto p = boost::dll::detail::make_shared(lib); return type(p, std::addressof(p->get(name))); } @@ -142,10 +143,11 @@ template BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(shared_library&& lib, const char* name) { using type = boost::dll::detail::import_type; - auto p = boost::make_shared( + auto p = boost::dll::detail::make_shared( std::move(lib) ); - return type(p, std::addressof(p->get(name))); + auto* addr = std::addressof(p->get(name)); + return type(std::move(p), addr); } //! \overload boost::dll::import_symbol(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) @@ -158,7 +160,8 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(shared_library&& lib, const std::stri /*! -* Returns callable object or boost::shared_ptr that holds the symbol imported +* Returns callable object or std::shared_ptr (boost::shared_ptr if +* BOOST_DLL_USE_BOOST_SHARED_PTR is defined) that holds the symbol imported * from the loaded library. Returned value refcounts usage * of the loaded shared library, so that it won't get unload until all copies of return value * are not destroyed. @@ -177,7 +180,7 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(shared_library&& lib, const std::stri * \endcode * * \code -* boost::shared_ptr i = import_alias("test_lib.so", "integer_alias_name"); +* std::shared_ptr i = import_alias("test_lib.so", "integer_alias_name"); * \endcode * * \code @@ -189,7 +192,8 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_symbol(shared_library&& lib, const std::stri * \param name Null-terminated C or C++ mangled name of the function or variable to import. Can handle std::string, char*, const char*. * \param mode An mode that will be used on library load. * -* \return callable object if T is a function type, or boost::shared_ptr if T is an object type. +* \return callable object if T is a function type, or std::shared_ptr (boost::shared_ptr if +* BOOST_DLL_USE_BOOST_SHARED_PTR is defined) if T is an object type. * * \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded. * Overload that accepts path also throws std::bad_alloc in case of insufficient memory. @@ -200,8 +204,9 @@ BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const boost::dll::fs::path& lib, const { using type = boost::dll::detail::import_type; - auto p = boost::make_shared(lib, mode); - return type(p, p->get(name)); + auto p = boost::dll::detail::make_shared(lib, mode); + auto* addr = p->get(name); + return type(std::move(p), addr); } //! \overload boost::dll::import_alias(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) @@ -217,8 +222,9 @@ template BOOST_DLL_IMPORT_RESULT_TYPE import_alias(const shared_library& lib, const char* name) { using type = boost::dll::detail::import_type; - auto p = boost::make_shared(lib); - return type(p, p->get(name)); + auto p = boost::dll::detail::make_shared(lib); + auto* addr = p->get(name); + return type(std::move(p), addr); } //! \overload boost::dll::import_alias(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) @@ -232,10 +238,11 @@ template BOOST_DLL_IMPORT_RESULT_TYPE import_alias(shared_library&& lib, const char* name) { using type = boost::dll::detail::import_type; - auto p = boost::make_shared( + auto p = boost::dll::detail::make_shared( std::move(lib) ); - return type(p, p->get(name)); + auto* addr = p->get(name); + return type(std::move(p), addr); } //! \overload boost::dll::import_alias(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) diff --git a/include/boost/dll/import_mangled.hpp b/include/boost/dll/import_mangled.hpp index 65a1ba5..bdedc07 100644 --- a/include/boost/dll/import_mangled.hpp +++ b/include/boost/dll/import_mangled.hpp @@ -19,7 +19,7 @@ # error This file requires C++11 at least! #endif -#include +#include #include #include @@ -39,10 +39,10 @@ namespace detail template class mangled_library_function { // Copying of `boost::dll::shared_library` is very expensive, so we use a `shared_ptr` to make it faster. - boost::shared_ptr lib_; + boost::dll::detail::shared_ptr lib_; function_tuple f_; public: - constexpr mangled_library_function(const boost::shared_ptr& lib, Ts*... func_ptr) noexcept + constexpr mangled_library_function(const boost::dll::detail::shared_ptr& lib, Ts*... func_ptr) noexcept : lib_(lib) , f_(func_ptr...) {} @@ -72,11 +72,11 @@ template class mangled_library_mem_fn> { // Copying of `boost::dll::shared_library` is very expensive, so we use a `shared_ptr` to make it faster. typedef mem_fn_tuple call_tuple_t; - boost::shared_ptr lib_; + boost::dll::detail::shared_ptr lib_; call_tuple_t f_; public: - constexpr mangled_library_mem_fn(const boost::shared_ptr& lib, typename Ts::mem_fn... func_ptr) noexcept + constexpr mangled_library_mem_fn(const boost::dll::detail::shared_ptr& lib, typename Ts::mem_fn... func_ptr) noexcept : lib_(lib) , f_(func_ptr...) {} @@ -111,7 +111,7 @@ struct mangled_import_type, true,false,false> //is function const std::string& name) { return type( - boost::make_shared(p.shared_lib()), + boost::dll::detail::make_shared(p.shared_lib()), std::addressof(p.get_function(name))...); } }; @@ -129,7 +129,7 @@ struct mangled_import_type, false, true, false> //is me const std::string & name, sequence * ) { - return type(boost::make_shared(p.shared_lib()), + return type(boost::dll::detail::make_shared(p.shared_lib()), p.get_mem_fn(name)...); } @@ -145,14 +145,14 @@ struct mangled_import_type, false, true, false> //is me template struct mangled_import_type, false, false, true> //is variable { - typedef boost::shared_ptr type; + typedef boost::dll::detail::shared_ptr type; static type make( const boost::dll::experimental::smart_library& p, const std::string& name) { return type( - boost::make_shared(p.shared_lib()), + boost::dll::detail::make_shared(p.shared_lib()), std::addressof(p.get_variable(name))); } @@ -175,7 +175,8 @@ struct mangled_import_type, false, false, true> //is variable */ /*! -* Returns callable object or boost::shared_ptr that holds the symbol imported +* Returns callable object or std::shared_ptr (boost::shared_ptr if +* BOOST_DLL_USE_BOOST_SHARED_PTR is defined) that holds the symbol imported * from the loaded library. Returned value refcounts usage * of the loaded shared library, so that it won't get unload until all copies of return value * are not destroyed. @@ -191,7 +192,7 @@ struct mangled_import_type, false, false, true> //is variable * \endcode * * \code -* boost::shared_ptr i = import_mangled("test_lib.so", "integer_name"); +* std::shared_ptr i = import_mangled("test_lib.so", "integer_name"); * \endcode * * Additionally you can also import overloaded symbols, including member-functions. @@ -218,7 +219,8 @@ struct mangled_import_type, false, false, true> //is variable * \param name Null-terminated C or C++ mangled name of the function to import. Can handle std::string, char*, const char*. * \param mode An mode that will be used on library load. * -* \return callable object if T is a function type, or boost::shared_ptr if T is an object type. +* \return callable object if T is a function type, or std::shared_ptr (boost::shared_ptr if +* BOOST_DLL_USE_BOOST_SHARED_PTR is defined) if T is an object type. * * \throw \forcedlinkfs{system_error} if symbol does not exist or if the DLL/DSO was not loaded. * Overload that accepts path also throws std::bad_alloc in case of insufficient memory. @@ -232,9 +234,7 @@ BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const boost::dll::fs::path& typedef typename boost::dll::experimental::detail::mangled_import_type< boost::dll::experimental::detail::sequence> type; - boost::dll::experimental::smart_library p(lib, mode); - //the load - return type::make(p, name); + return type::make(boost::dll::experimental::smart_library{lib, mode}, name); } @@ -244,7 +244,7 @@ template BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const boost::dll::fs::path& lib, const std::string& name, load_mode::type mode = load_mode::default_mode) { - return import_mangled(lib, name.c_str(), mode); + return boost::dll::experimental::import_mangled(lib, name.c_str(), mode); } //! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) @@ -258,52 +258,52 @@ BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const smart_library& lib, co //! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) template BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const smart_library& lib, const std::string& name) { - return import_mangled(lib, name.c_str()); + return boost::dll::experimental::import_mangled(lib, name.c_str()); } //! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) template BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(smart_library&& lib, const char* name) { typedef typename boost::dll::experimental::detail::mangled_import_type> type; - - return type::make(lib, name); + return type::make(std::move(lib), name); } //! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) template BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(smart_library&& lib, const std::string& name) { - return import_mangled(std::move(lib), name.c_str()); + return boost::dll::experimental::import_mangled(std::move(lib), name.c_str()); } //! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) template BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const shared_library& lib, const char* name) { typedef typename boost::dll::experimental::detail::mangled_import_type> type; - - boost::shared_ptr p = boost::make_shared(lib); - return type::boostmake(p, name); + return type::make( + boost::dll::detail::make_shared(lib), + name + ); } //! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) template BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(const shared_library& lib, const std::string& name) { - return import_mangled(lib, name.c_str()); + return boost::dll::experimental::import_mangled(lib, name.c_str()); } //! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) template BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(shared_library&& lib, const char* name) { typedef typename boost::dll::experimental::detail::mangled_import_type> type; - - boost::dll::experimental::smart_library p(std::move(lib)); - - return type::make(p, name); + return type::make( + boost::dll::experimental::smart_library{std::move(lib)}, + name + ); } //! \overload boost::dll::import(const boost::dll::fs::path& lib, const char* name, load_mode::type mode) template BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE import_mangled(shared_library&& lib, const std::string& name) { - return import_mangled(std::move(lib), name.c_str()); + return boost::dll::experimental::import_mangled(std::move(lib), name.c_str()); } #undef BOOST_DLL_MANGLED_IMPORT_RESULT_TYPE diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index d2a52c1..e743ed4 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -42,6 +42,7 @@ project hidden /boost/filesystem//boost_filesystem /boost/system//boost_system + /boost/smart_ptr//boost_smart_ptr multi BOOST_SYSTEM_NO_DEPRECATED ; @@ -79,7 +80,8 @@ project [ run broken_library_info_test.cpp : : : always_show_run_output shared ] [ run empty_library_info_test.cpp : : empty_library : always_show_run_output shared ] [ run ../example/getting_started.cpp : : getting_started_library : shared ] - [ run ../example/tutorial1/tutorial1.cpp : : my_plugin_sum : shared ] + [ run ../example/tutorial1/tutorial1.cpp : : my_plugin_sum : shared : tutorial1_std_shared_ptr ] + [ run ../example/tutorial1/tutorial1.cpp : : my_plugin_sum : shared BOOST_DLL_USE_BOOST_SHARED_PTR : tutorial1_boost_shared_ptr ] [ run ../example/tutorial2/tutorial2.cpp : : my_plugin_aggregator : shared ] [ run ../example/tutorial3/tutorial3.cpp : : my_plugin_aggregator my_plugin_sum : shared ] [ run ../example/tutorial4/load_self.cpp ../example/tutorial4/static_plugin.cpp diff --git a/test/shared_library_get_symbol_test.cpp b/test/shared_library_get_symbol_test.cpp index 5a6ff40..90f3f3d 100644 --- a/test/shared_library_get_symbol_test.cpp +++ b/test/shared_library_get_symbol_test.cpp @@ -12,6 +12,7 @@ #include #include #include +#include #include // lib functions @@ -20,7 +21,7 @@ typedef void (say_hello_func) (); typedef int (increment) (int); typedef boost::fusion::vector, std::vector, std::vector, const std::vector*, std::vector* > do_share_res_t; -typedef boost::shared_ptr (do_share_t)( +typedef std::shared_ptr (do_share_t)( std::vector v1, std::vector& v2, const std::vector& v3, @@ -67,7 +68,7 @@ void refcountable_test(boost::dll::fs::path shared_library_path) { } std::vector v1(1, 1), v2(2, 2), v3(3, 3), v4(4, 4), v5(1000, 5); - boost::shared_ptr res = f(v1, v2, v3, &v4, &v5); + auto res = f(v1, v2, v3, &v4, &v5); BOOST_TEST(at_c<0>(*res).size() == 1); BOOST_TEST(at_c<0>(*res).front() == 1); BOOST_TEST(at_c<1>(*res).size() == 2); BOOST_TEST(at_c<1>(*res).front() == 2); @@ -82,10 +83,10 @@ void refcountable_test(boost::dll::fs::path shared_library_path) { } { - boost::shared_ptr i = import_symbol(shared_library_path, "integer_g"); + auto i = import_symbol(shared_library_path, "integer_g"); BOOST_TEST(*i == 100); - boost::shared_ptr i2; + decltype(i) i2; i.swap(i2); BOOST_TEST(*i2 == 100); } @@ -105,19 +106,19 @@ void refcountable_test(boost::dll::fs::path shared_library_path) { } { - boost::shared_ptr i = import_symbol(shared_library_path, "const_integer_g"); + auto i = import_symbol(shared_library_path, "const_integer_g"); BOOST_TEST(*i == 777); - boost::shared_ptr i2 = i; + auto i2 = i; i.reset(); BOOST_TEST(*i2 == 777); } { - boost::shared_ptr s = import_alias(shared_library_path, "info"); + auto s = import_alias(shared_library_path, "info"); BOOST_TEST(*s == "I am a std::string from the test_library (Think of me as of 'Hello world'. Long 'Hello world')."); - boost::shared_ptr s2; + decltype(s) s2; s.swap(s2); BOOST_TEST(*s2 == "I am a std::string from the test_library (Think of me as of 'Hello world'. Long 'Hello world')."); } @@ -188,11 +189,11 @@ int main(int argc, char* argv[]) { BOOST_TEST(val == 15); } - int& reference_to_internal_integer = sl.get("reference_to_internal_integer"); - BOOST_TEST(reference_to_internal_integer == 0xFF0000); + int& ref_to_internal_integer = sl.get("reference_to_internal_integer"); + BOOST_TEST(ref_to_internal_integer == 0xFF0000); - int&& rvalue_reference_to_internal_integer = sl.get("rvalue_reference_to_internal_integer"); - BOOST_TEST(rvalue_reference_to_internal_integer == 0xFF0000); + int&& rvalue_ref_to_internal_integer = sl.get("rvalue_reference_to_internal_integer"); + BOOST_TEST(rvalue_ref_to_internal_integer == 0xFF0000); return boost::report_errors(); } diff --git a/test/test_library.cpp b/test/test_library.cpp index c472d85..bdb5512 100644 --- a/test/test_library.cpp +++ b/test/test_library.cpp @@ -13,11 +13,10 @@ #include #include +#include #include #include -#include -#include #include #define LIBRARY_API BOOST_SYMBOL_EXPORT @@ -49,7 +48,7 @@ namespace namespace1 { namespace namespace2 { namespace namespace3 { boost::fusion::vector, std::vector, std::vector, const std::vector*, std::vector* > do_share_res_t; - boost::shared_ptr do_share( + std::shared_ptr do_share( std::vector v1, std::vector& v2, const std::vector& v3, @@ -59,7 +58,7 @@ namespace namespace1 { namespace namespace2 { namespace namespace3 { { v2.back() = 777; v5->back() = 9990; - return boost::make_shared(v1, v2, v3, v4, v5); + return std::make_shared(v1, v2, v3, v4, v5); } std::string info("I am a std::string from the test_library (Think of me as of 'Hello world'. Long 'Hello world').");