]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/variant/test/recursive_wrapper_move_test.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / variant / test / recursive_wrapper_move_test.cpp
1 // Copyright (c) 2017
2 // Mikhail Maximov
3 //
4 // Distributed under the Boost Software License, Version 1.0. (See
5 // accompanying file LICENSE_1_0.txt or copy at
6 // http://www.boost.org/LICENSE_1_0.txt)
7
8 #include "boost/config.hpp"
9 #include "boost/test/minimal.hpp"
10
11 #ifdef __cpp_inheriting_constructors
12 // Test is based on reported issue:
13 // https://svn.boost.org/trac/boost/ticket/12680
14 // GCC 6 crashed, trying to determine is boost::recursive_wrapper<Node>
15 // is_noexcept_move_constructible
16
17 #include <string>
18 #include <iterator>
19
20 #include <boost/variant.hpp>
21 #include <boost/array.hpp>
22
23 struct Leaf { };
24 struct Node;
25
26 typedef boost::variant<Leaf, boost::recursive_wrapper<Node>> TreeBase;
27
28 struct Tree : TreeBase {
29 using TreeBase::TreeBase;
30
31 template <typename Iter>
32 static Tree Create(Iter /*first*/, Iter /*last*/) { return Leaf{}; }
33 };
34
35 struct Node {
36 Tree left, right;
37 };
38
39
40 // Test from https://svn.boost.org/trac/boost/ticket/7120
41 template<class Node>
42 struct node1_type;
43
44 struct var_type;
45
46 using var_base = boost::variant<int,
47 boost::recursive_wrapper<node1_type<var_type>>
48 >;
49
50 template<class Node>
51 struct node1_type {
52 boost::array<Node, 1> children;
53 };
54
55 struct var_type : var_base {
56 using var_base::var_base;
57 };
58
59 void run() {
60 std::string input{"abracadabra"};
61 const Tree root = Tree::Create(input.begin(), input.end());
62 (void)root; // prevents unused variable warning
63
64 var_type v1 = 1;
65 (void)v1;
66 }
67
68 #else // #!ifdef __cpp_inheriting_constructors
69 // if compiler does not support inheriting constructors - does nothing
70 void run() {}
71 #endif
72
73 int test_main(int , char* [])
74 {
75 run();
76 return 0;
77 }
78