flat_tree_test.cpp 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  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/flat_tree.hpp>
  11. #include <boost/container/small_vector.hpp>
  12. #include <boost/container/stable_vector.hpp>
  13. #include <boost/container/static_vector.hpp>
  14. #include <iostream>
  15. #include "movable_int.hpp"
  16. #include "dummy_test_allocator.hpp"
  17. using namespace boost::container;
  18. typedef boost::container::dtl::pair<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. template class flat_tree
  24. < pair_t
  25. , select1st<test::movable_and_copyable_int>
  26. , std::less<test::movable_and_copyable_int>
  27. , test::simple_allocator<pair_t>
  28. >;
  29. template class flat_tree
  30. < pair_t
  31. , select1st<test::movable_and_copyable_int>
  32. , std::less<test::movable_and_copyable_int>
  33. , std::allocator<pair_t>
  34. >;
  35. template class flat_tree
  36. < pair_t
  37. , select1st<test::movable_and_copyable_int>
  38. , std::less<test::movable_and_copyable_int>
  39. , small_vector<pair_t, 10>
  40. >;
  41. template class flat_tree
  42. < pair_t
  43. , select1st<test::movable_and_copyable_int>
  44. , std::less<test::movable_and_copyable_int>
  45. , stable_vector<pair_t>
  46. >;
  47. template class flat_tree
  48. < test::movable_and_copyable_int
  49. , identity<test::movable_and_copyable_int>
  50. , std::less<test::movable_and_copyable_int>
  51. , test::simple_allocator<test::movable_and_copyable_int>
  52. >;
  53. template class flat_tree
  54. < test::movable_and_copyable_int
  55. , identity<test::movable_and_copyable_int>
  56. , std::less<test::movable_and_copyable_int>
  57. , std::allocator<test::movable_and_copyable_int>
  58. >;
  59. template class flat_tree
  60. < test::movable_and_copyable_int
  61. , identity<test::movable_and_copyable_int>
  62. , std::less<test::movable_and_copyable_int>
  63. , small_vector<test::movable_and_copyable_int, 10>
  64. >;
  65. template class flat_tree
  66. < test::movable_and_copyable_int
  67. , identity<test::movable_and_copyable_int>
  68. , std::less<test::movable_and_copyable_int>
  69. , stable_vector<test::movable_and_copyable_int>
  70. >;
  71. template class flat_tree
  72. < test::movable_and_copyable_int
  73. , identity<test::movable_and_copyable_int>
  74. , std::less<test::movable_and_copyable_int>
  75. , static_vector<test::movable_and_copyable_int, 10>
  76. >;
  77. } //dtl {
  78. }} //boost::container
  79. #if (__cplusplus > 201103L)
  80. #include <vector>
  81. namespace boost{
  82. namespace container{
  83. namespace dtl{
  84. template class flat_tree
  85. < test::movable_and_copyable_int
  86. , identity<test::movable_and_copyable_int>
  87. , std::less<test::movable_and_copyable_int>
  88. , std::vector<test::movable_and_copyable_int>
  89. >;
  90. template class flat_tree
  91. < pair_t
  92. , select1st<test::movable_and_copyable_int>
  93. , std::less<test::movable_and_copyable_int>
  94. , std::vector<pair_t>
  95. >;
  96. } //dtl {
  97. }} //boost::container
  98. #endif
  99. int main ()
  100. {
  101. ////////////////////////////////////
  102. // has_trivial_destructor_after_move testing
  103. ////////////////////////////////////
  104. // default
  105. {
  106. typedef boost::container::dtl::flat_tree<int, boost::container::dtl::identity<int>,
  107. std::less<int>, void> tree;
  108. typedef tree::container_type container_type;
  109. typedef tree::key_compare key_compare;
  110. if (boost::has_trivial_destructor_after_move<tree>::value !=
  111. boost::has_trivial_destructor_after_move<container_type>::value &&
  112. boost::has_trivial_destructor_after_move<key_compare>::value) {
  113. std::cerr << "has_trivial_destructor_after_move(default allocator) test failed" << std::endl;
  114. return 1;
  115. }
  116. }
  117. // std::allocator
  118. {
  119. typedef boost::container::dtl::flat_tree<int, boost::container::dtl::identity<int>,
  120. std::less<int>, std::allocator<int> > tree;
  121. typedef tree::container_type container_type;
  122. typedef tree::key_compare key_compare;
  123. if (boost::has_trivial_destructor_after_move<tree>::value !=
  124. boost::has_trivial_destructor_after_move<container_type>::value &&
  125. boost::has_trivial_destructor_after_move<key_compare>::value) {
  126. std::cerr << "has_trivial_destructor_after_move(std::allocator) test failed" << std::endl;
  127. return 1;
  128. }
  129. }
  130. return 0;
  131. }