| 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/devector.hpp> |
| 16 | #include <boost/container/deque.hpp> |
| 17 | |
| 18 | #include <boost/container/detail/container_or_allocator_rebind.hpp> |
| 19 | |
| 20 | #include "map_test.hpp" |
| 21 | #include <map> |
| 22 | |
| 23 | using namespace boost::container; |
| 24 | |
| 25 | template<class VoidAllocatorOrContainer> |
| 26 | struct GetMapContainer |
| 27 | { |
| 28 | template<class ValueType> |
| 29 | struct apply |
| 30 | { |
| 31 | typedef std::pair<ValueType, ValueType> type_t; |
| 32 | typedef flat_map< ValueType |
| 33 | , ValueType |
| 34 | , std::less<ValueType> |
| 35 | , typename boost::container::dtl::container_or_allocator_rebind<VoidAllocatorOrContainer, type_t>::type |
| 36 | > map_type; |
| 37 | |
| 38 | typedef flat_multimap< ValueType |
| 39 | , ValueType |
| 40 | , std::less<ValueType> |
| 41 | , typename boost::container::dtl::container_or_allocator_rebind<VoidAllocatorOrContainer, type_t>::type |
| 42 | > multimap_type; |
| 43 | }; |
| 44 | }; |
| 45 | |
| 46 | int main() |
| 47 | { |
| 48 | using namespace boost::container::test; |
| 49 | |
| 50 | //////////////////////////////////// |
| 51 | // Testing sequence container implementations |
| 52 | //////////////////////////////////// |
| 53 | { |
| 54 | typedef std::map<int, int> MyStdMap; |
| 55 | typedef std::multimap<int, int> MyStdMultiMap; |
| 56 | |
| 57 | if (0 != test::map_test |
| 58 | < GetMapContainer<vector<std::pair<int, int> > >::apply<int>::map_type |
| 59 | , MyStdMap |
| 60 | , GetMapContainer<vector<std::pair<int, int> > >::apply<int>::multimap_type |
| 61 | , MyStdMultiMap>()) { |
| 62 | std::cout << "Error in map_test<vector<std::pair<int, int> > >" << std::endl; |
| 63 | return 1; |
| 64 | } |
| 65 | |
| 66 | if (0 != test::map_test |
| 67 | < GetMapContainer<small_vector<std::pair<int, int>, 7> >::apply<int>::map_type |
| 68 | , MyStdMap |
| 69 | , GetMapContainer<small_vector<std::pair<int, int>, 7> >::apply<int>::multimap_type |
| 70 | , MyStdMultiMap>()) { |
| 71 | std::cout << "Error in map_test<small_vector<std::pair<int, int>, 7> >" << std::endl; |
| 72 | return 1; |
| 73 | } |
| 74 | |
| 75 | if (0 != test::map_test |
| 76 | < GetMapContainer<static_vector<std::pair<int, int>, MaxElem * 10> >::apply<int>::map_type |
| 77 | , MyStdMap |
| 78 | , GetMapContainer<static_vector<std::pair<int, int>, MaxElem * 10> >::apply<int>::multimap_type |
| 79 | , MyStdMultiMap>()) { |
| 80 | std::cout << "Error in map_test<static_vector<std::pair<int, int>, MaxElem * 10> >" << std::endl; |
| 81 | return 1; |
| 82 | } |
| 83 | |
| 84 | if (0 != test::map_test |
| 85 | < GetMapContainer<stable_vector<std::pair<int, int> > >::apply<int>::map_type |
| 86 | , MyStdMap |
| 87 | , GetMapContainer<stable_vector<std::pair<int, int> > >::apply<int>::multimap_type |
| 88 | , MyStdMultiMap>()) { |
| 89 | std::cout << "Error in map_test<stable_vector<std::pair<int, int> > >" << std::endl; |
| 90 | return 1; |
| 91 | } |
| 92 | |
| 93 | |
| 94 | if (0 != test::map_test |
| 95 | < GetMapContainer<deque<std::pair<int, int> > >::apply<int>::map_type |
| 96 | , MyStdMap |
| 97 | , GetMapContainer<deque<std::pair<int, int> > >::apply<int>::multimap_type |
| 98 | , MyStdMultiMap>()) { |
| 99 | std::cout << "Error in map_test<deque<std::pair<int, int> > >" << std::endl; |
| 100 | return 1; |
| 101 | } |
| 102 | |
| 103 | if (0 != test::map_test |
| 104 | < GetMapContainer<devector<std::pair<int, int> > >::apply<int>::map_type |
| 105 | , MyStdMap |
| 106 | , GetMapContainer<devector<std::pair<int, int> > >::apply<int>::multimap_type |
| 107 | , MyStdMultiMap>()) { |
| 108 | std::cout << "Error in map_test<vector<std::pair<int, int> > >" << std::endl; |
| 109 | return 1; |
| 110 | } |
| 111 | } |
| 112 | { |
| 113 | using namespace boost::container; |
| 114 | using boost::container::dtl::is_same; |
| 115 | |
| 116 | typedef flat_map<int, float, std::less<int>, small_vector<std::pair<int, float>, 10> > map_container_t; |
| 117 | typedef flat_multimap<int, float, std::less<int>, small_vector<std::pair<int, float>, 10> > multimap_container_t; |
| 118 | #if !defined(BOOST_NO_CXX11_TEMPLATE_ALIASES) |
| 119 | BOOST_CONTAINER_STATIC_ASSERT(( is_same<map_container_t, small_flat_map<int, float, 10> >::value )); |
| 120 | BOOST_CONTAINER_STATIC_ASSERT(( is_same<multimap_container_t, small_flat_multimap<int, float, 10> >::value )); |
| 121 | #endif |
| 122 | |
| 123 | BOOST_CONTAINER_STATIC_ASSERT(( is_same<map_container_t, small_flat_map_of<int, float, 10>::type >::value )); |
| 124 | BOOST_CONTAINER_STATIC_ASSERT(( is_same<multimap_container_t, small_flat_multimap_of<int, float, 10>::type >::value )); |
| 125 | } |
| 126 | |
| 127 | return 0; |
| 128 | } |
| 129 | |