1 //////////////////////////////////////////////////////////////////////////////
2 //
3 // (C) Copyright Ion Gaztanaga 2004-2013. Distributed under the Boost
4 // Software License, Version 1.0. (See accompanying file
5 // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 //
7 // See http://www.boost.org/libs/container for documentation.
8 //
9 //////////////////////////////////////////////////////////////////////////////
10 #include <boost/container/detail/tree.hpp>
11 #include <boost/container/adaptive_pool.hpp>
12 #include <boost/container/new_allocator.hpp>
13 #include <boost/move/traits.hpp>
14 
15 #include <iostream>
16 
17 #include "movable_int.hpp"
18 #include "dummy_test_allocator.hpp"
19 
20 using namespace boost::container;
21 
22 typedef std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> pair_t;
23 
24 namespace boost {
25 namespace container {
26 
27 //Explicit instantiation to detect compilation errors
28 
29 namespace dtl {
30 
31 //Instantiate base class as previous instantiations don't instantiate inherited members
32 template class tree
33    < pair_t
34    , select1st<test::movable_and_copyable_int>
35    , std::less<test::movable_and_copyable_int>
36    , test::simple_allocator<pair_t>
37    , tree_assoc_defaults
38    >;
39 
40 template class tree
41    < pair_t
42    , select1st<test::movable_and_copyable_int>
43    , std::less<test::movable_and_copyable_int>
44    , std::allocator<pair_t>
45    , tree_assoc_defaults
46    >;
47 
48 template class tree
49    < pair_t
50    , select1st<test::movable_and_copyable_int>
51    , std::less<test::movable_and_copyable_int>
52    , adaptive_pool<pair_t>
53    , tree_assoc_defaults
54    >;
55 
56 template class tree
57    < test::movable_and_copyable_int
58    , identity<test::movable_and_copyable_int>
59    , std::less<test::movable_and_copyable_int>
60    , test::simple_allocator<test::movable_and_copyable_int>
61    , tree_assoc_defaults
62    >;
63 
64 template class tree
65    < test::movable_and_copyable_int
66    , identity<test::movable_and_copyable_int>
67    , std::less<test::movable_and_copyable_int>
68    , std::allocator<test::movable_and_copyable_int>
69    , tree_assoc_defaults
70    >;
71 
72 template class tree
73    < test::movable_and_copyable_int
74    , identity<test::movable_and_copyable_int>
75    , std::less<test::movable_and_copyable_int>
76    , adaptive_pool<test::movable_and_copyable_int>
77    , tree_assoc_defaults
78    >;
79 
80 }  //dtl {
81 
82 }} //boost::container
83 
main()84 int main ()
85 {
86    ////////////////////////////////////
87    //    has_trivial_destructor_after_move testing
88    ////////////////////////////////////
89    // default
90    {
91       typedef boost::container::dtl::tree<int, void, std::less<int>, void, void> tree;
92       typedef tree::allocator_type allocator_type;
93       typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
94       typedef tree::key_compare key_compare;
95       if (boost::has_trivial_destructor_after_move<tree>::value !=
96           boost::has_trivial_destructor_after_move<allocator_type>::value &&
97           boost::has_trivial_destructor_after_move<pointer>::value &&
98           boost::has_trivial_destructor_after_move<key_compare>::value) {
99          std::cerr << "has_trivial_destructor_after_move(default allocator) test failed" << std::endl;
100          return 1;
101       }
102    }
103    // std::allocator
104    {
105       typedef boost::container::dtl::tree<int, void, std::less<int>, std::allocator<int>, void> tree;
106       typedef tree::allocator_type allocator_type;
107       typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
108       typedef tree::key_compare key_compare;
109       if (boost::has_trivial_destructor_after_move<tree>::value !=
110           boost::has_trivial_destructor_after_move<allocator_type>::value &&
111           boost::has_trivial_destructor_after_move<pointer>::value &&
112           boost::has_trivial_destructor_after_move<key_compare>::value) {
113          std::cerr << "has_trivial_destructor_after_move(std::allocator) test failed" << std::endl;
114          return 1;
115       }
116    }
117 
118    return 0;
119 }
120