diff --git a/libcxx/include/map b/libcxx/include/map index 29d068a501c0..d04b803ce672 100644 --- a/libcxx/include/map +++ b/libcxx/include/map @@ -1076,9 +1076,7 @@ public: insert(const_iterator __p, const value_type& __v) {return __tree_.__insert_unique(__p.__i_, __v);} -#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) - // TODO(EricWF): These functions are C++17 only but they should probably - // be exposed in C++11. +#ifndef _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY pair insert(value_type&& __v) {return __tree_.__insert_unique(_VSTD::move(__v));} @@ -1787,6 +1785,14 @@ public: iterator insert(const_iterator __pos, _Pp&& __p) {return __tree_.__insert_multi(__pos.__i_, _VSTD::forward<_Pp>(__p));} + _LIBCPP_INLINE_VISIBILITY + iterator insert(value_type&& __v) + {return __tree_.__insert_multi(_VSTD::move(__v));} + + _LIBCPP_INLINE_VISIBILITY + iterator insert(const_iterator __p, value_type&& __v) + {return __tree_.__insert_multi(__p.__i_, _VSTD::move(__v));} + #endif // _LIBCPP_CXX03_LANG _LIBCPP_INLINE_VISIBILITY @@ -1796,18 +1802,6 @@ public: iterator insert(const_iterator __p, const value_type& __v) {return __tree_.__insert_multi(__p.__i_, __v);} -#if _LIBCPP_STD_VER > 14 && !defined(_LIBCPP_HAS_NO_RVALUE_REFERENCES) - // TODO(EricWF): These functions are C++17 only but they should probably - // be exposed in C++11. - _LIBCPP_INLINE_VISIBILITY - iterator insert(value_type&& __v) - {return __tree_.__insert_multi(_VSTD::move(__v));} - - _LIBCPP_INLINE_VISIBILITY - iterator insert(const_iterator __p, value_type&& __v) - {return __tree_.__insert_multi(__p.__i_, _VSTD::move(__v));} -#endif - template _LIBCPP_INLINE_VISIBILITY void insert(_InputIterator __f, _InputIterator __l) diff --git a/libcxx/include/unordered_map b/libcxx/include/unordered_map index 372868a0df59..e0ebc6e61c79 100644 --- a/libcxx/include/unordered_map +++ b/libcxx/include/unordered_map @@ -909,7 +909,61 @@ public: _LIBCPP_INLINE_VISIBILITY const_iterator cend() const _NOEXCEPT {return __table_.end();} + _LIBCPP_INLINE_VISIBILITY + pair insert(const value_type& __x) + {return __table_.__insert_unique(__x);} + + iterator insert(const_iterator __p, const value_type& __x) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + "unordered_map::insert(const_iterator, const value_type&) called with an iterator not" + " referring to this unordered_map"); +#endif + return insert(__x).first; + } + + template + void insert(_InputIterator __first, _InputIterator __last); + +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + _LIBCPP_INLINE_VISIBILITY + void insert(initializer_list __il) + {insert(__il.begin(), __il.end());} +#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + #ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + pair insert(value_type&& __x) + {return __table_.__insert_unique(_VSTD::move(__x));} + + iterator insert(const_iterator __p, value_type&& __x) { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + "unordered_map::insert(const_iterator, const value_type&) called with an iterator not" + " referring to this unordered_map"); +#endif + return __table_.__insert_unique(_VSTD::move(__x)).first; + } + + template ::value>::type> + _LIBCPP_INLINE_VISIBILITY + pair insert(_Pp&& __x) + {return __table_.__insert_unique(_VSTD::forward<_Pp>(__x));} + + template ::value>::type> + _LIBCPP_INLINE_VISIBILITY + iterator insert(const_iterator __p, _Pp&& __x) + { +#if _LIBCPP_DEBUG_LEVEL >= 2 + _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, + "unordered_map::insert(const_iterator, value_type&&) called with an iterator not" + " referring to this unordered_map"); +#endif + return insert(_VSTD::forward<_Pp>(__x)).first; + } + template _LIBCPP_INLINE_VISIBILITY pair emplace(_Args&&... __args) { @@ -927,55 +981,7 @@ public: return __table_.__emplace_unique(_VSTD::forward<_Args>(__args)...).first; } -#endif // _LIBCPP_CXX03_LANG - - _LIBCPP_INLINE_VISIBILITY - pair insert(const value_type& __x) - {return __table_.__insert_unique(__x);} -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - template ::value>::type> - _LIBCPP_INLINE_VISIBILITY - pair insert(_Pp&& __x) - {return __table_.__insert_unique(_VSTD::forward<_Pp>(__x));} -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - _LIBCPP_INLINE_VISIBILITY -#if _LIBCPP_DEBUG_LEVEL >= 2 - iterator insert(const_iterator __p, const value_type& __x) - { - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, - "unordered_map::insert(const_iterator, const value_type&) called with an iterator not" - " referring to this unordered_map"); - return insert(__x).first; - } -#else - iterator insert(const_iterator, const value_type& __x) - {return insert(__x).first;} -#endif -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - template ::value>::type> - _LIBCPP_INLINE_VISIBILITY -#if _LIBCPP_DEBUG_LEVEL >= 2 - iterator insert(const_iterator __p, _Pp&& __x) - { - _LIBCPP_ASSERT(__get_const_db()->__find_c_from_i(&__p) == this, - "unordered_map::insert(const_iterator, value_type&&) called with an iterator not" - " referring to this unordered_map"); - return insert(_VSTD::forward<_Pp>(__x)).first; - } -#else - iterator insert(const_iterator, _Pp&& __x) - {return insert(_VSTD::forward<_Pp>(__x)).first;} -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - template - void insert(_InputIterator __first, _InputIterator __last); -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS - _LIBCPP_INLINE_VISIBILITY - void insert(initializer_list __il) - {insert(__il.begin(), __il.end());} -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS +#endif // _LIBCPP_CXX03_LANG #if _LIBCPP_STD_VER > 14 #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -1684,7 +1690,42 @@ public: _LIBCPP_INLINE_VISIBILITY const_iterator cend() const _NOEXCEPT {return __table_.end();} + _LIBCPP_INLINE_VISIBILITY + iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);} + + _LIBCPP_INLINE_VISIBILITY + iterator insert(const_iterator __p, const value_type& __x) + {return __table_.__insert_multi(__p.__i_, __x);} + + template + void insert(_InputIterator __first, _InputIterator __last); + +#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + _LIBCPP_INLINE_VISIBILITY + void insert(initializer_list __il) + {insert(__il.begin(), __il.end());} +#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS + #ifndef _LIBCPP_CXX03_LANG + _LIBCPP_INLINE_VISIBILITY + iterator insert(value_type&& __x) {return __table_.__insert_multi(_VSTD::move(__x));} + + _LIBCPP_INLINE_VISIBILITY + iterator insert(const_iterator __p, value_type&& __x) + {return __table_.__insert_multi(__p.__i_, _VSTD::move(__x));} + + template ::value>::type> + _LIBCPP_INLINE_VISIBILITY + iterator insert(_Pp&& __x) + {return __table_.__insert_multi(_VSTD::forward<_Pp>(__x));} + + template ::value>::type> + _LIBCPP_INLINE_VISIBILITY + iterator insert(const_iterator __p, _Pp&& __x) + {return __table_.__insert_multi(__p.__i_, _VSTD::forward<_Pp>(__x));} + template iterator emplace(_Args&&... __args) { return __table_.__emplace_multi(_VSTD::forward<_Args>(__args)...); @@ -1696,32 +1737,6 @@ public: } #endif // _LIBCPP_CXX03_LANG - _LIBCPP_INLINE_VISIBILITY - iterator insert(const value_type& __x) {return __table_.__insert_multi(__x);} -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - template ::value>::type> - _LIBCPP_INLINE_VISIBILITY - iterator insert(_Pp&& __x) - {return __table_.__insert_multi(_VSTD::forward<_Pp>(__x));} -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - _LIBCPP_INLINE_VISIBILITY - iterator insert(const_iterator __p, const value_type& __x) - {return __table_.__insert_multi(__p.__i_, __x);} -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - template ::value>::type> - _LIBCPP_INLINE_VISIBILITY - iterator insert(const_iterator __p, _Pp&& __x) - {return __table_.__insert_multi(__p.__i_, _VSTD::forward<_Pp>(__x));} -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - template - void insert(_InputIterator __first, _InputIterator __last); -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS - _LIBCPP_INLINE_VISIBILITY - void insert(initializer_list __il) - {insert(__il.begin(), __il.end());} -#endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS _LIBCPP_INLINE_VISIBILITY iterator erase(const_iterator __p) {return __table_.erase(__p.__i_);} diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp index 9eae62810429..d98047d02e7d 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp @@ -25,6 +25,7 @@ int main() { testMapInsert >(); + testMapInsertHint >(); testMapEmplace >(); testMapEmplaceHint >(); } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp index 3d28242fd322..e2ffcba375fa 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp @@ -16,74 +16,57 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" +template +void do_insert_cv_test() +{ + typedef Container M; + typedef std::pair R; + typedef typename M::value_type VT; + M m; + + const VT v1(2, 2.5); + R r = m.insert(v1); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 1); + assert(r.first->first == 2); + assert(r.first->second == 2.5); + + const VT v2(1, 1.5); + r = m.insert(v2); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 2); + assert(r.first->first == 1); + assert(r.first->second == 1.5); + + const VT v3(3, 3.5); + r = m.insert(v3); + assert(r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(r.first->first == 3); + assert(r.first->second == 3.5); + + const VT v4(3, 4.5); + r = m.insert(v4); + assert(!r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(r.first->first == 3); + assert(r.first->second == 3.5); +} + int main() { - { - typedef std::map M; - typedef std::pair R; - M m; - R r = m.insert(M::value_type(2, 2.5)); - assert(r.second); - assert(r.first == m.begin()); - assert(m.size() == 1); - assert(r.first->first == 2); - assert(r.first->second == 2.5); - - r = m.insert(M::value_type(1, 1.5)); - assert(r.second); - assert(r.first == m.begin()); - assert(m.size() == 2); - assert(r.first->first == 1); - assert(r.first->second == 1.5); - - r = m.insert(M::value_type(3, 3.5)); - assert(r.second); - assert(r.first == prev(m.end())); - assert(m.size() == 3); - assert(r.first->first == 3); - assert(r.first->second == 3.5); - - r = m.insert(M::value_type(3, 3.5)); - assert(!r.second); - assert(r.first == prev(m.end())); - assert(m.size() == 3); - assert(r.first->first == 3); - assert(r.first->second == 3.5); - } -#if __cplusplus >= 201103L + do_insert_cv_test >(); +#if TEST_STD_VER >= 11 { typedef std::map, min_allocator>> M; - typedef std::pair R; - M m; - R r = m.insert(M::value_type(2, 2.5)); - assert(r.second); - assert(r.first == m.begin()); - assert(m.size() == 1); - assert(r.first->first == 2); - assert(r.first->second == 2.5); - - r = m.insert(M::value_type(1, 1.5)); - assert(r.second); - assert(r.first == m.begin()); - assert(m.size() == 2); - assert(r.first->first == 1); - assert(r.first->second == 1.5); - - r = m.insert(M::value_type(3, 3.5)); - assert(r.second); - assert(r.first == prev(m.end())); - assert(m.size() == 3); - assert(r.first->first == 3); - assert(r.first->second == 3.5); - - r = m.insert(M::value_type(3, 3.5)); - assert(!r.second); - assert(r.first == prev(m.end())); - assert(m.size() == 3); - assert(r.first->first == 3); - assert(r.first->second == 3.5); + do_insert_cv_test(); } #endif } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp index 278db4631a8c..0c7e124e0d1c 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp @@ -16,66 +16,53 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" +template +void do_insert_iter_cv_test() +{ + typedef Container M; + typedef typename M::iterator R; + typedef typename M::value_type VT; + + M m; + const VT v1(2, 2.5); + R r = m.insert(m.end(), v1); + assert(r == m.begin()); + assert(m.size() == 1); + assert(r->first == 2); + assert(r->second == 2.5); + + const VT v2(1, 1.5); + r = m.insert(m.end(), v2); + assert(r == m.begin()); + assert(m.size() == 2); + assert(r->first == 1); + assert(r->second == 1.5); + + const VT v3(3, 3.5); + r = m.insert(m.end(), v3); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3.5); + + const VT v4(3, 4.5); + r = m.insert(m.end(), v4); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3.5); +} + int main() { - { - typedef std::map M; - typedef M::iterator R; - M m; - R r = m.insert(m.end(), M::value_type(2, 2.5)); - assert(r == m.begin()); - assert(m.size() == 1); - assert(r->first == 2); - assert(r->second == 2.5); - - r = m.insert(m.end(), M::value_type(1, 1.5)); - assert(r == m.begin()); - assert(m.size() == 2); - assert(r->first == 1); - assert(r->second == 1.5); - - r = m.insert(m.end(), M::value_type(3, 3.5)); - assert(r == prev(m.end())); - assert(m.size() == 3); - assert(r->first == 3); - assert(r->second == 3.5); - - r = m.insert(m.end(), M::value_type(3, 3.5)); - assert(r == prev(m.end())); - assert(m.size() == 3); - assert(r->first == 3); - assert(r->second == 3.5); - } -#if __cplusplus >= 201103L + do_insert_iter_cv_test >(); +#if TEST_STD_VER >= 11 { typedef std::map, min_allocator>> M; - typedef M::iterator R; - M m; - R r = m.insert(m.end(), M::value_type(2, 2.5)); - assert(r == m.begin()); - assert(m.size() == 1); - assert(r->first == 2); - assert(r->second == 2.5); - - r = m.insert(m.end(), M::value_type(1, 1.5)); - assert(r == m.begin()); - assert(m.size() == 2); - assert(r->first == 1); - assert(r->second == 1.5); - - r = m.insert(m.end(), M::value_type(3, 3.5)); - assert(r == prev(m.end())); - assert(m.size() == 3); - assert(r->first == 3); - assert(r->second == 3.5); - - r = m.insert(m.end(), M::value_type(3, 3.5)); - assert(r == prev(m.end())); - assert(m.size() == 3); - assert(r->first == 3); - assert(r->second == 3.5); + do_insert_iter_cv_test(); } #endif } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp index 9db1e5c70732..3edb9c06e7c0 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // class map @@ -21,70 +23,49 @@ #include "min_allocator.h" #include "test_macros.h" +template +void do_insert_iter_rv_test() +{ + typedef Container M; + typedef Pair P; + typedef typename M::iterator R; + M m; + R r = m.insert(m.end(), P(2, 2)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(r->first == 2); + assert(r->second == 2); + + r = m.insert(m.end(), P(1, 1)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(r->first == 1); + assert(r->second == 1); + + r = m.insert(m.end(), P(3, 3)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3); + + r = m.insert(m.end(), P(3, 4)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3); +} int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - { - typedef std::map M; - typedef std::pair P; - typedef M::iterator R; - M m; - R r = m.insert(m.end(), P(2, 2)); - assert(r == m.begin()); - assert(m.size() == 1); - assert(r->first == 2); - assert(r->second == 2); + do_insert_iter_rv_test, std::pair>(); + do_insert_iter_rv_test, std::pair>(); - r = m.insert(m.end(), P(1, 1)); - assert(r == m.begin()); - assert(m.size() == 2); - assert(r->first == 1); - assert(r->second == 1); - - r = m.insert(m.end(), P(3, 3)); - assert(r == prev(m.end())); - assert(m.size() == 3); - assert(r->first == 3); - assert(r->second == 3); - - r = m.insert(m.end(), P(3, 3)); - assert(r == prev(m.end())); - assert(m.size() == 3); - assert(r->first == 3); - assert(r->second == 3); - } -#if TEST_STD_VER >= 11 { typedef std::map, min_allocator>> M; typedef std::pair P; - typedef M::iterator R; - M m; - R r = m.insert(m.end(), P(2, 2)); - assert(r == m.begin()); - assert(m.size() == 1); - assert(r->first == 2); - assert(r->second == 2); - - r = m.insert(m.end(), P(1, 1)); - assert(r == m.begin()); - assert(m.size() == 2); - assert(r->first == 1); - assert(r->second == 1); - - r = m.insert(m.end(), P(3, 3)); - assert(r == prev(m.end())); - assert(m.size() == 3); - assert(r->first == 3); - assert(r->second == 3); - - r = m.insert(m.end(), P(3, 3)); - assert(r == prev(m.end())); - assert(m.size() == 3); - assert(r->first == 3); - assert(r->second == 3); + typedef std::pair CP; + do_insert_iter_rv_test(); + do_insert_iter_rv_test(); } -#endif -#if TEST_STD_VER > 14 { typedef std::map M; typedef M::iterator R; @@ -113,6 +94,5 @@ int main() assert(r->first == 3); assert(r->second == 3); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#endif + } diff --git a/libcxx/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp b/libcxx/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp index 23eb84d687ff..503d9291076d 100644 --- a/libcxx/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp +++ b/libcxx/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // class map @@ -22,76 +24,54 @@ #include "min_allocator.h" #include "test_macros.h" +template +void do_insert_rv_test() +{ + typedef Container M; + typedef Pair P; + typedef std::pair R; + M m; + R r = m.insert(P(2, 2)); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 1); + assert(r.first->first == 2); + assert(r.first->second == 2); + + r = m.insert(P(1, 1)); + assert(r.second); + assert(r.first == m.begin()); + assert(m.size() == 2); + assert(r.first->first == 1); + assert(r.first->second == 1); + + r = m.insert(P(3, 3)); + assert(r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(r.first->first == 3); + assert(r.first->second == 3); + + r = m.insert(P(3, 3)); + assert(!r.second); + assert(r.first == prev(m.end())); + assert(m.size() == 3); + assert(r.first->first == 3); + assert(r.first->second == 3); +} + int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - { - typedef std::map M; - typedef std::pair R; - M m; - R r = m.insert(M::value_type(2, 2)); - assert(r.second); - assert(r.first == m.begin()); - assert(m.size() == 1); - assert(r.first->first == 2); - assert(r.first->second == 2); + do_insert_rv_test, std::pair>(); + do_insert_rv_test, std::pair>(); - r = m.insert(M::value_type(1, 1)); - assert(r.second); - assert(r.first == m.begin()); - assert(m.size() == 2); - assert(r.first->first == 1); - assert(r.first->second == 1); - - r = m.insert(M::value_type(3, 3)); - assert(r.second); - assert(r.first == prev(m.end())); - assert(m.size() == 3); - assert(r.first->first == 3); - assert(r.first->second == 3); - - r = m.insert(M::value_type(3, 3)); - assert(!r.second); - assert(r.first == prev(m.end())); - assert(m.size() == 3); - assert(r.first->first == 3); - assert(r.first->second == 3); - } -#if TEST_STD_VER >= 11 { typedef std::map, min_allocator>> M; - typedef std::pair R; - M m; - R r = m.insert(M::value_type(2, 2)); - assert(r.second); - assert(r.first == m.begin()); - assert(m.size() == 1); - assert(r.first->first == 2); - assert(r.first->second == 2); - - r = m.insert(M::value_type(1, 1)); - assert(r.second); - assert(r.first == m.begin()); - assert(m.size() == 2); - assert(r.first->first == 1); - assert(r.first->second == 1); - - r = m.insert(M::value_type(3, 3)); - assert(r.second); - assert(r.first == prev(m.end())); - assert(m.size() == 3); - assert(r.first->first == 3); - assert(r.first->second == 3); - - r = m.insert(M::value_type(3, 3)); - assert(!r.second); - assert(r.first == prev(m.end())); - assert(m.size() == 3); - assert(r.first->first == 3); - assert(r.first->second == 3); + typedef std::pair P; + typedef std::pair CP; + do_insert_rv_test(); + do_insert_rv_test(); } -#endif -#if TEST_STD_VER > 14 { typedef std::map M; typedef std::pair R; @@ -124,6 +104,4 @@ int main() assert(r.first->first == 3); assert(r.first->second == 3); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_allocator_requirements.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_allocator_requirements.pass.cpp index d421de31767e..225bf67bb1f6 100644 --- a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_allocator_requirements.pass.cpp +++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_allocator_requirements.pass.cpp @@ -24,4 +24,5 @@ int main() { testMultimapInsert >(); + testMultimapInsertHint >(); } diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp index d9afc9d0fdf0..53874311c782 100644 --- a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp +++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp @@ -16,66 +16,54 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" +template +void do_insert_test() { + typedef Container M; + typedef typename M::iterator R; + typedef typename M::value_type VT; + M m; + const VT v1(2, 2.5); + R r = m.insert(v1); + assert(r == m.begin()); + assert(m.size() == 1); + assert(r->first == 2); + assert(r->second == 2.5); + + const VT v2(1, 1.5); + r = m.insert(v2); + assert(r == m.begin()); + assert(m.size() == 2); + assert(r->first == 1); + assert(r->second == 1.5); + + const VT v3(3, 3.5); + r = m.insert(v3); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3.5); + + const VT v4(3, 3.5); + r = m.insert(v4); + assert(r == prev(m.end())); + assert(m.size() == 4); + assert(r->first == 3); + assert(r->second == 3.5); +} + int main() { { - typedef std::multimap M; - typedef M::iterator R; - M m; - R r = m.insert(M::value_type(2, 2.5)); - assert(r == m.begin()); - assert(m.size() == 1); - assert(r->first == 2); - assert(r->second == 2.5); - - r = m.insert(M::value_type(1, 1.5)); - assert(r == m.begin()); - assert(m.size() == 2); - assert(r->first == 1); - assert(r->second == 1.5); - - r = m.insert(M::value_type(3, 3.5)); - assert(r == prev(m.end())); - assert(m.size() == 3); - assert(r->first == 3); - assert(r->second == 3.5); - - r = m.insert(M::value_type(3, 3.5)); - assert(r == prev(m.end())); - assert(m.size() == 4); - assert(r->first == 3); - assert(r->second == 3.5); + typedef std::multimap Container; + do_insert_test(); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { - typedef std::multimap, min_allocator>> M; - typedef M::iterator R; - M m; - R r = m.insert(M::value_type(2, 2.5)); - assert(r == m.begin()); - assert(m.size() == 1); - assert(r->first == 2); - assert(r->second == 2.5); - - r = m.insert(M::value_type(1, 1.5)); - assert(r == m.begin()); - assert(m.size() == 2); - assert(r->first == 1); - assert(r->second == 1.5); - - r = m.insert(M::value_type(3, 3.5)); - assert(r == prev(m.end())); - assert(m.size() == 3); - assert(r->first == 3); - assert(r->second == 3.5); - - r = m.insert(M::value_type(3, 3.5)); - assert(r == prev(m.end())); - assert(m.size() == 4); - assert(r->first == 3); - assert(r->second == 3.5); + typedef std::multimap, min_allocator>> Container; + do_insert_test(); } #endif } diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp index b83c802c04cf..05e1096cb547 100644 --- a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp +++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp @@ -16,66 +16,52 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" +template +void do_insert_hint_test() +{ + typedef Container M; + typedef typename M::iterator R; + typedef typename M::value_type VT; + M m; + const VT v1(2, 2.5); + R r = m.insert(m.end(), v1); + assert(r == m.begin()); + assert(m.size() == 1); + assert(r->first == 2); + assert(r->second == 2.5); + + const VT v2(1, 1.5); + r = m.insert(m.end(), v2); + assert(r == m.begin()); + assert(m.size() == 2); + assert(r->first == 1); + assert(r->second == 1.5); + + const VT v3(3, 3.5); + r = m.insert(m.end(), v3); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3.5); + + const VT v4(3, 4.5); + r = m.insert(prev(m.end()), v4); + assert(r == prev(m.end(), 2)); + assert(m.size() == 4); + assert(r->first == 3); + assert(r->second == 4.5); +} + int main() { - { - typedef std::multimap M; - typedef M::iterator R; - M m; - R r = m.insert(m.end(), M::value_type(2, 2.5)); - assert(r == m.begin()); - assert(m.size() == 1); - assert(r->first == 2); - assert(r->second == 2.5); - - r = m.insert(m.end(), M::value_type(1, 1.5)); - assert(r == m.begin()); - assert(m.size() == 2); - assert(r->first == 1); - assert(r->second == 1.5); - - r = m.insert(m.end(), M::value_type(3, 3.5)); - assert(r == prev(m.end())); - assert(m.size() == 3); - assert(r->first == 3); - assert(r->second == 3.5); - - r = m.insert(prev(m.end()), M::value_type(3, 4.5)); - assert(r == prev(m.end(), 2)); - assert(m.size() == 4); - assert(r->first == 3); - assert(r->second == 4.5); - } -#if __cplusplus >= 201103L + do_insert_hint_test >(); +#if TEST_STD_VER >= 11 { typedef std::multimap, min_allocator>> M; - typedef M::iterator R; - M m; - R r = m.insert(m.end(), M::value_type(2, 2.5)); - assert(r == m.begin()); - assert(m.size() == 1); - assert(r->first == 2); - assert(r->second == 2.5); - - r = m.insert(m.end(), M::value_type(1, 1.5)); - assert(r == m.begin()); - assert(m.size() == 2); - assert(r->first == 1); - assert(r->second == 1.5); - - r = m.insert(m.end(), M::value_type(3, 3.5)); - assert(r == prev(m.end())); - assert(m.size() == 3); - assert(r->first == 3); - assert(r->second == 3.5); - - r = m.insert(prev(m.end()), M::value_type(3, 4.5)); - assert(r == prev(m.end(), 2)); - assert(m.size() == 4); - assert(r->first == 3); - assert(r->second == 4.5); + do_insert_hint_test(); } #endif } diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp index 7035de83f990..47e0d371bb48 100644 --- a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp +++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // class multimap @@ -21,73 +23,53 @@ #include "min_allocator.h" #include "test_macros.h" +template +void do_insert_rv_test() +{ + typedef Container M; + typedef Pair P; + typedef typename M::iterator R; + M m; + R r = m.insert(m.cend(), P(2, 2)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(r->first == 2); + assert(r->second == 2); + + r = m.insert(m.cend(), P(1, 1)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(r->first == 1); + assert(r->second == 1); + + r = m.insert(m.cend(), P(3, 3)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3); + + r = m.insert(m.cend(), P(3, 2)); + assert(r == prev(m.end())); + assert(m.size() == 4); + assert(r->first == 3); + assert(r->second == 2); +} + int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - { - typedef std::multimap M; - typedef std::pair P; - typedef M::iterator R; - M m; - R r = m.insert(m.cend(), P(2, 2)); - assert(r == m.begin()); - assert(m.size() == 1); - assert(r->first == 2); - assert(r->second == 2); + do_insert_rv_test, std::pair >(); + do_insert_rv_test, std::pair >(); - r = m.insert(m.cend(), P(1, 1)); - assert(r == m.begin()); - assert(m.size() == 2); - assert(r->first == 1); - assert(r->second == 1); - - r = m.insert(m.cend(), P(3, 3)); - assert(r == prev(m.end())); - assert(m.size() == 3); - assert(r->first == 3); - assert(r->second == 3); - - r = m.insert(m.cend(), P(3, 2)); - assert(r == prev(m.end())); - assert(m.size() == 4); - assert(r->first == 3); - assert(r->second == 2); - } -#if TEST_STD_VER >= 11 { typedef std::multimap, min_allocator>> M; typedef std::pair P; - typedef M::iterator R; - M m; - R r = m.insert(m.cend(), P(2, 2)); - assert(r == m.begin()); - assert(m.size() == 1); - assert(r->first == 2); - assert(r->second == 2); + typedef std::pair CP; + do_insert_rv_test(); + do_insert_rv_test(); - r = m.insert(m.cend(), P(1, 1)); - assert(r == m.begin()); - assert(m.size() == 2); - assert(r->first == 1); - assert(r->second == 1); - - r = m.insert(m.cend(), P(3, 3)); - assert(r == prev(m.end())); - assert(m.size() == 3); - assert(r->first == 3); - assert(r->second == 3); - - r = m.insert(m.cend(), P(3, 2)); - assert(r == prev(m.end())); - assert(m.size() == 4); - assert(r->first == 3); - assert(r->second == 2); } -#endif -#if TEST_STD_VER > 14 { typedef std::multimap M; - typedef std::pair P; typedef M::iterator R; M m; R r = m.insert(m.cend(), {2, MoveOnly(2)}); @@ -114,6 +96,4 @@ int main() assert(r->first == 3); assert(r->second == 2); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp index 825e304f65a8..022de873f7f1 100644 --- a/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp +++ b/libcxx/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // class multimap @@ -21,68 +23,45 @@ #include "min_allocator.h" #include "test_macros.h" +template +void do_insert_rv_test() +{ + typedef std::multimap M; + typedef typename M::iterator R; + typedef typename M::value_type VT; + M m; + R r = m.insert(VT(2, 2)); + assert(r == m.begin()); + assert(m.size() == 1); + assert(r->first == 2); + assert(r->second == 2); + + r = m.insert(VT(1, 1)); + assert(r == m.begin()); + assert(m.size() == 2); + assert(r->first == 1); + assert(r->second == 1); + + r = m.insert(VT(3, 3)); + assert(r == prev(m.end())); + assert(m.size() == 3); + assert(r->first == 3); + assert(r->second == 3); + + r = m.insert(VT(3, 3)); + assert(r == prev(m.end())); + assert(m.size() == 4); + assert(r->first == 3); + assert(r->second == 3); +} + int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - { - typedef std::multimap M; - typedef M::iterator R; - M m; - R r = m.insert(M::value_type(2, 2)); - assert(r == m.begin()); - assert(m.size() == 1); - assert(r->first == 2); - assert(r->second == 2); - - r = m.insert(M::value_type(1, 1)); - assert(r == m.begin()); - assert(m.size() == 2); - assert(r->first == 1); - assert(r->second == 1); - - r = m.insert(M::value_type(3, 3)); - assert(r == prev(m.end())); - assert(m.size() == 3); - assert(r->first == 3); - assert(r->second == 3); - - r = m.insert(M::value_type(3, 3)); - assert(r == prev(m.end())); - assert(m.size() == 4); - assert(r->first == 3); - assert(r->second == 3); - } -#if TEST_STD_VER >= 11 + do_insert_rv_test>(); { typedef std::multimap, min_allocator>> M; - typedef M::iterator R; - M m; - R r = m.insert(M::value_type(2, 2)); - assert(r == m.begin()); - assert(m.size() == 1); - assert(r->first == 2); - assert(r->second == 2); - - r = m.insert(M::value_type(1, 1)); - assert(r == m.begin()); - assert(m.size() == 2); - assert(r->first == 1); - assert(r->second == 1); - - r = m.insert(M::value_type(3, 3)); - assert(r == prev(m.end())); - assert(m.size() == 3); - assert(r->first == 3); - assert(r->second == 3); - - r = m.insert(M::value_type(3, 3)); - assert(r == prev(m.end())); - assert(m.size() == 4); - assert(r->first == 3); - assert(r->second == 3); + do_insert_rv_test(); } -#endif -#if TEST_STD_VER > 14 { typedef std::multimap M; typedef M::iterator R; @@ -111,6 +90,4 @@ int main() assert(r->first == 3); assert(r->second == 3); } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/libcxx/test/std/containers/map_allocator_requirement_test_templates.h b/libcxx/test/std/containers/map_allocator_requirement_test_templates.h index 91b209d0b79a..2ae3a2e3c87a 100644 --- a/libcxx/test/std/containers/map_allocator_requirement_test_templates.h +++ b/libcxx/test/std/containers/map_allocator_requirement_test_templates.h @@ -33,6 +33,8 @@ template void testMapInsert() { typedef typename Container::value_type ValueTp; + typedef typename Container::key_type Key; + typedef typename Container::mapped_type Mapped; typedef Container C; typedef std::pair R; ConstructController* cc = getConstructController(); @@ -89,6 +91,18 @@ void testMapInsert() assert(c.insert(std::move(v2)).second == false); } } + { + CHECKPOINT("Testing C::insert({key, value})"); + Container c; + cc->expect(); + assert(c.insert({42, 1}).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const ValueTp v2(42, 1); + assert(c.insert(std::move(v2)).second == false); + } + } { CHECKPOINT("Testing C::insert(std::initializer_list)"); Container c; @@ -142,6 +156,140 @@ void testMapInsert() } } + +template +void testMapInsertHint() +{ + typedef typename Container::value_type ValueTp; + typedef typename Container::key_type Key; + typedef typename Container::mapped_type Mapped; + typedef typename std::pair NonConstKeyPair; + typedef Container C; + typedef typename C::iterator It; + ConstructController* cc = getConstructController(); + cc->reset(); + { + CHECKPOINT("Testing C::insert(p, const value_type&)"); + Container c; + const ValueTp v(42, 1); + cc->expect(); + It ret = c.insert(c.end(), v); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const ValueTp v2(42, 1); + It ret2 = c.insert(c.begin(), v2); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::insert(p, value_type&)"); + Container c; + ValueTp v(42, 1); + cc->expect(); + It ret = c.insert(c.end(), v); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + ValueTp v2(42, 1); + It ret2 = c.insert(c.begin(), v2); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::insert(p, value_type&&)"); + Container c; + ValueTp v(42, 1); + cc->expect(); + It ret = c.insert(c.end(), std::move(v)); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + ValueTp v2(42, 1); + It ret2 = c.insert(c.begin(), std::move(v2)); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::insert(p, {key, value})"); + Container c; + cc->expect(); + It ret = c.insert(c.end(), {42, 1}); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + It ret2 = c.insert(c.begin(), {42, 1}); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::insert(p, const value_type&&)"); + Container c; + const ValueTp v(42, 1); + cc->expect(); + It ret = c.insert(c.end(), std::move(v)); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const ValueTp v2(42, 1); + It ret2 = c.insert(c.begin(), std::move(v2)); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::insert(p, pair const&)"); + Container c; + const NonConstKeyPair v(42, 1); + cc->expect(); + It ret = c.insert(c.end(), v); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const NonConstKeyPair v2(42, 1); + It ret2 = c.insert(c.begin(), v2); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::insert(p, pair&&)"); + Container c; + NonConstKeyPair v(42, 1); + cc->expect(); + It ret = c.insert(c.end(), std::move(v)); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + NonConstKeyPair v2(42, 1); + It ret2 = c.insert(c.begin(), std::move(v2)); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + + +} + + template void testMapEmplace() { @@ -509,6 +657,13 @@ void testMultimapInsert() c.insert(std::move(v)); assert(!cc->unchecked()); } + { + CHECKPOINT("Testing C::insert({key, value})"); + Container c; + cc->expect(); + c.insert({42, 1}); + assert(!cc->unchecked()); + } { CHECKPOINT("Testing C::insert(std::initializer_list)"); Container c; @@ -542,7 +697,47 @@ void testMultimapInsert() c.insert(std::begin(ValueList), std::end(ValueList)); assert(!cc->unchecked()); } +} + +template +void testMultimapInsertHint() +{ + typedef typename Container::value_type ValueTp; + typedef Container C; + ConstructController* cc = getConstructController(); + cc->reset(); + { + CHECKPOINT("Testing C::insert(p, const value_type&)"); + Container c; + const ValueTp v(42, 1); + cc->expect(); + c.insert(c.begin(), v); + assert(!cc->unchecked()); + } + { + CHECKPOINT("Testing C::insert(p, value_type&)"); + Container c; + ValueTp v(42, 1); + cc->expect(); + c.insert(c.begin(), v); + assert(!cc->unchecked()); + } + { + CHECKPOINT("Testing C::insert(p, value_type&&)"); + Container c; + ValueTp v(42, 1); + cc->expect(); + c.insert(c.begin(), std::move(v)); + assert(!cc->unchecked()); + } + { + CHECKPOINT("Testing C::insert(p, {key, value})"); + Container c; + cc->expect(); + c.insert(c.begin(), {42, 1}); + assert(!cc->unchecked()); + } } #endif diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp index 3b44e945816a..00c47182c925 100644 --- a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp @@ -25,6 +25,7 @@ int main() { testMapInsert >(); + testMapInsertHint >(); testMapEmplace >(); testMapEmplaceHint >(); } diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp index a16f097b4c01..fe2b24707fb3 100644 --- a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp @@ -18,69 +18,64 @@ #include #include +#include "test_macros.h" #include "min_allocator.h" + +template +void do_insert_cv_test() +{ + typedef Container M; + typedef std::pair R; + typedef typename M::value_type VT; + M m; + + const VT v1(2.5, 2); + R r = m.insert(v1); + assert(r.second); + assert(m.size() == 1); + assert(r.first->first == 2.5); + assert(r.first->second == 2); + + r = m.insert(VT(2.5, 3)); // test rvalue insertion works in C++03 + assert(!r.second); + assert(m.size() == 1); + assert(r.first->first == 2.5); + assert(r.first->second == 2); + + const VT v2(1.5, 1); + r = m.insert(v2); + assert(r.second); + assert(m.size() == 2); + assert(r.first->first == 1.5); + assert(r.first->second == 1); + + const VT v3(3.5, 3); + r = m.insert(v3); + assert(r.second); + assert(m.size() == 3); + assert(r.first->first == 3.5); + assert(r.first->second == 3); + + const VT v4(3.5, 4); + r = m.insert(v4); + assert(!r.second); + assert(m.size() == 3); + assert(r.first->first == 3.5); + assert(r.first->second == 3); +} + int main() { { - typedef std::unordered_map C; - typedef std::pair R; - typedef C::value_type P; - C c; - R r = c.insert(P(3.5, 3)); - assert(r.second); - assert(c.size() == 1); - assert(r.first->first == 3.5); - assert(r.first->second == 3); - - r = c.insert(P(3.5, 4)); - assert(!r.second); - assert(c.size() == 1); - assert(r.first->first == 3.5); - assert(r.first->second == 3); - - r = c.insert(P(4.5, 4)); - assert(r.second); - assert(c.size() == 2); - assert(r.first->first == 4.5); - assert(r.first->second == 4); - - r = c.insert(P(5.5, 4)); - assert(r.second); - assert(c.size() == 3); - assert(r.first->first == 5.5); - assert(r.first->second == 4); + typedef std::unordered_map M; + do_insert_cv_test(); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map, std::equal_to, - min_allocator>> C; - typedef std::pair R; - typedef C::value_type P; - C c; - R r = c.insert(P(3.5, 3)); - assert(r.second); - assert(c.size() == 1); - assert(r.first->first == 3.5); - assert(r.first->second == 3); - - r = c.insert(P(3.5, 4)); - assert(!r.second); - assert(c.size() == 1); - assert(r.first->first == 3.5); - assert(r.first->second == 3); - - r = c.insert(P(4.5, 4)); - assert(r.second); - assert(c.size() == 2); - assert(r.first->first == 4.5); - assert(r.first->second == 4); - - r = c.insert(P(5.5, 4)); - assert(r.second); - assert(c.size() == 3); - assert(r.first->first == 5.5); - assert(r.first->second == 4); + min_allocator>> M; + do_insert_cv_test(); } #endif } diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp index 1618c1019e1c..04d01eb466e7 100644 --- a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // template , class Pred = equal_to, @@ -55,7 +57,6 @@ int main() assert(r->first == 5.5); assert(r->second == 4); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unordered_map C; typedef C::iterator R; @@ -82,8 +83,6 @@ int main() assert(r->first == 5); assert(r->second == 4); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L { typedef std::unordered_map, std::equal_to, min_allocator>> C; @@ -111,7 +110,6 @@ int main() assert(r->first == 5.5); assert(r->second == 4); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unordered_map, std::equal_to, min_allocator>> C; @@ -139,7 +137,31 @@ int main() assert(r->first == 5); assert(r->second == 4); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_map C; + typedef C::iterator R; + C c; + C::const_iterator e = c.end(); + R r = c.insert(e, {3.5, 3}); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + r = c.insert(c.end(), {3.5, 4}); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + r = c.insert(c.end(), {4.5, 4}); + assert(c.size() == 2); + assert(r->first == 4.5); + assert(r->second == 4); + + r = c.insert(c.end(), {5.5, 4}); + assert(c.size() == 3); + assert(r->first == 5.5); + assert(r->second == 4); + } #if _LIBCPP_DEBUG >= 1 { typedef std::unordered_map C; @@ -152,5 +174,4 @@ int main() assert(false); } #endif -#endif } diff --git a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp index f53dc6c7e97a..faf5b046b5d8 100644 --- a/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // template , class Pred = equal_to, @@ -54,7 +56,6 @@ int main() assert(r.first->first == 5.5); assert(r.first->second == 4); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unordered_map C; typedef std::pair R; @@ -84,8 +85,6 @@ int main() assert(r.first->first == 5); assert(r.first->second == 4); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L { typedef std::unordered_map, std::equal_to, min_allocator>> C; @@ -116,7 +115,6 @@ int main() assert(r.first->first == 5.5); assert(r.first->second == 4); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unordered_map, std::equal_to, min_allocator>> C; @@ -147,6 +145,32 @@ int main() assert(r.first->first == 5); assert(r.first->second == 4); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#endif + { + typedef std::unordered_map C; + typedef std::pair R; + C c; + R r = c.insert({3.5, 3}); + assert(r.second); + assert(c.size() == 1); + assert(r.first->first == 3.5); + assert(r.first->second == 3); + + r = c.insert({3.5, 4}); + assert(!r.second); + assert(c.size() == 1); + assert(r.first->first == 3.5); + assert(r.first->second == 3); + + r = c.insert({4.5, 4}); + assert(r.second); + assert(c.size() == 2); + assert(r.first->first == 4.5); + assert(r.first->second == 4); + + r = c.insert({5.5, 4}); + assert(r.second); + assert(c.size() == 3); + assert(r.first->first == 5.5); + assert(r.first->second == 4); + } } diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_allocator_requirements.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_allocator_requirements.pass.cpp index 1145eb990912..30f78936ff92 100644 --- a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_allocator_requirements.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_allocator_requirements.pass.cpp @@ -23,4 +23,5 @@ int main() { testMultimapInsert >(); + testMultimapInsertHint >(); } diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp index 7116fa02b6f5..d6c0dbdbed07 100644 --- a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // template , class Pred = equal_to, @@ -55,7 +57,6 @@ int main() assert(r->first == 5.5); assert(r->second == 4); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unordered_multimap C; typedef C::iterator R; @@ -82,8 +83,6 @@ int main() assert(r->first == 5); assert(r->second == 4); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L { typedef std::unordered_multimap, std::equal_to, min_allocator>> C; @@ -111,7 +110,6 @@ int main() assert(r->first == 5.5); assert(r->second == 4); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unordered_multimap, std::equal_to, min_allocator>> C; @@ -139,7 +137,31 @@ int main() assert(r->first == 5); assert(r->second == 4); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_multimap C; + typedef C::iterator R; + C c; + C::const_iterator e = c.end(); + R r = c.insert(e, {3.5, 3}); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + r = c.insert(r, {3.5, 4}); + assert(c.size() == 2); + assert(r->first == 3.5); + assert(r->second == 4); + + r = c.insert(c.end(), {4.5, 4}); + assert(c.size() == 3); + assert(r->first == 4.5); + assert(r->second == 4); + + r = c.insert(c.end(), {5.5, 4}); + assert(c.size() == 4); + assert(r->first == 5.5); + assert(r->second == 4); + } #if _LIBCPP_DEBUG >= 1 { typedef std::unordered_multimap C; @@ -152,5 +174,4 @@ int main() assert(false); } #endif -#endif } diff --git a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp index 5a98467e9d0f..6735b8af5a0a 100644 --- a/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // // template , class Pred = equal_to, @@ -50,7 +52,6 @@ int main() assert(r->first == 5.5); assert(r->second == 4); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unordered_multimap C; typedef C::iterator R; @@ -76,8 +77,6 @@ int main() assert(r->first == 5); assert(r->second == 4); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L { typedef std::unordered_multimap, std::equal_to, min_allocator>> C; @@ -104,7 +103,6 @@ int main() assert(r->first == 5.5); assert(r->second == 4); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unordered_multimap, std::equal_to, min_allocator>> C; @@ -131,6 +129,28 @@ int main() assert(r->first == 5); assert(r->second == 4); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#endif + { + typedef std::unordered_multimap C; + typedef C::iterator R; + C c; + R r = c.insert({3.5, 3}); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + r = c.insert({3.5, 4}); + assert(c.size() == 2); + assert(r->first == 3.5); + assert(r->second == 4); + + r = c.insert({4.5, 4}); + assert(c.size() == 3); + assert(r->first == 4.5); + assert(r->second == 4); + + r = c.insert({5.5, 4}); + assert(c.size() == 4); + assert(r->first == 5.5); + assert(r->second == 4); + } } diff --git a/libcxx/www/cxx1z_status.html b/libcxx/www/cxx1z_status.html index 65c33c094817..7993607e781f 100644 --- a/libcxx/www/cxx1z_status.html +++ b/libcxx/www/cxx1z_status.html @@ -105,7 +105,7 @@ 2170Aggregates cannot be DefaultConstructibleUrbanaComplete 2308Clarify container destructor requirements w.r.t. std::arrayUrbanaComplete 2340Replacement allocation functions declared as inlineUrbanaComplete - 2354Unnecessary copying when inserting into maps with braced-init syntaxUrbana + 2354Unnecessary copying when inserting into maps with braced-init syntaxUrbanaComplete 2377std::align requirements overly strictUrbanaComplete 2396underlying_type doesn't say what to do for an incomplete enumeration typeUrbanaComplete 2399shared_ptr's constructor from unique_ptr should be constrainedUrbanaComplete