// Copyright 2019 Ramil Gauss. // Copyright 2019 Antony Polukhin. // // Distributed under the Boost Software License, Version 1.0. // (See accompanying file LICENSE_1_0.txt // or copy at http://www.boost.org/LICENSE_1_0.txt) #include #if (__cplusplus >= 201402L) || (BOOST_COMP_MSVC >= BOOST_VERSION_NUMBER(14,0,0)) #include #include #include #include #include #include "../example/b2_workarounds.hpp" #include namespace space { class BOOST_SYMBOL_EXPORT my_plugin { public: template BOOST_SYMBOL_EXPORT int Func(); // defined in cpp_test_library.cpp }; } int main(int argc, char** argv) { unsigned matches_found = 0; boost::dll::fs::path lib_path = b2_workarounds::first_lib_from_argv(argc, argv); boost::dll::experimental::smart_library lib(lib_path); auto storage = lib.symbol_storage().get_storage(); for (auto& s : storage) { auto& demangled = s.demangled; BOOST_TEST(demangled.data()); auto beginFound = demangled.find("Func<"); if (beginFound == std::string::npos) continue; auto endFound = demangled.find("("); if (endFound == std::string::npos) continue; // Usually "Func" on Linux, "Func" on Windows. auto funcName = demangled.substr(beginFound, endFound - beginFound); std::cout << "Function name: " << funcName.data() << std::endl; auto typeIndexFunc = boost::dll::experimental::import_mangled(lib, funcName); space::my_plugin cl; BOOST_TEST_EQ(typeIndexFunc(&cl), 42); ++matches_found; break; } BOOST_TEST_EQ(matches_found, 1); return boost::report_errors(); } #else int main() {} #endif