]>
Commit | Line | Data |
---|---|---|
11fdf7f2 TL |
1 | //----------------------------------------------------------------------------- |
2 | // boost-libs variant/test/issue42.cpp source file | |
3 | // See http://www.boost.org for updates, documentation, and revision history. | |
4 | //----------------------------------------------------------------------------- | |
5 | // | |
92f5a8d4 | 6 | // Copyright (c) 2018-2019 Antony Polukhin |
11fdf7f2 TL |
7 | // |
8 | // Distributed under the Boost Software License, Version 1.0. (See | |
9 | // accompanying file LICENSE_1_0.txt or copy at | |
10 | // http://www.boost.org/LICENSE_1_0.txt) | |
11 | ||
12 | // Test case from https://github.com/boostorg/variant/issues/42 | |
13 | ||
14 | #include <boost/variant.hpp> | |
15 | #include <map> | |
16 | #include <memory> | |
17 | #include <vector> | |
18 | ||
19 | ||
20 | ||
21 | #ifdef BOOST_NO_CXX11_SMART_PTR | |
22 | template <class T> struct shared_ptr_like {}; | |
23 | typedef shared_ptr_like<boost::recursive_variant_> ptr_t; | |
24 | #else | |
25 | typedef std::shared_ptr<boost::recursive_variant_> ptr_t; | |
26 | #endif | |
27 | ||
28 | template <class F> | |
29 | class func{}; | |
30 | ||
31 | int main() { | |
32 | typedef boost::make_recursive_variant< | |
33 | int, | |
34 | ptr_t | |
35 | >::type node; | |
36 | ||
37 | node x = 1; | |
38 | (void)x; | |
39 | ||
40 | ||
41 | typedef boost::make_recursive_variant< | |
42 | std::string, int, double, bool, | |
43 | ptr_t, | |
44 | std::map<const std::string, boost::recursive_variant_>, | |
45 | std::vector<boost::recursive_variant_> | |
46 | >::type node2; | |
47 | ||
48 | node2 x2 = 1; | |
49 | (void)x2; | |
50 | ||
51 | ||
52 | typedef boost::make_recursive_variant< | |
53 | int, | |
54 | func<boost::recursive_variant_(*)(boost::recursive_variant_&, const boost::recursive_variant_&)>, | |
55 | boost::recursive_variant_&(*)(boost::recursive_variant_, boost::recursive_variant_*), | |
56 | ptr_t | |
57 | >::type node3; | |
58 | ||
59 | node3 x3 = func<node3(*)(node3&, const node3&)>(); | |
60 | (void)x3; | |
61 | } |