tree_test.cpp 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  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. #include <iostream>
  15. #include "movable_int.hpp"
  16. #include "dummy_test_allocator.hpp"
  17. using namespace boost::container;
  18. typedef std::pair<const test::movable_and_copyable_int, test::movable_and_copyable_int> pair_t;
  19. namespace boost {
  20. namespace container {
  21. //Explicit instantiation to detect compilation errors
  22. namespace dtl {
  23. //Instantiate base class as previous instantiations don't instantiate inherited members
  24. template class tree
  25. < pair_t
  26. , select1st<test::movable_and_copyable_int>
  27. , std::less<test::movable_and_copyable_int>
  28. , test::simple_allocator<pair_t>
  29. , tree_assoc_defaults
  30. >;
  31. template class tree
  32. < pair_t
  33. , select1st<test::movable_and_copyable_int>
  34. , std::less<test::movable_and_copyable_int>
  35. , std::allocator<pair_t>
  36. , tree_assoc_defaults
  37. >;
  38. template class tree
  39. < pair_t
  40. , select1st<test::movable_and_copyable_int>
  41. , std::less<test::movable_and_copyable_int>
  42. , adaptive_pool<pair_t>
  43. , tree_assoc_defaults
  44. >;
  45. template class tree
  46. < test::movable_and_copyable_int
  47. , identity<test::movable_and_copyable_int>
  48. , std::less<test::movable_and_copyable_int>
  49. , test::simple_allocator<test::movable_and_copyable_int>
  50. , tree_assoc_defaults
  51. >;
  52. template class tree
  53. < test::movable_and_copyable_int
  54. , identity<test::movable_and_copyable_int>
  55. , std::less<test::movable_and_copyable_int>
  56. , std::allocator<test::movable_and_copyable_int>
  57. , tree_assoc_defaults
  58. >;
  59. template class tree
  60. < test::movable_and_copyable_int
  61. , identity<test::movable_and_copyable_int>
  62. , std::less<test::movable_and_copyable_int>
  63. , adaptive_pool<test::movable_and_copyable_int>
  64. , tree_assoc_defaults
  65. >;
  66. } //dtl {
  67. }} //boost::container
  68. int main ()
  69. {
  70. ////////////////////////////////////
  71. // has_trivial_destructor_after_move testing
  72. ////////////////////////////////////
  73. // default
  74. {
  75. typedef boost::container::dtl::tree<int, void, std::less<int>, void, void> tree;
  76. typedef tree::allocator_type allocator_type;
  77. typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
  78. typedef tree::key_compare key_compare;
  79. if (boost::has_trivial_destructor_after_move<tree>::value !=
  80. boost::has_trivial_destructor_after_move<allocator_type>::value &&
  81. boost::has_trivial_destructor_after_move<pointer>::value &&
  82. boost::has_trivial_destructor_after_move<key_compare>::value) {
  83. std::cerr << "has_trivial_destructor_after_move(default allocator) test failed" << std::endl;
  84. return 1;
  85. }
  86. }
  87. // std::allocator
  88. {
  89. typedef boost::container::dtl::tree<int, void, std::less<int>, std::allocator<int>, void> tree;
  90. typedef tree::allocator_type allocator_type;
  91. typedef boost::container::allocator_traits<allocator_type>::pointer pointer;
  92. typedef tree::key_compare key_compare;
  93. if (boost::has_trivial_destructor_after_move<tree>::value !=
  94. boost::has_trivial_destructor_after_move<allocator_type>::value &&
  95. boost::has_trivial_destructor_after_move<pointer>::value &&
  96. boost::has_trivial_destructor_after_move<key_compare>::value) {
  97. std::cerr << "has_trivial_destructor_after_move(std::allocator) test failed" << std::endl;
  98. return 1;
  99. }
  100. }
  101. return 0;
  102. }