diff --git a/include/boost/container/flat_map.hpp b/include/boost/container/flat_map.hpp index 6df2266..02388ca 100644 --- a/include/boost/container/flat_map.hpp +++ b/include/boost/container/flat_map.hpp @@ -156,7 +156,11 @@ class flat_map //! //! Complexity: Constant. flat_map() - : m_flat_tree() {} + : m_flat_tree() + { + //Allocator type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } //! Effects: Constructs an empty flat_map using the specified //! comparison object and allocator. @@ -164,14 +168,20 @@ class flat_map //! Complexity: Constant. explicit flat_map(const Compare& comp, const allocator_type& a = allocator_type()) : m_flat_tree(comp, container_detail::force(a)) - {} + { + //Allocator type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } //! Effects: Constructs an empty flat_map using the specified allocator. //! //! Complexity: Constant. explicit flat_map(const allocator_type& a) : m_flat_tree(container_detail::force(a)) - {} + { + //Allocator type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } //! Effects: Constructs an empty flat_map using the specified comparison object and //! allocator, and inserts elements from the range [first ,last ). @@ -182,7 +192,10 @@ class flat_map flat_map(InputIterator first, InputIterator last, const Compare& comp = Compare(), const allocator_type& a = allocator_type()) : m_flat_tree(true, first, last, comp, container_detail::force(a)) - {} + { + //Allocator type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } //! Effects: Constructs an empty flat_map using the specified comparison object and //! allocator, and inserts elements from the ordered unique range [first ,last). This function @@ -198,13 +211,20 @@ class flat_map flat_map( ordered_unique_range_t, InputIterator first, InputIterator last , const Compare& comp = Compare(), const allocator_type& a = allocator_type()) : m_flat_tree(ordered_range, first, last, comp, a) - {} + { + //Allocator type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } //! Effects: Copy constructs a flat_map. //! //! Complexity: Linear in x.size(). flat_map(const flat_map& x) - : m_flat_tree(x.m_flat_tree) {} + : m_flat_tree(x.m_flat_tree) + { + //Allocator type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } //! Effects: Move constructs a flat_map. //! Constructs *this using x's resources. @@ -214,14 +234,20 @@ class flat_map //! Postcondition: x is emptied. flat_map(BOOST_RV_REF(flat_map) x) : m_flat_tree(boost::move(x.m_flat_tree)) - {} + { + //Allocator type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } //! Effects: Copy constructs a flat_map using the specified allocator. //! //! Complexity: Linear in x.size(). flat_map(const flat_map& x, const allocator_type &a) : m_flat_tree(x.m_flat_tree, a) - {} + { + //Allocator type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } //! Effects: Move constructs a flat_map using the specified allocator. //! Constructs *this using x's resources. @@ -229,7 +255,10 @@ class flat_map //! Complexity: Constant if x.get_allocator() == a, linear otherwise. flat_map(BOOST_RV_REF(flat_map) x, const allocator_type &a) : m_flat_tree(boost::move(x.m_flat_tree), a) - {} + { + //Allocator type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } //! Effects: Makes *this a copy of x. //! @@ -993,7 +1022,11 @@ class flat_multimap //! //! Complexity: Constant. flat_multimap() - : m_flat_tree() {} + : m_flat_tree() + { + //Allocator type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } //! Effects: Constructs an empty flat_multimap using the specified comparison //! object and allocator. @@ -1002,14 +1035,20 @@ class flat_multimap explicit flat_multimap(const Compare& comp, const allocator_type& a = allocator_type()) : m_flat_tree(comp, container_detail::force(a)) - {} + { + //Allocator type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } //! Effects: Constructs an empty flat_multimap using the specified allocator. //! //! Complexity: Constant. explicit flat_multimap(const allocator_type& a) : m_flat_tree(container_detail::force(a)) - {} + { + //Allocator type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } //! Effects: Constructs an empty flat_multimap using the specified comparison object //! and allocator, and inserts elements from the range [first ,last ). @@ -1021,7 +1060,10 @@ class flat_multimap const Compare& comp = Compare(), const allocator_type& a = allocator_type()) : m_flat_tree(false, first, last, comp, container_detail::force(a)) - {} + { + //Allocator type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } //! Effects: Constructs an empty flat_multimap using the specified comparison object and //! allocator, and inserts elements from the ordered range [first ,last). This function @@ -1037,13 +1079,20 @@ class flat_multimap const Compare& comp = Compare(), const allocator_type& a = allocator_type()) : m_flat_tree(ordered_range, first, last, comp, a) - {} + { + //Allocator type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } //! Effects: Copy constructs a flat_multimap. //! //! Complexity: Linear in x.size(). flat_multimap(const flat_multimap& x) - : m_flat_tree(x.m_flat_tree) { } + : m_flat_tree(x.m_flat_tree) + { + //Allocator type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } //! Effects: Move constructs a flat_multimap. Constructs *this using x's resources. //! @@ -1052,14 +1101,20 @@ class flat_multimap //! Postcondition: x is emptied. flat_multimap(BOOST_RV_REF(flat_multimap) x) : m_flat_tree(boost::move(x.m_flat_tree)) - {} + { + //Allocator type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } //! Effects: Copy constructs a flat_multimap using the specified allocator. //! //! Complexity: Linear in x.size(). flat_multimap(const flat_multimap& x, const allocator_type &a) : m_flat_tree(x.m_flat_tree, a) - {} + { + //Allocator type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } //! Effects: Move constructs a flat_multimap using the specified allocator. //! Constructs *this using x's resources. @@ -1067,7 +1122,10 @@ class flat_multimap //! Complexity: Constant if a == x.get_allocator(), linear otherwise. flat_multimap(BOOST_RV_REF(flat_multimap) x, const allocator_type &a) : m_flat_tree(boost::move(x.m_flat_tree), a) - { } + { + //Allocator type must be std::pair + BOOST_STATIC_ASSERT((container_detail::is_same, typename Allocator::value_type>::value)); + } //! Effects: Makes *this a copy of x. //! diff --git a/test/flat_map_test.cpp b/test/flat_map_test.cpp index d3ac20e..de9978b 100644 --- a/test/flat_map_test.cpp +++ b/test/flat_map_test.cpp @@ -187,31 +187,37 @@ void test_move() } template -class flat_tree_propagate_test_wrapper - : public container_detail::flat_tree, std::less, A> +class flat_map_propagate_test_wrapper + : public boost::container::flat_map + < T, T, std::less + , typename boost::container::allocator_traits::template + portable_rebind_alloc< std::pair >::type> { - BOOST_COPYABLE_AND_MOVABLE(flat_tree_propagate_test_wrapper) - typedef container_detail::flat_tree, std::less, A> Base; + BOOST_COPYABLE_AND_MOVABLE(flat_map_propagate_test_wrapper) + typedef boost::container::flat_map + < T, T, std::less + , typename boost::container::allocator_traits::template + portable_rebind_alloc< std::pair >::type> Base; public: - flat_tree_propagate_test_wrapper() + flat_map_propagate_test_wrapper() : Base() {} - flat_tree_propagate_test_wrapper(const flat_tree_propagate_test_wrapper &x) + flat_map_propagate_test_wrapper(const flat_map_propagate_test_wrapper &x) : Base(x) {} - flat_tree_propagate_test_wrapper(BOOST_RV_REF(flat_tree_propagate_test_wrapper) x) + flat_map_propagate_test_wrapper(BOOST_RV_REF(flat_map_propagate_test_wrapper) x) : Base(boost::move(static_cast(x))) {} - flat_tree_propagate_test_wrapper &operator=(BOOST_COPY_ASSIGN_REF(flat_tree_propagate_test_wrapper) x) + flat_map_propagate_test_wrapper &operator=(BOOST_COPY_ASSIGN_REF(flat_map_propagate_test_wrapper) x) { this->Base::operator=(x); return *this; } - flat_tree_propagate_test_wrapper &operator=(BOOST_RV_REF(flat_tree_propagate_test_wrapper) x) + flat_map_propagate_test_wrapper &operator=(BOOST_RV_REF(flat_map_propagate_test_wrapper) x) { this->Base::operator=(boost::move(static_cast(x))); return *this; } - void swap(flat_tree_propagate_test_wrapper &x) + void swap(flat_map_propagate_test_wrapper &x) { this->Base::swap(x); } }; @@ -429,7 +435,7 @@ int main() return 1; if(!boost::container::test::test_emplace, MapOptions>()) return 1; - if(!boost::container::test::test_propagate_allocator()) + if(!boost::container::test::test_propagate_allocator()) return 1; return 0; diff --git a/test/flat_set_test.cpp b/test/flat_set_test.cpp index c901ec2..717191b 100644 --- a/test/flat_set_test.cpp +++ b/test/flat_set_test.cpp @@ -164,31 +164,31 @@ void test_move() } template -class flat_tree_propagate_test_wrapper - : public container_detail::flat_tree, std::less, A> +class flat_set_propagate_test_wrapper + : public boost::container::flat_set, A> { - BOOST_COPYABLE_AND_MOVABLE(flat_tree_propagate_test_wrapper) - typedef container_detail::flat_tree, std::less, A> Base; + BOOST_COPYABLE_AND_MOVABLE(flat_set_propagate_test_wrapper) + typedef boost::container::flat_set, A> Base; public: - flat_tree_propagate_test_wrapper() + flat_set_propagate_test_wrapper() : Base() {} - flat_tree_propagate_test_wrapper(const flat_tree_propagate_test_wrapper &x) + flat_set_propagate_test_wrapper(const flat_set_propagate_test_wrapper &x) : Base(x) {} - flat_tree_propagate_test_wrapper(BOOST_RV_REF(flat_tree_propagate_test_wrapper) x) + flat_set_propagate_test_wrapper(BOOST_RV_REF(flat_set_propagate_test_wrapper) x) : Base(boost::move(static_cast(x))) {} - flat_tree_propagate_test_wrapper &operator=(BOOST_COPY_ASSIGN_REF(flat_tree_propagate_test_wrapper) x) + flat_set_propagate_test_wrapper &operator=(BOOST_COPY_ASSIGN_REF(flat_set_propagate_test_wrapper) x) { this->Base::operator=(x); return *this; } - flat_tree_propagate_test_wrapper &operator=(BOOST_RV_REF(flat_tree_propagate_test_wrapper) x) + flat_set_propagate_test_wrapper &operator=(BOOST_RV_REF(flat_set_propagate_test_wrapper) x) { this->Base::operator=(boost::move(static_cast(x))); return *this; } - void swap(flat_tree_propagate_test_wrapper &x) + void swap(flat_set_propagate_test_wrapper &x) { this->Base::swap(x); } }; @@ -404,7 +404,7 @@ int main() return 1; if(!boost::container::test::test_emplace, SetOptions>()) return 1; - if(!boost::container::test::test_propagate_allocator()) + if(!boost::container::test::test_propagate_allocator()) return 1; return 0; diff --git a/test/map_test.cpp b/test/map_test.cpp index 05a3dce..21c53d3 100644 --- a/test/map_test.cpp +++ b/test/map_test.cpp @@ -166,31 +166,39 @@ void test_move() } template -class tree_propagate_test_wrapper - : public container_detail::tree, std::less, A, red_black_tree> +class map_propagate_test_wrapper + : public boost::container::map + < T, T, std::less + , typename boost::container::allocator_traits::template + portable_rebind_alloc< std::pair >::type + , red_black_tree> { - BOOST_COPYABLE_AND_MOVABLE(tree_propagate_test_wrapper) - typedef container_detail::tree, std::less, A, red_black_tree> Base; + BOOST_COPYABLE_AND_MOVABLE(map_propagate_test_wrapper) + typedef boost::container::map + < T, T, std::less + , typename boost::container::allocator_traits::template + portable_rebind_alloc< std::pair >::type + , red_black_tree> Base; public: - tree_propagate_test_wrapper() + map_propagate_test_wrapper() : Base() {} - tree_propagate_test_wrapper(const tree_propagate_test_wrapper &x) + map_propagate_test_wrapper(const map_propagate_test_wrapper &x) : Base(x) {} - tree_propagate_test_wrapper(BOOST_RV_REF(tree_propagate_test_wrapper) x) + map_propagate_test_wrapper(BOOST_RV_REF(map_propagate_test_wrapper) x) : Base(boost::move(static_cast(x))) {} - tree_propagate_test_wrapper &operator=(BOOST_COPY_ASSIGN_REF(tree_propagate_test_wrapper) x) + map_propagate_test_wrapper &operator=(BOOST_COPY_ASSIGN_REF(map_propagate_test_wrapper) x) { this->Base::operator=(x); return *this; } - tree_propagate_test_wrapper &operator=(BOOST_RV_REF(tree_propagate_test_wrapper) x) + map_propagate_test_wrapper &operator=(BOOST_RV_REF(map_propagate_test_wrapper) x) { this->Base::operator=(boost::move(static_cast(x))); return *this; } - void swap(tree_propagate_test_wrapper &x) + void swap(map_propagate_test_wrapper &x) { this->Base::swap(x); } }; @@ -315,7 +323,7 @@ int main () return 1; if(!boost::container::test::test_emplace, MapOptions>()) return 1; - if(!boost::container::test::test_propagate_allocator()) + if(!boost::container::test::test_propagate_allocator()) return 1; return 0; diff --git a/test/scoped_allocator_usage_test.cpp b/test/scoped_allocator_usage_test.cpp index f8dafa4..058d997 100644 --- a/test/scoped_allocator_usage_test.cpp +++ b/test/scoped_allocator_usage_test.cpp @@ -114,9 +114,9 @@ typedef multiset, AllocIntAllocator> MultiSet; //[multi]flat_map/set typedef std::pair FlatMapNode; typedef scoped_allocator_adaptor > FlatMapAllocator; -typedef flat_map, MapAllocator> FlatMap; +typedef flat_map, FlatMapAllocator> FlatMap; typedef flat_set, AllocIntAllocator> FlatSet; -typedef flat_multimap, MapAllocator> FlatMultiMap; +typedef flat_multimap, FlatMapAllocator> FlatMultiMap; typedef flat_multiset, AllocIntAllocator> FlatMultiSet; //vector, deque, list, slist, stable_vector. diff --git a/test/set_test.cpp b/test/set_test.cpp index acd42db..c604343 100644 --- a/test/set_test.cpp +++ b/test/set_test.cpp @@ -144,31 +144,31 @@ void test_move() } template -class tree_propagate_test_wrapper - : public container_detail::tree, std::less, A, red_black_tree> +class set_propagate_test_wrapper + : public boost::container::set, A, red_black_tree> { - BOOST_COPYABLE_AND_MOVABLE(tree_propagate_test_wrapper) - typedef container_detail::tree, std::less, A, red_black_tree> Base; + BOOST_COPYABLE_AND_MOVABLE(set_propagate_test_wrapper) + typedef boost::container::set, A, red_black_tree> Base; public: - tree_propagate_test_wrapper() + set_propagate_test_wrapper() : Base() {} - tree_propagate_test_wrapper(const tree_propagate_test_wrapper &x) + set_propagate_test_wrapper(const set_propagate_test_wrapper &x) : Base(x) {} - tree_propagate_test_wrapper(BOOST_RV_REF(tree_propagate_test_wrapper) x) + set_propagate_test_wrapper(BOOST_RV_REF(set_propagate_test_wrapper) x) : Base(boost::move(static_cast(x))) {} - tree_propagate_test_wrapper &operator=(BOOST_COPY_ASSIGN_REF(tree_propagate_test_wrapper) x) + set_propagate_test_wrapper &operator=(BOOST_COPY_ASSIGN_REF(set_propagate_test_wrapper) x) { this->Base::operator=(x); return *this; } - tree_propagate_test_wrapper &operator=(BOOST_RV_REF(tree_propagate_test_wrapper) x) + set_propagate_test_wrapper &operator=(BOOST_RV_REF(set_propagate_test_wrapper) x) { this->Base::operator=(boost::move(static_cast(x))); return *this; } - void swap(tree_propagate_test_wrapper &x) + void swap(set_propagate_test_wrapper &x) { this->Base::swap(x); } }; @@ -291,7 +291,7 @@ int main () return 1; if(!boost::container::test::test_emplace, SetOptions>()) return 1; - if(!boost::container::test::test_propagate_allocator()) + if(!boost::container::test::test_propagate_allocator()) return 1; return 0;