diff --git a/include/boost/unordered_map.hpp b/include/boost/unordered_map.hpp index abb49e04..7b9af025 100644 --- a/include/boost/unordered_map.hpp +++ b/include/boost/unordered_map.hpp @@ -158,47 +158,32 @@ namespace boost base.insert(obj)); } - iterator insert(iterator hint, const value_type& obj) + iterator insert(const_iterator hint, const value_type& obj) { return iterator(base.insert(get(hint), obj)); } - const_iterator insert(const_iterator hint, const value_type& obj) - { - return const_iterator(base.insert(get(hint), obj)); - } - template void insert(InputIterator first, InputIterator last) { base.insert(first, last); } - iterator erase(iterator position) + iterator erase(const_iterator position) { return iterator(base.erase(get(position))); } - const_iterator erase(const_iterator position) - { - return const_iterator(base.erase(get(position))); - } - size_type erase(const key_type& k) { return base.erase(k); } - iterator erase(iterator first, iterator last) + iterator erase(const_iterator first, const_iterator last) { return iterator(base.erase(get(first), get(last))); } - const_iterator erase(const_iterator first, const_iterator last) - { - return const_iterator(base.erase(get(first), get(last))); - } - void clear() { base.clear(); @@ -477,47 +462,32 @@ namespace boost return iterator(base.insert(obj)); } - iterator insert(iterator hint, const value_type& obj) + iterator insert(const_iterator hint, const value_type& obj) { return iterator(base.insert(get(hint), obj)); } - const_iterator insert(const_iterator hint, const value_type& obj) - { - return const_iterator(base.insert(get(hint), obj)); - } - template void insert(InputIterator first, InputIterator last) { base.insert(first, last); } - iterator erase(iterator position) + iterator erase(const_iterator position) { return iterator(base.erase(get(position))); } - const_iterator erase(const_iterator position) - { - return const_iterator(base.erase(get(position))); - } - size_type erase(const key_type& k) { return base.erase(k); } - iterator erase(iterator first, iterator last) + iterator erase(const_iterator first, const_iterator last) { return iterator(base.erase(get(first), get(last))); } - const_iterator erase(const_iterator first, const_iterator last) - { - return const_iterator(base.erase(get(first), get(last))); - } - void clear() { base.clear(); diff --git a/include/boost/unordered_set.hpp b/include/boost/unordered_set.hpp index cb7be821..15c20c15 100644 --- a/include/boost/unordered_set.hpp +++ b/include/boost/unordered_set.hpp @@ -155,9 +155,9 @@ namespace boost base.insert(obj)); } - const_iterator insert(const_iterator hint, const value_type& obj) + iterator insert(const_iterator hint, const value_type& obj) { - return const_iterator(base.insert(get(hint), obj)); + return iterator(base.insert(get(hint), obj)); } template @@ -166,9 +166,9 @@ namespace boost base.insert(first, last); } - const_iterator erase(const_iterator position) + iterator erase(const_iterator position) { - return const_iterator(base.erase(get(position))); + return iterator(base.erase(get(position))); } size_type erase(const key_type& k) @@ -176,9 +176,9 @@ namespace boost return base.erase(k); } - const_iterator erase(const_iterator first, const_iterator last) + iterator erase(const_iterator first, const_iterator last) { - return const_iterator(base.erase(get(first), get(last))); + return iterator(base.erase(get(first), get(last))); } void clear() @@ -439,9 +439,9 @@ namespace boost return iterator(base.insert(obj)); } - const_iterator insert(const_iterator hint, const value_type& obj) + iterator insert(const_iterator hint, const value_type& obj) { - return const_iterator(base.insert(get(hint), obj)); + return iterator(base.insert(get(hint), obj)); } template @@ -450,9 +450,9 @@ namespace boost base.insert(first, last); } - const_iterator erase(const_iterator position) + iterator erase(const_iterator position) { - return const_iterator(base.erase(get(position))); + return iterator(base.erase(get(position))); } size_type erase(const key_type& k) @@ -460,9 +460,9 @@ namespace boost return base.erase(k); } - const_iterator erase(const_iterator first, const_iterator last) + iterator erase(const_iterator first, const_iterator last) { - return const_iterator(base.erase(get(first), get(last))); + return iterator(base.erase(get(first), get(last))); } void clear() diff --git a/test/objects/minimal.hpp b/test/objects/minimal.hpp index 3fd48da0..63863318 100644 --- a/test/objects/minimal.hpp +++ b/test/objects/minimal.hpp @@ -125,9 +125,9 @@ namespace minimal { friend class allocator; - T* ptr_; + T const* ptr_; - const_ptr(T* ptr) : ptr_(ptr) {} + const_ptr(T const* ptr) : ptr_(ptr) {} public: const_ptr() : ptr_(0) {} const_ptr(ptr const& x) : ptr_(x.ptr_) {} @@ -135,12 +135,12 @@ namespace minimal typedef void (const_ptr::*bool_type)() const; void this_type_does_not_support_comparisons() const {} - T& operator*() const { return *ptr_; } - T* operator->() const { return ptr_; } + T const& operator*() const { return *ptr_; } + T const* operator->() const { return ptr_; } const_ptr& operator++() { ++ptr_; return *this; } const_ptr operator++(int) { const_ptr tmp(*this); ++ptr_; return tmp; } const_ptr operator+(int s) const { return const_ptr(ptr_ + s); } - T& operator[](int s) const { return ptr_[s]; } + T const& operator[](int s) const { return ptr_[s]; } bool operator!() const { return !ptr_; } operator bool_type() const { diff --git a/test/unordered/compile_tests.cpp b/test/unordered/compile_tests.cpp index 9573b2de..7a0ba38f 100644 --- a/test/unordered/compile_tests.cpp +++ b/test/unordered/compile_tests.cpp @@ -144,10 +144,8 @@ void unordered_test(X&, Key& k, T& t, Hash& hf, Pred& eq) test::check_return_type::equals(b.hash_function()); test::check_return_type::equals(b.key_eq()); - iterator q = a.begin(); - const_iterator r = a.begin(); + const_iterator q = a.cbegin(); test::check_return_type::equals(a.insert(q, t)); - test::check_return_type::equals(a.insert(r, t)); // TODO: void return? a.insert(i, j); @@ -156,23 +154,13 @@ void unordered_test(X&, Key& k, T& t, Hash& hf, Pred& eq) BOOST_TEST(a.empty()); if(a.empty()) { a.insert(t); - q = a.begin(); + q = a.cbegin(); test::check_return_type::equals(a.erase(q)); } - BOOST_TEST(a.empty()); - if(a.empty()) { - a.insert(t); - r = a.begin(); - test::check_return_type::equals(a.erase(r)); - } - - iterator q1 = a.begin(), q2 = a.end(); + const_iterator q1 = a.cbegin(), q2 = a.cend(); test::check_return_type::equals(a.erase(q1, q2)); - const_iterator r1 = a.begin(), r2 = a.end(); - test::check_return_type::equals(a.erase(r1, r2)); - // TODO: void return? a.clear();