]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/dll/test/cpp_import_test.cpp
1 // Copyright 2016 Klemens Morgenstern
3 // Distributed under the Boost Software License, Version 1.0.
4 // (See accompanying file LICENSE_1_0.txt
5 // or copy at http://www.boost.org/LICENSE_1_0.txt)
7 // For more information, see http://www.boost.org
9 #include <boost/predef.h>
11 #if (__cplusplus >= 201402L) || (BOOST_COMP_MSVC >= BOOST_VERSION_NUMBER(14,0,0))
13 #include "../example/b2_workarounds.hpp"
15 #include <boost/dll/smart_library.hpp>
16 #include <boost/dll/import_mangled.hpp>
18 #include <boost/core/lightweight_test.hpp>
19 #include <boost/filesystem.hpp>
20 #include <boost/variant.hpp>
21 #include <boost/function.hpp>
31 int main(int argc
, char* argv
[])
33 using namespace boost::dll
;
34 using namespace boost::dll::experimental
;
35 boost::filesystem::path pt
= b2_workarounds::first_lib_from_argv(argc
, argv
);
37 BOOST_TEST(!pt
.empty());
38 std::cout
<< "Library: " << pt
<< std::endl
;
42 auto sp_variable
= import_mangled
<double>(sm
, "some_space::variable");
44 auto unscoped_var
= import_mangled
<int>(sm
, "unscoped_var");
47 auto ovl
= import_mangled
<void(int), void(double)>(sm
, "overloaded");
50 BOOST_TEST(*unscoped_var
== 12);
52 BOOST_TEST(*sp_variable
== 5.0);
54 boost::function
<void(int)> f_test
= ovl
;//test if it binds
56 BOOST_TEST(*unscoped_var
== -2);
58 sm
.add_type_alias
<override_class
>("some_space::some_class");
60 auto func
= import_mangled
<
61 override_class
, double(double, double), int(int, int),
62 volatile override_class
, int(int, int),
63 const volatile override_class
, double(double, double)>(sm
, "func");
66 override_class
*ov
= 0;
67 volatile override_class
*ovv
= ov
;
68 const volatile override_class
*ovcv
= ov
;
70 BOOST_TEST(func(ov
, 3.,2.) == 6.);
71 BOOST_TEST(func(ov
, 1,2 ) == 3 );
72 BOOST_TEST(func(ovv
, 10,2) == 8 );
73 BOOST_TEST(func(ovcv
, 9,2) == 4.5 );
75 return boost::report_errors();
79 int main() {return 0;}