flat_set_adaptor_test.cpp 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (C) Copyright Ion Gaztanaga 2004-2019. 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/flat_set.hpp>
  11. #include <boost/container/small_vector.hpp>
  12. #include <boost/container/static_vector.hpp>
  13. #include <boost/container/stable_vector.hpp>
  14. #include <boost/container/vector.hpp>
  15. #include <boost/container/deque.hpp>
  16. #include <boost/container/detail/container_or_allocator_rebind.hpp>
  17. #include "set_test.hpp"
  18. #include <set>
  19. using namespace boost::container;
  20. template<class VoidAllocatorOrContainer>
  21. struct GetSetContainer
  22. {
  23. template<class ValueType>
  24. struct apply
  25. {
  26. typedef flat_set < ValueType
  27. , std::less<ValueType>
  28. , typename boost::container::dtl::container_or_allocator_rebind<VoidAllocatorOrContainer, ValueType>::type
  29. > set_type;
  30. typedef flat_multiset < ValueType
  31. , std::less<ValueType>
  32. , typename boost::container::dtl::container_or_allocator_rebind<VoidAllocatorOrContainer, ValueType>::type
  33. > multiset_type;
  34. };
  35. };
  36. int main()
  37. {
  38. using namespace boost::container::test;
  39. ////////////////////////////////////
  40. // Testing sequence container implementations
  41. ////////////////////////////////////
  42. {
  43. typedef std::set<int> MyStdSet;
  44. typedef std::multiset<int> MyStdMultiSet;
  45. if (0 != test::set_test
  46. < GetSetContainer<vector<int> >::apply<int>::set_type
  47. , MyStdSet
  48. , GetSetContainer<vector<int> >::apply<int>::multiset_type
  49. , MyStdMultiSet>()) {
  50. std::cout << "Error in set_test<vector<int> >" << std::endl;
  51. return 1;
  52. }
  53. if (0 != test::set_test
  54. < GetSetContainer<small_vector<int, 7> >::apply<int>::set_type
  55. , MyStdSet
  56. , GetSetContainer<small_vector<int, 7> >::apply<int>::multiset_type
  57. , MyStdMultiSet>()) {
  58. std::cout << "Error in set_test<small_vector<int, 7> >" << std::endl;
  59. return 1;
  60. }
  61. if (0 != test::set_test
  62. < GetSetContainer<static_vector<int, MaxElem * 10> >::apply<int>::set_type
  63. , MyStdSet
  64. , GetSetContainer<static_vector<int, MaxElem * 10> >::apply<int>::multiset_type
  65. , MyStdMultiSet>()) {
  66. std::cout << "Error in set_test<static_vector<int, MaxElem * 10> >" << std::endl;
  67. return 1;
  68. }
  69. if (0 != test::set_test
  70. < GetSetContainer<stable_vector<int> >::apply<int>::set_type
  71. , MyStdSet
  72. , GetSetContainer<stable_vector<int> >::apply<int>::multiset_type
  73. , MyStdMultiSet>()) {
  74. std::cout << "Error in set_test<stable_vector<int> >" << std::endl;
  75. return 1;
  76. }
  77. if (0 != test::set_test
  78. < GetSetContainer<deque<int> >::apply<int>::set_type
  79. , MyStdSet
  80. , GetSetContainer<deque<int> >::apply<int>::multiset_type
  81. , MyStdMultiSet>()) {
  82. std::cout << "Error in set_test<deque<int> >" << std::endl;
  83. return 1;
  84. }
  85. }
  86. return 0;
  87. }