• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/map.hpp>
11 #include <boost/container/adaptive_pool.hpp>
12 
13 #include <map>
14 
15 #include "print_container.hpp"
16 #include "movable_int.hpp"
17 #include "dummy_test_allocator.hpp"
18 #include "map_test.hpp"
19 #include "propagate_allocator_test.hpp"
20 #include "emplace_test.hpp"
21 #include "../../intrusive/test/iterator_test.hpp"
22 
23 using namespace boost::container;
24 
25 typedef std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> pair_t;
26 
27 class recursive_map
28 {
29    public:
operator =(const recursive_map & x)30    recursive_map & operator=(const recursive_map &x)
31    {  id_ = x.id_;  map_ = x.map_; return *this;  }
32 
33    int id_;
34    map<recursive_map, recursive_map> map_;
35    map<recursive_map, recursive_map>::iterator it_;
36    map<recursive_map, recursive_map>::const_iterator cit_;
37    map<recursive_map, recursive_map>::reverse_iterator rit_;
38    map<recursive_map, recursive_map>::const_reverse_iterator crit_;
39 
operator <(const recursive_map & a,const recursive_map & b)40    friend bool operator< (const recursive_map &a, const recursive_map &b)
41    {  return a.id_ < b.id_;   }
42 };
43 
44 class recursive_multimap
45 {
46    public:
operator =(const recursive_multimap & x)47    recursive_multimap & operator=(const recursive_multimap &x)
48    {  id_ = x.id_;  multimap_ = x.multimap_; return *this;  }
49 
50    int id_;
51    multimap<recursive_multimap, recursive_multimap> multimap_;
52    multimap<recursive_multimap, recursive_multimap>::iterator it_;
53    multimap<recursive_multimap, recursive_multimap>::const_iterator cit_;
54    multimap<recursive_multimap, recursive_multimap>::reverse_iterator rit_;
55    multimap<recursive_multimap, recursive_multimap>::const_reverse_iterator crit_;
56 
operator <(const recursive_multimap & a,const recursive_multimap & b)57    friend bool operator< (const recursive_multimap &a, const recursive_multimap &b)
58    {  return a.id_ < b.id_;   }
59 };
60 
61 template<class C>
test_move()62 void test_move()
63 {
64    //Now test move semantics
65    C original;
66    original.emplace();
67    C move_ctor(boost::move(original));
68    C move_assign;
69    move_assign.emplace();
70    move_assign = boost::move(move_ctor);
71    move_assign.swap(original);
72 }
73 
node_type_test()74 bool node_type_test()
75 {
76    using namespace boost::container;
77    {
78       typedef map<test::movable_int, test::movable_int> map_type;
79       map_type src;
80       {
81          test::movable_int mv_1(1), mv_2(2), mv_3(3), mv_11(11), mv_12(12), mv_13(13);
82          src.try_emplace(boost::move(mv_1), boost::move(mv_11));
83          src.try_emplace(boost::move(mv_2), boost::move(mv_12));
84          src.try_emplace(boost::move(mv_3), boost::move(mv_13));
85       }
86       if(src.size() != 3)
87          return false;
88 
89       map_type dst;
90       {
91          test::movable_int mv_3(3), mv_33(33);
92          dst.try_emplace(boost::move(mv_3), boost::move(mv_33));
93       }
94 
95       if(dst.size() != 1)
96          return false;
97 
98       const test::movable_int mv_1(1);
99       const test::movable_int mv_2(2);
100       const test::movable_int mv_3(3);
101       const test::movable_int mv_33(33);
102       const test::movable_int mv_13(13);
103       map_type::insert_return_type r;
104 
105       r = dst.insert(src.extract(mv_33)); // Key version, try to insert empty node
106       if(! (r.position == dst.end() && r.inserted == false && r.node.empty()) )
107          return false;
108       r = dst.insert(src.extract(src.find(mv_1))); // Iterator version, successful
109       if(! (r.position == dst.find(mv_1) && r.inserted == true && r.node.empty()) )
110          return false;
111       r = dst.insert(dst.begin(), src.extract(mv_2)); // Key type version, successful
112       if(! (r.position == dst.find(mv_2) && r.inserted == true && r.node.empty()) )
113          return false;
114       r = dst.insert(src.extract(mv_3)); // Key type version, unsuccessful
115 
116       if(!src.empty())
117          return false;
118       if(dst.size() != 3)
119          return false;
120       if(! (r.position == dst.find(mv_3) && r.inserted == false && r.node.key() == mv_3 && r.node.mapped() == mv_13) )
121          return false;
122    }
123 
124    {
125       typedef multimap<test::movable_int, test::movable_int> multimap_type;
126       multimap_type src;
127       {
128          test::movable_int mv_1(1), mv_2(2), mv_3(3), mv_3bis(3), mv_11(11), mv_12(12), mv_13(13), mv_23(23);
129          src.emplace(boost::move(mv_1), boost::move(mv_11));
130          src.emplace(boost::move(mv_2), boost::move(mv_12));
131          src.emplace(boost::move(mv_3), boost::move(mv_13));
132          src.emplace_hint(src.begin(), boost::move(mv_3bis), boost::move(mv_23));
133       }
134       if(src.size() != 4)
135          return false;
136 
137       multimap_type dst;
138       {
139          test::movable_int mv_3(3), mv_33(33);
140          dst.emplace(boost::move(mv_3), boost::move(mv_33));
141       }
142 
143       if(dst.size() != 1)
144          return false;
145 
146       const test::movable_int mv_1(1);
147       const test::movable_int mv_2(2);
148       const test::movable_int mv_3(3);
149       const test::movable_int mv_4(4);
150       const test::movable_int mv_33(33);
151       const test::movable_int mv_13(13);
152       const test::movable_int mv_23(23);
153       multimap_type::iterator r;
154 
155       multimap_type::node_type nt(src.extract(mv_3));
156       r = dst.insert(dst.begin(), boost::move(nt));
157       if(! (r->first == mv_3 && r->second == mv_23 && dst.find(mv_3) == r && nt.empty()) )
158          return false;
159 
160       nt = src.extract(src.find(mv_1));
161       r = dst.insert(boost::move(nt)); // Iterator version, successful
162       if(! (r->first == mv_1 && nt.empty()) )
163          return false;
164 
165       nt = src.extract(mv_2);
166       r = dst.insert(boost::move(nt)); // Key type version, successful
167       if(! (r->first == mv_2 && nt.empty()) )
168          return false;
169 
170       r = dst.insert(src.extract(mv_3)); // Key type version, successful
171       if(! (r->first == mv_3 && r->second == mv_13 && r == --multimap_type::iterator(dst.upper_bound(mv_3)) && nt.empty()) )
172          return false;
173 
174       r = dst.insert(src.extract(mv_4)); // Key type version, unsuccessful
175       if(! (r == dst.end()) )
176          return false;
177 
178       if(!src.empty())
179          return false;
180       if(dst.size() != 5)
181          return false;
182    }
183    return true;
184 }
185 
186 template<class VoidAllocator, boost::container::tree_type_enum tree_type_value>
187 struct GetAllocatorMap
188 {
189    template<class ValueType>
190    struct apply
191    {
192       typedef map< ValueType
193                  , ValueType
194                  , std::less<ValueType>
195                  , typename allocator_traits<VoidAllocator>
196                     ::template portable_rebind_alloc< std::pair<const ValueType, ValueType> >::type
197                   , typename boost::container::tree_assoc_options
198                         < boost::container::tree_type<tree_type_value>
199                         >::type
200                  > map_type;
201 
202       typedef multimap< ValueType
203                  , ValueType
204                  , std::less<ValueType>
205                  , typename allocator_traits<VoidAllocator>
206                     ::template portable_rebind_alloc< std::pair<const ValueType, ValueType> >::type
207                   , typename boost::container::tree_assoc_options
208                         < boost::container::tree_type<tree_type_value>
209                         >::type
210                  > multimap_type;
211    };
212 };
213 
214 struct boost_container_map;
215 struct boost_container_multimap;
216 
217 namespace boost { namespace container {   namespace test {
218 
219 template<>
220 struct alloc_propagate_base<boost_container_map>
221 {
222    template <class T, class Allocator>
223    struct apply
224    {
225       typedef typename boost::container::allocator_traits<Allocator>::
226          template portable_rebind_alloc<std::pair<const T, T> >::type TypeAllocator;
227       typedef boost::container::map<T, T, std::less<T>, TypeAllocator> type;
228    };
229 };
230 
231 template<>
232 struct alloc_propagate_base<boost_container_multimap>
233 {
234    template <class T, class Allocator>
235    struct apply
236    {
237       typedef typename boost::container::allocator_traits<Allocator>::
238          template portable_rebind_alloc<std::pair<const T, T> >::type TypeAllocator;
239       typedef boost::container::multimap<T, T, std::less<T>, TypeAllocator> type;
240    };
241 };
242 
test_merge_from_different_comparison()243 void test_merge_from_different_comparison()
244 {
245    map<int, int> map1;
246    map<int, int, std::greater<int> > map2;
247    map1.merge(map2);
248 }
249 
test_heterogeneous_lookups()250 bool test_heterogeneous_lookups()
251 {
252    typedef map<int, char, less_transparent> map_t;
253    typedef multimap<int, char, less_transparent> mmap_t;
254    typedef map_t::value_type value_type;
255 
256    map_t map1;
257    mmap_t mmap1;
258 
259    const map_t &cmap1 = map1;
260    const mmap_t &cmmap1 = mmap1;
261 
262    if(!map1.insert_or_assign(1, 'a').second)
263       return false;
264    if( map1.insert_or_assign(1, 'b').second)
265       return false;
266    if(!map1.insert_or_assign(2, 'c').second)
267       return false;
268    if( map1.insert_or_assign(2, 'd').second)
269       return false;
270    if(!map1.insert_or_assign(3, 'e').second)
271       return false;
272 
273    if(map1.insert_or_assign(1, 'a').second)
274       return false;
275    if(map1.insert_or_assign(1, 'b').second)
276       return false;
277    if(map1.insert_or_assign(2, 'c').second)
278       return false;
279    if(map1.insert_or_assign(2, 'd').second)
280       return false;
281    if(map1.insert_or_assign(3, 'e').second)
282       return false;
283 
284    mmap1.insert(value_type(1, 'a'));
285    mmap1.insert(value_type(1, 'b'));
286    mmap1.insert(value_type(2, 'c'));
287    mmap1.insert(value_type(2, 'd'));
288    mmap1.insert(value_type(3, 'e'));
289 
290    const test::non_copymovable_int find_me(2);
291 
292    //find
293    if(map1.find(find_me)->second != 'd')
294       return false;
295    if(cmap1.find(find_me)->second != 'd')
296       return false;
297    if(mmap1.find(find_me)->second != 'c')
298       return false;
299    if(cmmap1.find(find_me)->second != 'c')
300       return false;
301 
302    //count
303    if(map1.count(find_me) != 1)
304       return false;
305    if(cmap1.count(find_me) != 1)
306       return false;
307    if(mmap1.count(find_me) != 2)
308       return false;
309    if(cmmap1.count(find_me) != 2)
310       return false;
311 
312    //contains
313    if(!map1.contains(find_me))
314       return false;
315    if(!cmap1.contains(find_me))
316       return false;
317    if(!mmap1.contains(find_me))
318       return false;
319    if(!cmmap1.contains(find_me))
320       return false;
321 
322    //lower_bound
323    if(map1.lower_bound(find_me)->second != 'd')
324       return false;
325    if(cmap1.lower_bound(find_me)->second != 'd')
326       return false;
327    if(mmap1.lower_bound(find_me)->second != 'c')
328       return false;
329    if(cmmap1.lower_bound(find_me)->second != 'c')
330       return false;
331 
332    //upper_bound
333    if(map1.upper_bound(find_me)->second != 'e')
334       return false;
335    if(cmap1.upper_bound(find_me)->second != 'e')
336       return false;
337    if(mmap1.upper_bound(find_me)->second != 'e')
338       return false;
339    if(cmmap1.upper_bound(find_me)->second != 'e')
340       return false;
341 
342    //equal_range
343    if(map1.equal_range(find_me).first->second != 'd')
344       return false;
345    if(cmap1.equal_range(find_me).second->second != 'e')
346       return false;
347    if(mmap1.equal_range(find_me).first->second != 'c')
348       return false;
349    if(cmmap1.equal_range(find_me).second->second != 'e')
350       return false;
351 
352    return true;
353 }
354 
constructor_template_auto_deduction_test()355 bool constructor_template_auto_deduction_test()
356 {
357 
358 #ifndef BOOST_CONTAINER_NO_CXX17_CTAD
359    using namespace boost::container;
360    const std::size_t NumElements = 100;
361    {
362       std::map<int, int> int_map;
363       for(std::size_t i = 0; i != NumElements; ++i){
364          int_map.insert(std::map<int, int>::value_type(static_cast<int>(i), static_cast<int>(i)));
365       }
366       std::multimap<int, int> int_mmap;
367       for (std::size_t i = 0; i != NumElements; ++i) {
368          int_mmap.insert(std::multimap<int, int>::value_type(static_cast<int>(i), static_cast<int>(i)));
369       }
370 
371       typedef std::less<int> comp_int_t;
372       typedef std::allocator<std::pair<const int, int> > alloc_pair_int_t;
373 
374       //range
375       {
376          auto fmap = map(int_map.begin(), int_map.end());
377          if (!CheckEqualContainers(int_map, fmap))
378             return false;
379          auto fmmap = multimap(int_mmap.begin(), int_mmap.end());
380          if (!CheckEqualContainers(int_mmap, fmmap))
381             return false;
382       }
383       //range+comp
384       {
385          auto fmap = map(int_map.begin(), int_map.end(), comp_int_t());
386          if (!CheckEqualContainers(int_map, fmap))
387             return false;
388          auto fmmap = multimap(int_mmap.begin(), int_mmap.end(), comp_int_t());
389          if (!CheckEqualContainers(int_mmap, fmmap))
390             return false;
391       }
392       //range+comp+alloc
393       {
394          auto fmap = map(int_map.begin(), int_map.end(), comp_int_t(), alloc_pair_int_t());
395          if (!CheckEqualContainers(int_map, fmap))
396             return false;
397          auto fmmap = multimap(int_mmap.begin(), int_mmap.end(), comp_int_t(), alloc_pair_int_t());
398          if (!CheckEqualContainers(int_mmap, fmmap))
399             return false;
400       }
401       //range+alloc
402       {
403          auto fmap = map(int_map.begin(), int_map.end(), alloc_pair_int_t());
404          if (!CheckEqualContainers(int_map, fmap))
405             return false;
406          auto fmmap = multimap(int_mmap.begin(), int_mmap.end(), alloc_pair_int_t());
407          if (!CheckEqualContainers(int_mmap, fmmap))
408             return false;
409       }
410 
411       //ordered_unique_range / ordered_range
412 
413       //range
414       {
415          auto fmap = map(ordered_unique_range, int_map.begin(), int_map.end());
416          if(!CheckEqualContainers(int_map, fmap))
417             return false;
418          auto fmmap = multimap(ordered_range, int_mmap.begin(), int_mmap.end());
419          if(!CheckEqualContainers(int_mmap, fmmap))
420             return false;
421       }
422       //range+comp
423       {
424          auto fmap = map(ordered_unique_range, int_map.begin(), int_map.end(), comp_int_t());
425          if (!CheckEqualContainers(int_map, fmap))
426             return false;
427          auto fmmap = multimap(ordered_range, int_mmap.begin(), int_mmap.end(), comp_int_t());
428          if (!CheckEqualContainers(int_mmap, fmmap))
429             return false;
430       }
431       //range+comp+alloc
432       {
433          auto fmap = map(ordered_unique_range, int_map.begin(), int_map.end(), comp_int_t(), alloc_pair_int_t());
434          if (!CheckEqualContainers(int_map, fmap))
435             return false;
436          auto fmmap = multimap(ordered_range, int_mmap.begin(), int_mmap.end(), comp_int_t(), alloc_pair_int_t());
437          if (!CheckEqualContainers(int_mmap, fmmap))
438             return false;
439       }
440       //range+alloc
441       {
442          auto fmap = map(ordered_unique_range, int_map.begin(), int_map.end(),alloc_pair_int_t());
443          if (!CheckEqualContainers(int_map, fmap))
444             return false;
445          auto fmmap = multimap(ordered_range, int_mmap.begin(), int_mmap.end(),alloc_pair_int_t());
446          if (!CheckEqualContainers(int_mmap, fmmap))
447             return false;
448       }
449    }
450 #endif
451 
452    return true;
453 }
454 
455 }}}   //namespace boost::container::test
456 
main()457 int main ()
458 {
459    //Recursive container instantiation
460    {
461       map<recursive_map, recursive_map> map_;
462       multimap<recursive_multimap, recursive_multimap> multimap_;
463    }
464    //Allocator argument container
465    {
466       map<int, int> map_((map<int, int>::allocator_type()));
467       multimap<int, int> multimap_((multimap<int, int>::allocator_type()));
468    }
469    //Now test move semantics
470    {
471       test_move<map<recursive_map, recursive_map> >();
472       test_move<multimap<recursive_multimap, recursive_multimap> >();
473    }
474 
475    //Test std::pair value type as tree has workarounds to make old std::pair
476    //implementations movable that can break things
477    {
478       boost::container::map<pair_t, pair_t> s;
479       std::pair<const pair_t,pair_t> p;
480       s.insert(p);
481       s.emplace(p);
482    }
483 
484    ////////////////////////////////////
485    //    Testing allocator implementations
486    ////////////////////////////////////
487    {
488       typedef std::map<int, int>                                     MyStdMap;
489       typedef std::multimap<int, int>                                MyStdMultiMap;
490 
491       if (0 != test::map_test
492          < GetAllocatorMap<std::allocator<void>, red_black_tree>::apply<int>::map_type
493          , MyStdMap
494          , GetAllocatorMap<std::allocator<void>, red_black_tree>::apply<int>::multimap_type
495          , MyStdMultiMap>()) {
496          std::cout << "Error in map_test<std::allocator<void>, red_black_tree>" << std::endl;
497          return 1;
498       }
499 
500       if (0 != test::map_test
501          < GetAllocatorMap<new_allocator<void>, avl_tree>::apply<int>::map_type
502          , MyStdMap
503          , GetAllocatorMap<new_allocator<void>, avl_tree>::apply<int>::multimap_type
504          , MyStdMultiMap>()) {
505          std::cout << "Error in map_test<new_allocator<void>, avl_tree>" << std::endl;
506          return 1;
507       }
508 
509       if (0 != test::map_test
510          < GetAllocatorMap<adaptive_pool<void>, scapegoat_tree>::apply<int>::map_type
511          , MyStdMap
512          , GetAllocatorMap<adaptive_pool<void>, scapegoat_tree>::apply<int>::multimap_type
513          , MyStdMultiMap>()) {
514          std::cout << "Error in map_test<adaptive_pool<void>, scapegoat_tree>" << std::endl;
515          return 1;
516       }
517 
518       ///////////
519 
520      if (0 != test::map_test
521          < GetAllocatorMap<new_allocator<void>, splay_tree>::apply<test::movable_int>::map_type
522          , MyStdMap
523          , GetAllocatorMap<new_allocator<void>, splay_tree>::apply<test::movable_int>::multimap_type
524          , MyStdMultiMap>()) {
525          std::cout << "Error in map_test<new_allocator<void>, splay_tree>" << std::endl;
526          return 1;
527       }
528 
529       if (0 != test::map_test
530          < GetAllocatorMap<new_allocator<void>, red_black_tree>::apply<test::copyable_int>::map_type
531          , MyStdMap
532          , GetAllocatorMap<new_allocator<void>, red_black_tree>::apply<test::copyable_int>::multimap_type
533          , MyStdMultiMap>()) {
534          std::cout << "Error in map_test<new_allocator<void>, red_black_tree>" << std::endl;
535          return 1;
536       }
537 
538       if (0 != test::map_test
539          < GetAllocatorMap<new_allocator<void>, red_black_tree>::apply<test::movable_and_copyable_int>::map_type
540          , MyStdMap
541          , GetAllocatorMap<new_allocator<void>, red_black_tree>::apply<test::movable_and_copyable_int>::multimap_type
542          , MyStdMultiMap>()) {
543          std::cout << "Error in map_test<new_allocator<void>, red_black_tree>" << std::endl;
544          return 1;
545       }
546    }
547 
548    ////////////////////////////////////
549    //    Emplace testing
550    ////////////////////////////////////
551    const test::EmplaceOptions MapOptions = (test::EmplaceOptions)(test::EMPLACE_HINT_PAIR | test::EMPLACE_ASSOC_PAIR);
552    if(!boost::container::test::test_emplace<map<test::EmplaceInt, test::EmplaceInt>, MapOptions>())
553       return 1;
554    if(!boost::container::test::test_emplace<multimap<test::EmplaceInt, test::EmplaceInt>, MapOptions>())
555       return 1;
556 
557    ////////////////////////////////////
558    //    Allocator propagation testing
559    ////////////////////////////////////
560    if(!boost::container::test::test_propagate_allocator<boost_container_map>())
561       return 1;
562 
563    if(!boost::container::test::test_propagate_allocator<boost_container_multimap>())
564       return 1;
565 
566    if (!boost::container::test::test_map_support_for_initialization_list_for<map<int, int> >())
567       return 1;
568 
569    if (!boost::container::test::test_map_support_for_initialization_list_for<multimap<int, int> >())
570       return 1;
571 
572    ////////////////////////////////////
573    //    Iterator testing
574    ////////////////////////////////////
575    {
576       typedef boost::container::map<int, int> cont_int;
577       cont_int a; a.insert(cont_int::value_type(0, 9)); a.insert(cont_int::value_type(1, 9)); a.insert(cont_int::value_type(2, 9));
578       boost::intrusive::test::test_iterator_bidirectional< cont_int >(a);
579       if(boost::report_errors() != 0) {
580          return 1;
581       }
582    }
583    {
584       typedef boost::container::multimap<int, int> cont_int;
585       cont_int a; a.insert(cont_int::value_type(0, 9)); a.insert(cont_int::value_type(1, 9)); a.insert(cont_int::value_type(2, 9));
586       boost::intrusive::test::test_iterator_bidirectional< cont_int >(a);
587       if(boost::report_errors() != 0) {
588          return 1;
589       }
590    }
591 
592    ////////////////////////////////////
593    //    Node extraction/insertion testing functions
594    ////////////////////////////////////
595    if(!node_type_test())
596       return 1;
597 
598    ////////////////////////////////////
599    //    Constructor Template Auto Deduction test
600    ////////////////////////////////////
601    if (!test::constructor_template_auto_deduction_test()) {
602       return 1;
603    }
604 
605    if (!boost::container::test::instantiate_constructors<map<int, int>, multimap<int, int> >())
606       return 1;
607 
608    test::test_merge_from_different_comparison();
609 
610    if(!test::test_heterogeneous_lookups())
611       return 1;
612 
613    ////////////////////////////////////
614    //    Test optimize_size option
615    ////////////////////////////////////
616    //
617    // map
618    //
619    typedef map< int*, int*, std::less<int*>, std::allocator< std::pair<int *const, int*> >
620               , tree_assoc_options< optimize_size<false>, tree_type<red_black_tree> >::type > rbmap_size_optimized_no;
621 
622    typedef map< int*, int*, std::less<int*>, std::allocator< std::pair<int *const, int*> >
623               , tree_assoc_options< optimize_size<true>, tree_type<avl_tree>  >::type > avlmap_size_optimized_yes;
624    //
625    // multimap
626    //
627    typedef multimap< int*, int*, std::less<int*>, std::allocator< std::pair<int *const, int*> >
628                    , tree_assoc_options< optimize_size<true>, tree_type<red_black_tree>  >::type > rbmmap_size_optimized_yes;
629    typedef multimap< int*, int*, std::less<int*>, std::allocator< std::pair<int *const, int*> >
630                    , tree_assoc_options< optimize_size<false>, tree_type<avl_tree> >::type > avlmmap_size_optimized_no;
631 
632    BOOST_STATIC_ASSERT(sizeof(rbmmap_size_optimized_yes) < sizeof(rbmap_size_optimized_no));
633    BOOST_STATIC_ASSERT(sizeof(avlmap_size_optimized_yes) < sizeof(avlmmap_size_optimized_no));
634 
635    ////////////////////////////////////
636    //    has_trivial_destructor_after_move testing
637    ////////////////////////////////////
638    {
639       typedef std::pair<const int, int> value_type;
640       //
641       // map
642       //
643       // default allocator
644       {
645          typedef boost::container::map<int, int> cont;
646          typedef boost::container::dtl::tree<value_type, int, std::less<int>, void, void> tree;
647          if (boost::has_trivial_destructor_after_move<cont>::value !=
648              boost::has_trivial_destructor_after_move<tree>::value) {
649             std::cerr << "has_trivial_destructor_after_move(map, default allocator) test failed" << std::endl;
650             return 1;
651          }
652       }
653       // std::allocator
654       {
655          typedef boost::container::map<int, int, std::less<int>, std::allocator<value_type> > cont;
656          typedef boost::container::dtl::tree<value_type, int, std::less<int>, std::allocator<value_type>, void> tree;
657          if (boost::has_trivial_destructor_after_move<cont>::value !=
658              boost::has_trivial_destructor_after_move<tree>::value) {
659             std::cerr << "has_trivial_destructor_after_move(map, std::allocator) test failed" << std::endl;
660             return 1;
661          }
662       }
663       //
664       // multimap
665       //
666       // default allocator
667       {
668          //       default allocator
669          typedef boost::container::multimap<int, int> cont;
670          typedef boost::container::dtl::tree<value_type, int, std::less<int>, void, void> tree;
671          if (boost::has_trivial_destructor_after_move<cont>::value !=
672              boost::has_trivial_destructor_after_move<tree>::value) {
673             std::cerr << "has_trivial_destructor_after_move(multimap, default allocator) test failed" << std::endl;
674             return 1;
675          }
676       }
677       // std::allocator
678       {
679          typedef boost::container::multimap<int, int, std::less<int>, std::allocator<value_type> > cont;
680          typedef boost::container::dtl::tree<value_type, int, std::less<int>, std::allocator<value_type>, void> tree;
681          if (boost::has_trivial_destructor_after_move<cont>::value !=
682              boost::has_trivial_destructor_after_move<tree>::value) {
683             std::cerr << "has_trivial_destructor_after_move(multimap, std::allocator) test failed" << std::endl;
684             return 1;
685          }
686       }
687    }
688 
689    return 0;
690 }
691