flat_map_adaptor_test.cpp 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  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_map.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 "map_test.hpp"
  18. #include <map>
  19. using namespace boost::container;
  20. template<class VoidAllocatorOrContainer>
  21. struct GetMapContainer
  22. {
  23. template<class ValueType>
  24. struct apply
  25. {
  26. typedef std::pair<ValueType, ValueType> type_t;
  27. typedef flat_map< ValueType
  28. , ValueType
  29. , std::less<ValueType>
  30. , typename boost::container::dtl::container_or_allocator_rebind<VoidAllocatorOrContainer, type_t>::type
  31. > map_type;
  32. typedef flat_multimap< ValueType
  33. , ValueType
  34. , std::less<ValueType>
  35. , typename boost::container::dtl::container_or_allocator_rebind<VoidAllocatorOrContainer, type_t>::type
  36. > multimap_type;
  37. };
  38. };
  39. int main()
  40. {
  41. using namespace boost::container::test;
  42. ////////////////////////////////////
  43. // Testing sequence container implementations
  44. ////////////////////////////////////
  45. {
  46. typedef std::map<int, int> MyStdMap;
  47. typedef std::multimap<int, int> MyStdMultiMap;
  48. if (0 != test::map_test
  49. < GetMapContainer<vector<std::pair<int, int> > >::apply<int>::map_type
  50. , MyStdMap
  51. , GetMapContainer<vector<std::pair<int, int> > >::apply<int>::multimap_type
  52. , MyStdMultiMap>()) {
  53. std::cout << "Error in map_test<vector<std::pair<int, int> > >" << std::endl;
  54. return 1;
  55. }
  56. if (0 != test::map_test
  57. < GetMapContainer<small_vector<std::pair<int, int>, 7> >::apply<int>::map_type
  58. , MyStdMap
  59. , GetMapContainer<small_vector<std::pair<int, int>, 7> >::apply<int>::multimap_type
  60. , MyStdMultiMap>()) {
  61. std::cout << "Error in map_test<small_vector<std::pair<int, int>, 7> >" << std::endl;
  62. return 1;
  63. }
  64. if (0 != test::map_test
  65. < GetMapContainer<static_vector<std::pair<int, int>, MaxElem * 10> >::apply<int>::map_type
  66. , MyStdMap
  67. , GetMapContainer<static_vector<std::pair<int, int>, MaxElem * 10> >::apply<int>::multimap_type
  68. , MyStdMultiMap>()) {
  69. std::cout << "Error in map_test<static_vector<std::pair<int, int>, MaxElem * 10> >" << std::endl;
  70. return 1;
  71. }
  72. if (0 != test::map_test
  73. < GetMapContainer<stable_vector<std::pair<int, int> > >::apply<int>::map_type
  74. , MyStdMap
  75. , GetMapContainer<stable_vector<std::pair<int, int> > >::apply<int>::multimap_type
  76. , MyStdMultiMap>()) {
  77. std::cout << "Error in map_test<stable_vector<std::pair<int, int> > >" << std::endl;
  78. return 1;
  79. }
  80. if (0 != test::map_test
  81. < GetMapContainer<deque<std::pair<int, int> > >::apply<int>::map_type
  82. , MyStdMap
  83. , GetMapContainer<deque<std::pair<int, int> > >::apply<int>::multimap_type
  84. , MyStdMultiMap>()) {
  85. std::cout << "Error in map_test<deque<std::pair<int, int> > >" << std::endl;
  86. return 1;
  87. }
  88. }
  89. return 0;
  90. }