• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/core/lightweight_test.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 
19 #include <boost/variant.hpp>
20 #include <boost/array.hpp>
21 
22 struct Leaf { };
23 struct Node;
24 
25 typedef boost::variant<Leaf, boost::recursive_wrapper<Node>> TreeBase;
26 
27 struct Tree : TreeBase {
28   using TreeBase::TreeBase;
29 
30   template <typename Iter>
CreateTree31   static Tree Create(Iter /*first*/, Iter /*last*/) { return Leaf{}; }
32 };
33 
34 struct Node {
35   Tree left, right;
36 };
37 
38 
39 // Test from https://svn.boost.org/trac/boost/ticket/7120
40 template<class Node>
41 struct node1_type;
42 
43 struct var_type;
44 
45 using var_base = boost::variant<int,
46   boost::recursive_wrapper<node1_type<var_type>>
47 >;
48 
49 template<class Node>
50 struct node1_type {
51   boost::array<Node, 1> children;
52 };
53 
54 struct var_type : var_base {
55   using var_base::var_base;
56 };
57 
run()58 void run() {
59   std::string input{"abracadabra"};
60   const Tree root = Tree::Create(input.begin(), input.end());
61   (void)root; // prevents unused variable warning
62 
63   var_type v1 = 1;
64   (void)v1;
65 }
66 
67 #else // #!ifdef __cpp_inheriting_constructors
68 // if compiler does not support inheriting constructors - does nothing
run()69 void run() {}
70 #endif
71 
main()72 int main()
73 {
74     run();
75     return boost::report_errors();
76 }
77 
78