]> git.proxmox.com Git - ceph.git/blame - ceph/src/boost/libs/dll/test/test_library.cpp
import new upstream nautilus stable release 14.2.8
[ceph.git] / ceph / src / boost / libs / dll / test / test_library.cpp
CommitLineData
7c673cae
FG
1// Copyright 2011-2012 Renato Tegon Forti
2// Copyright 2014 Renato Tegon Forti, Antony Polukhin.
92f5a8d4 3// Copyright 2015-2019 Antony Polukhin.
7c673cae
FG
4//
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt
7// or copy at http://www.boost.org/LICENSE_1_0.txt)
8
9// For more information, see http://www.boost.org
10
11// MinGW related workaround
12#define BOOST_DLL_FORCE_ALIAS_INSTANTIATION
13
92f5a8d4 14#include <boost/dll/config.hpp>
7c673cae
FG
15#include <boost/dll/alias.hpp>
16#include <iostream>
17#include <vector>
18
19#include <boost/shared_ptr.hpp>
20#include <boost/make_shared.hpp>
21#include <boost/fusion/container.hpp>
22
23#define LIBRARY_API BOOST_SYMBOL_EXPORT
24
25extern "C" void LIBRARY_API say_hello(void);
26extern "C" float LIBRARY_API lib_version(void);
27extern "C" int LIBRARY_API increment(int);
28
29extern "C" int LIBRARY_API integer_g;
30extern "C" const int LIBRARY_API const_integer_g = 777;
31
32namespace foo {
33 std::size_t bar(const std::vector<int>& v) {
34 return v.size();
35 }
36
37 std::size_t variable = 42;
38}
39
40
41
42// Make sure that aliases have no problems with memory allocations and different types of input parameters
43namespace namespace1 { namespace namespace2 { namespace namespace3 {
44 typedef
45 boost::fusion::vector<std::vector<int>, std::vector<int>, std::vector<int>, const std::vector<int>*, std::vector<int>* >
46 do_share_res_t;
47
48 boost::shared_ptr<do_share_res_t> do_share(
49 std::vector<int> v1,
50 std::vector<int>& v2,
51 const std::vector<int>& v3,
52 const std::vector<int>* v4,
53 std::vector<int>* v5
54 )
55 {
56 v2.back() = 777;
57 v5->back() = 9990;
58 return boost::make_shared<do_share_res_t>(v1, v2, v3, v4, v5);
59 }
60
61 std::string info("I am a std::string from the test_library (Think of me as of 'Hello world'. Long 'Hello world').");
62
63 int& ref_returning_function() {
64 static int i = 0;
65 return i;
66 }
67}}}
68
69
70
71BOOST_DLL_ALIAS(foo::bar, foo_bar)
72BOOST_DLL_ALIAS(foo::variable, foo_variable)
73BOOST_DLL_ALIAS(namespace1::namespace2::namespace3::do_share, do_share)
74BOOST_DLL_ALIAS(namespace1::namespace2::namespace3::info, info)
75BOOST_DLL_ALIAS(const_integer_g, const_integer_g_alias)
76BOOST_DLL_ALIAS(namespace1::namespace2::namespace3::ref_returning_function, ref_returning_function)
77
78
79
80int integer_g = 100;
81
82void say_hello(void)
83{
84 std::cout << "Hello, Boost.Application!" << std::endl;
85}
86
87float lib_version(void)
88{
89 return 1.0;
90}
91
92int increment(int n)
93{
94 return ++n;
95}
96
97#include <boost/dll/runtime_symbol_info.hpp>
98
92f5a8d4 99boost::dll::fs::path this_module_location_from_itself() {
7c673cae
FG
100 return boost::dll::this_line_location();
101}
102
103BOOST_DLL_ALIAS(this_module_location_from_itself, module_location_from_itself)
104
105
106
107int internal_integer_i = 0xFF0000;
108extern "C" LIBRARY_API int& reference_to_internal_integer;
109int& reference_to_internal_integer = internal_integer_i;
110
111#ifndef BOOST_NO_RVALUE_REFERENCES
112extern "C" LIBRARY_API int&& rvalue_reference_to_internal_integer;
113int&& rvalue_reference_to_internal_integer = static_cast<int&&>(internal_integer_i);
114#endif
115