diff options
author | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:47:26 +0000 |
---|---|---|
committer | Dimitry Andric <dim@FreeBSD.org> | 2016-07-23 20:47:26 +0000 |
commit | 51072bd6bf79ef2bc6a922079bff57c31c1effbc (patch) | |
tree | 91a2effbc9e6f80bdbbf9eb70e06c51ad0867ea0 /test/std/containers/associative | |
parent | bb5e33f003797b67974a8893f7f2930fc51b8210 (diff) | |
download | src-51072bd6bf79ef2bc6a922079bff57c31c1effbc.tar.gz src-51072bd6bf79ef2bc6a922079bff57c31c1effbc.zip |
Vendor import of libc++ release_39 branch r276489:vendor/libc++/libc++-release_39-r276489
Notes
Notes:
svn path=/vendor/libc++/dist/; revision=303237
svn path=/vendor/libc++/libc++-release_39-r276489/; revision=303238; tag=vendor/libc++/libc++-release_39-r276489
Diffstat (limited to 'test/std/containers/associative')
230 files changed, 1261 insertions, 4342 deletions
diff --git a/test/std/containers/associative/iterator_types.pass.cpp b/test/std/containers/associative/iterator_types.pass.cpp new file mode 100644 index 000000000000..2026219d86cb --- /dev/null +++ b/test/std/containers/associative/iterator_types.pass.cpp @@ -0,0 +1,131 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +#include <map> +#include <set> +#include <type_traits> + +#include "test_macros.h" +#include "min_allocator.h" +#include "test_allocator.h" + + +template <class Map, class ValueTp, class PtrT, class CPtrT> +void testMap() { + typedef typename Map::difference_type Diff; + { + typedef typename Map::iterator It; + static_assert((std::is_same<typename It::value_type, ValueTp>::value), ""); + static_assert((std::is_same<typename It::reference, ValueTp&>::value), ""); + static_assert((std::is_same<typename It::pointer, PtrT>::value), ""); + static_assert((std::is_same<typename It::difference_type, Diff>::value), ""); + } + { + typedef typename Map::const_iterator It; + static_assert((std::is_same<typename It::value_type, ValueTp>::value), ""); + static_assert((std::is_same<typename It::reference, ValueTp const&>::value), ""); + static_assert((std::is_same<typename It::pointer, CPtrT>::value), ""); + static_assert((std::is_same<typename It::difference_type, Diff>::value), ""); + } +} + + +template <class Set, class ValueTp, class CPtrT> +void testSet() { + static_assert((std::is_same<typename Set::iterator, + typename Set::const_iterator>::value), ""); + typedef typename Set::difference_type Diff; + { + typedef typename Set::iterator It; + static_assert((std::is_same<typename It::value_type, ValueTp>::value), ""); + static_assert((std::is_same<typename It::reference, ValueTp const&>::value), ""); + static_assert((std::is_same<typename It::pointer, CPtrT>::value), ""); + static_assert((std::is_same<typename It::difference_type, Diff>::value), ""); + + } +} + +int main() { + { + typedef std::map<int, int> Map; + typedef std::pair<const int, int> ValueTp; + testMap<Map, ValueTp, ValueTp*, ValueTp const*>(); + } + { + typedef std::pair<const int, int> ValueTp; + typedef test_allocator<ValueTp> Alloc; + typedef std::map<int, int, std::less<int>, Alloc> Map; + testMap<Map, ValueTp, ValueTp*, ValueTp const*>(); + } +#if TEST_STD_VER >= 11 + { + typedef std::pair<const int, int> ValueTp; + typedef min_allocator<ValueTp> Alloc; + typedef std::map<int, int, std::less<int>, Alloc> Map; + testMap<Map, ValueTp, min_pointer<ValueTp>, min_pointer<const ValueTp>>(); + } +#endif + { + typedef std::multimap<int, int> Map; + typedef std::pair<const int, int> ValueTp; + testMap<Map, ValueTp, ValueTp*, ValueTp const*>(); + } + { + typedef std::pair<const int, int> ValueTp; + typedef test_allocator<ValueTp> Alloc; + typedef std::multimap<int, int, std::less<int>, Alloc> Map; + testMap<Map, ValueTp, ValueTp*, ValueTp const*>(); + } +#if TEST_STD_VER >= 11 + { + typedef std::pair<const int, int> ValueTp; + typedef min_allocator<ValueTp> Alloc; + typedef std::multimap<int, int, std::less<int>, Alloc> Map; + testMap<Map, ValueTp, min_pointer<ValueTp>, min_pointer<const ValueTp>>(); + } +#endif + { + typedef int ValueTp; + typedef std::set<ValueTp> Set; + testSet<Set, ValueTp, ValueTp const*>(); + } + { + typedef int ValueTp; + typedef test_allocator<ValueTp> Alloc; + typedef std::set<ValueTp, std::less<ValueTp>, Alloc> Set; + testSet<Set, ValueTp, ValueTp const*>(); + } +#if TEST_STD_VER >= 11 + { + typedef int ValueTp; + typedef min_allocator<ValueTp> Alloc; + typedef std::set<ValueTp, std::less<ValueTp>, Alloc> Set; + testSet<Set, ValueTp, min_pointer<const ValueTp>>(); + } +#endif + { + typedef int ValueTp; + typedef std::multiset<ValueTp> Set; + testSet<Set, ValueTp, ValueTp const*>(); + } + { + typedef int ValueTp; + typedef test_allocator<ValueTp> Alloc; + typedef std::multiset<ValueTp, std::less<ValueTp>, Alloc> Set; + testSet<Set, ValueTp, ValueTp const*>(); + } +#if TEST_STD_VER >= 11 + { + typedef int ValueTp; + typedef min_allocator<ValueTp> Alloc; + typedef std::multiset<ValueTp, std::less<ValueTp>, Alloc> Set; + testSet<Set, ValueTp, min_pointer<const ValueTp>>(); + } +#endif +} diff --git a/test/std/containers/associative/map/PR28469_undefined_behavior_segfault.sh.cpp b/test/std/containers/associative/map/PR28469_undefined_behavior_segfault.sh.cpp new file mode 100644 index 000000000000..32d34d90d7f8 --- /dev/null +++ b/test/std/containers/associative/map/PR28469_undefined_behavior_segfault.sh.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// RUN: %build -O2 +// RUN: %run + +// <map> + +// Previously this code caused a segfault when compiled at -O2 due to undefined +// behavior in __tree. See https://llvm.org/bugs/show_bug.cgi?id=28469 + +#include <functional> +#include <map> + +void dummy() {} + +struct F { + std::map<int, std::function<void()> > m; + F() { m[42] = &dummy; } +}; + +int main() { + F f; + f = F(); +} diff --git a/test/std/containers/associative/map/compare.pass.cpp b/test/std/containers/associative/map/compare.pass.cpp index 26ac7af7d908..9d1c13d7b8e6 100644 --- a/test/std/containers/associative/map/compare.pass.cpp +++ b/test/std/containers/associative/map/compare.pass.cpp @@ -44,7 +44,7 @@ int main() MapT map; IterBool result = map.insert(std::make_pair(Key(0), 42)); assert(result.second); - assert(result.first->second = 42); + assert(result.first->second == 42); IterBool result2 = map.insert(std::make_pair(Key(0), 43)); assert(!result2.second); assert(map[Key(0)] == 42); diff --git a/test/std/containers/associative/map/incomplete_type.pass.cpp b/test/std/containers/associative/map/incomplete_type.pass.cpp new file mode 100644 index 000000000000..84c2451ce087 --- /dev/null +++ b/test/std/containers/associative/map/incomplete_type.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <map> + +// Check that std::map and it's iterators can be instantiated with an incomplete +// type. + +#include <map> + +struct A { + typedef std::map<A, A> Map; + int data; + Map m; + Map::iterator it; + Map::const_iterator cit; +}; + +inline bool operator==(A const& L, A const& R) { return &L == &R; } +inline bool operator<(A const& L, A const& R) { return L.data < R.data; } +int main() { + A a; +} diff --git a/test/std/containers/associative/map/map.access/at.pass.cpp b/test/std/containers/associative/map/map.access/at.pass.cpp index 0da28507fce3..c5f77bf5f0fb 100644 --- a/test/std/containers/associative/map/map.access/at.pass.cpp +++ b/test/std/containers/associative/map/map.access/at.pass.cpp @@ -86,7 +86,7 @@ int main() assert(m.at(8) == 8.5); assert(m.size() == 7); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; V ar[] = diff --git a/test/std/containers/associative/map/map.access/empty.pass.cpp b/test/std/containers/associative/map/map.access/empty.pass.cpp index b11e94c8042c..17b9cfd4ec11 100644 --- a/test/std/containers/associative/map/map.access/empty.pass.cpp +++ b/test/std/containers/associative/map/map.access/empty.pass.cpp @@ -29,7 +29,7 @@ int main() m.clear(); assert(m.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; M m; diff --git a/test/std/containers/associative/map/map.access/index_key.pass.cpp b/test/std/containers/associative/map/map.access/index_key.pass.cpp index ab1144c60afd..3b1c21fd5da4 100644 --- a/test/std/containers/associative/map/map.access/index_key.pass.cpp +++ b/test/std/containers/associative/map/map.access/index_key.pass.cpp @@ -16,8 +16,13 @@ #include <map> #include <cassert> +#include "test_macros.h" +#include "count_new.hpp" #include "min_allocator.h" #include "private_constructor.hpp" +#if TEST_STD_VER >= 11 +#include "container_test_types.h" +#endif int main() { @@ -46,7 +51,7 @@ int main() assert(m[6] == 6.5); assert(m.size() == 8); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; V ar[] = @@ -73,8 +78,42 @@ int main() assert(m[6] == 6.5); assert(m.size() == 8); } + { + // Use "container_test_types.h" to check what arguments get passed + // to the allocator for operator[] + using Container = TCT::map<>; + using Key = Container::key_type; + using MappedType = Container::mapped_type; + using ValueTp = Container::value_type; + ConstructController* cc = getConstructController(); + cc->reset(); + { + Container c; + const Key k(1); + cc->expect<std::piecewise_construct_t const&, std::tuple<Key const&>&&, std::tuple<>&&>(); + MappedType& mref = c[k]; + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + MappedType& mref2 = c[k]; + assert(&mref == &mref2); + } + } + { + Container c; + Key k(1); + cc->expect<std::piecewise_construct_t const&, std::tuple<Key const&>&&, std::tuple<>&&>(); + MappedType& mref = c[k]; + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + MappedType& mref2 = c[k]; + assert(&mref == &mref2); + } + } + } #endif -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER > 11 { typedef std::pair<const int, double> V; V ar[] = diff --git a/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp b/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp index 6511dcc85f53..e5580bca3955 100644 --- a/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp +++ b/test/std/containers/associative/map/map.access/index_rv_key.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <map> // class map @@ -17,12 +19,13 @@ #include <cassert> #include "test_macros.h" +#include "count_new.hpp" #include "MoveOnly.h" #include "min_allocator.h" +#include "container_test_types.h" int main() { -#if TEST_STD_VER >= 11 { std::map<MoveOnly, double> m; assert(m.size() == 0); @@ -52,5 +55,27 @@ int main() assert(m[6] == 6.5); assert(m.size() == 2); } -#endif + { + // Use "container_test_types.h" to check what arguments get passed + // to the allocator for operator[] + using Container = TCT::map<>; + using Key = Container::key_type; + using MappedType = Container::mapped_type; + using ValueTp = Container::value_type; + ConstructController* cc = getConstructController(); + cc->reset(); + { + Container c; + Key k(1); + cc->expect<std::piecewise_construct_t const&, std::tuple<Key &&>&&, std::tuple<>&&>(); + MappedType& mref = c[std::move(k)]; + assert(!cc->unchecked()); + { + Key k2(1); + DisableAllocationGuard g; + MappedType& mref2 = c[std::move(k2)]; + assert(&mref == &mref2); + } + } + } } diff --git a/test/std/containers/associative/map/map.access/iterator.pass.cpp b/test/std/containers/associative/map/map.access/iterator.pass.cpp index 552e87d8fc8d..4f66eb6a8e31 100644 --- a/test/std/containers/associative/map/map.access/iterator.pass.cpp +++ b/test/std/containers/associative/map/map.access/iterator.pass.cpp @@ -119,7 +119,7 @@ int main() assert(i->second == 1); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; V ar[] = diff --git a/test/std/containers/associative/map/map.access/max_size.pass.cpp b/test/std/containers/associative/map/map.access/max_size.pass.cpp index 551120d331e1..c67d8b1f674d 100644 --- a/test/std/containers/associative/map/map.access/max_size.pass.cpp +++ b/test/std/containers/associative/map/map.access/max_size.pass.cpp @@ -25,7 +25,7 @@ int main() M m; assert(m.max_size() != 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; M m; diff --git a/test/std/containers/associative/map/map.access/size.pass.cpp b/test/std/containers/associative/map/map.access/size.pass.cpp index 07c12322a460..b9d56167a4b0 100644 --- a/test/std/containers/associative/map/map.access/size.pass.cpp +++ b/test/std/containers/associative/map/map.access/size.pass.cpp @@ -37,7 +37,7 @@ int main() m.erase(m.begin()); assert(m.size() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; M m; diff --git a/test/std/containers/associative/map/map.cons/alloc.pass.cpp b/test/std/containers/associative/map/map.cons/alloc.pass.cpp index 2292c47ef74b..6ff102e6873c 100644 --- a/test/std/containers/associative/map/map.cons/alloc.pass.cpp +++ b/test/std/containers/associative/map/map.cons/alloc.pass.cpp @@ -29,7 +29,7 @@ int main() assert(m.begin() == m.end()); assert(m.get_allocator() == A(5)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::less<int> C; typedef min_allocator<std::pair<const int, double> > A; diff --git a/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp b/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp index 482d1acff840..679600662fda 100644 --- a/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp +++ b/test/std/containers/associative/map/map.cons/assign_initializer_list.pass.cpp @@ -45,7 +45,7 @@ int main() assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; std::map<int, double, std::less<int>, min_allocator<V>> m = diff --git a/test/std/containers/associative/map/map.cons/compare.pass.cpp b/test/std/containers/associative/map/map.cons/compare.pass.cpp index 5a213c8e8b8f..5d8d5e252507 100644 --- a/test/std/containers/associative/map/map.cons/compare.pass.cpp +++ b/test/std/containers/associative/map/map.cons/compare.pass.cpp @@ -28,7 +28,7 @@ int main() assert(m.begin() == m.end()); assert(m.key_comp() == C(3)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef test_compare<std::less<int> > C; std::map<int, double, C, min_allocator<std::pair<const int, double>>> m(C(3)); diff --git a/test/std/containers/associative/map/map.cons/compare_alloc.pass.cpp b/test/std/containers/associative/map/map.cons/compare_alloc.pass.cpp index 56b3c3315e08..ea1374a53dac 100644 --- a/test/std/containers/associative/map/map.cons/compare_alloc.pass.cpp +++ b/test/std/containers/associative/map/map.cons/compare_alloc.pass.cpp @@ -31,7 +31,7 @@ int main() assert(m.key_comp() == C(4)); assert(m.get_allocator() == A(5)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef test_compare<std::less<int> > C; typedef min_allocator<std::pair<const int, double> > A; diff --git a/test/std/containers/associative/map/map.cons/compare_copy_constructible.fail.cpp b/test/std/containers/associative/map/map.cons/compare_copy_constructible.fail.cpp new file mode 100644 index 000000000000..81ccba3bbc96 --- /dev/null +++ b/test/std/containers/associative/map/map.cons/compare_copy_constructible.fail.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <map> + +// Check that std::map fails to instantiate if the comparison predicate is +// not copy-constructible. This is LWG issue 2436 + +#include <map> + +template <class T> +struct Comp { + bool operator () (const T& lhs, const T& rhs) const { return lhs < rhs; } + + Comp () {} +private: + Comp (const Comp &); // declared but not defined + }; + + +int main() { + std::map<int, int, Comp<int> > m; +} diff --git a/test/std/containers/associative/map/map.cons/copy.pass.cpp b/test/std/containers/associative/map/map.cons/copy.pass.cpp index be5274133082..a1de1b13aed2 100644 --- a/test/std/containers/associative/map/map.cons/copy.pass.cpp +++ b/test/std/containers/associative/map/map.cons/copy.pass.cpp @@ -92,7 +92,7 @@ int main() assert(*next(mo.begin(), 2) == V(3, 1)); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; V ar[] = diff --git a/test/std/containers/associative/map/map.cons/copy_alloc.pass.cpp b/test/std/containers/associative/map/map.cons/copy_alloc.pass.cpp index fcbe5976d6da..8a9f7c86a2c7 100644 --- a/test/std/containers/associative/map/map.cons/copy_alloc.pass.cpp +++ b/test/std/containers/associative/map/map.cons/copy_alloc.pass.cpp @@ -56,7 +56,7 @@ int main() assert(*next(mo.begin()) == V(2, 1)); assert(*next(mo.begin(), 2) == V(3, 1)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; V ar[] = diff --git a/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp b/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp index a1bcb30f4294..fc6641ae34b9 100644 --- a/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp +++ b/test/std/containers/associative/map/map.cons/copy_assign.pass.cpp @@ -107,7 +107,7 @@ int main() assert(*next(mo.begin()) == V(2, 1)); assert(*next(mo.begin(), 2) == V(3, 1)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; V ar[] = diff --git a/test/std/containers/associative/map/map.cons/default.pass.cpp b/test/std/containers/associative/map/map.cons/default.pass.cpp index 1832a32fffb3..265c59ef24cd 100644 --- a/test/std/containers/associative/map/map.cons/default.pass.cpp +++ b/test/std/containers/associative/map/map.cons/default.pass.cpp @@ -25,7 +25,7 @@ int main() assert(m.empty()); assert(m.begin() == m.end()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> m; assert(m.empty()); diff --git a/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp index dedc89bd435e..817f1207ac94 100644 --- a/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/default_noexcept.pass.cpp @@ -17,9 +17,12 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <map> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -28,19 +31,19 @@ struct some_comp { typedef T value_type; some_comp(); + bool operator()(const T&, const T&) const { return false; } }; int main() { -#if __has_feature(cxx_noexcept) typedef std::pair<const MoveOnly, MoveOnly> V; { typedef std::map<MoveOnly, MoveOnly> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::map<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; @@ -50,5 +53,4 @@ int main() typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp index 9baa19b53d05..efdf5a2ed184 100644 --- a/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/dtor_noexcept.pass.cpp @@ -11,26 +11,24 @@ // ~map() // implied noexcept; +// UNSUPPORTED: c++98, c++03 + #include <map> #include <cassert> #include "MoveOnly.h" #include "test_allocator.h" -#if __has_feature(cxx_noexcept) - template <class T> struct some_comp { typedef T value_type; ~some_comp() noexcept(false); + bool operator()(const T&, const T&) const noexcept { return false; } }; -#endif - int main() { -#if __has_feature(cxx_noexcept) typedef std::pair<const MoveOnly, MoveOnly> V; { typedef std::map<MoveOnly, MoveOnly> C; @@ -48,5 +46,4 @@ int main() typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_destructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/associative/map/map.cons/initializer_list.pass.cpp b/test/std/containers/associative/map/map.cons/initializer_list.pass.cpp index 196943653a14..c55d18f54094 100644 --- a/test/std/containers/associative/map/map.cons/initializer_list.pass.cpp +++ b/test/std/containers/associative/map/map.cons/initializer_list.pass.cpp @@ -41,7 +41,7 @@ int main() assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; std::map<int, double, std::less<int>, min_allocator<V>> m = diff --git a/test/std/containers/associative/map/map.cons/initializer_list_compare.pass.cpp b/test/std/containers/associative/map/map.cons/initializer_list_compare.pass.cpp index 08f8a529f030..3133eb2e0dd6 100644 --- a/test/std/containers/associative/map/map.cons/initializer_list_compare.pass.cpp +++ b/test/std/containers/associative/map/map.cons/initializer_list_compare.pass.cpp @@ -42,7 +42,7 @@ int main() assert(*next(m.begin(), 2) == V(3, 1)); assert(m.key_comp() == C(3)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; typedef test_compare<std::less<int> > C; diff --git a/test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp b/test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp index 765428a631e5..1210fe0e49e1 100644 --- a/test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp +++ b/test/std/containers/associative/map/map.cons/initializer_list_compare_alloc.pass.cpp @@ -45,7 +45,7 @@ int main() assert(m.key_comp() == C(3)); assert(m.get_allocator() == A(6)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; typedef test_compare<std::less<int> > C; diff --git a/test/std/containers/associative/map/map.cons/iter_iter.pass.cpp b/test/std/containers/associative/map/map.cons/iter_iter.pass.cpp index c1029af6889e..48610f3b3e58 100644 --- a/test/std/containers/associative/map/map.cons/iter_iter.pass.cpp +++ b/test/std/containers/associative/map/map.cons/iter_iter.pass.cpp @@ -42,7 +42,7 @@ int main() assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; V ar[] = diff --git a/test/std/containers/associative/map/map.cons/iter_iter_comp.pass.cpp b/test/std/containers/associative/map/map.cons/iter_iter_comp.pass.cpp index 837fa8c6cdea..1389f71449c8 100644 --- a/test/std/containers/associative/map/map.cons/iter_iter_comp.pass.cpp +++ b/test/std/containers/associative/map/map.cons/iter_iter_comp.pass.cpp @@ -45,7 +45,7 @@ int main() assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; V ar[] = diff --git a/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp b/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp index 67fb5d644762..42376e268332 100644 --- a/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp +++ b/test/std/containers/associative/map/map.cons/iter_iter_comp_alloc.pass.cpp @@ -49,7 +49,7 @@ int main() assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; V ar[] = diff --git a/test/std/containers/associative/map/map.cons/move.pass.cpp b/test/std/containers/associative/map/map.cons/move.pass.cpp index c06f2ee5021b..2d19b88bdda8 100644 --- a/test/std/containers/associative/map/map.cons/move.pass.cpp +++ b/test/std/containers/associative/map/map.cons/move.pass.cpp @@ -69,7 +69,7 @@ int main() assert(mo.size() == 0); assert(distance(mo.begin(), mo.end()) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef test_compare<std::less<int> > C; typedef min_allocator<V> A; diff --git a/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp b/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp index e5d43f266c08..4ccf56118aec 100644 --- a/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp +++ b/test/std/containers/associative/map/map.cons/move_alloc.pass.cpp @@ -169,7 +169,7 @@ int main() M m1(I(a1), I(a1+num), C(), A()); assert(Counter_base::gConstructed == num+3); - + M m2(m1); assert(m2 == m1); assert(Counter_base::gConstructed == num+6); @@ -187,9 +187,9 @@ int main() } assert(Counter_base::gConstructed == num+3); } - assert(Counter_base::gConstructed == 0); + assert(Counter_base::gConstructed == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<MoveOnly, MoveOnly> V; typedef std::pair<const MoveOnly, MoveOnly> VC; diff --git a/test/std/containers/associative/map/map.cons/move_assign.pass.cpp b/test/std/containers/associative/map/map.cons/move_assign.pass.cpp index 8ae8265cdc12..09b41d3b130b 100644 --- a/test/std/containers/associative/map/map.cons/move_assign.pass.cpp +++ b/test/std/containers/associative/map/map.cons/move_assign.pass.cpp @@ -144,7 +144,7 @@ int main() assert(m3.key_comp() == C(5)); assert(m1.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<MoveOnly, MoveOnly> V; typedef std::pair<const MoveOnly, MoveOnly> VC; diff --git a/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp index 3b28118b5b1e..95ddf6dcb82f 100644 --- a/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/move_assign_noexcept.pass.cpp @@ -17,6 +17,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <map> #include <cassert> @@ -28,11 +30,11 @@ struct some_comp { typedef T value_type; some_comp& operator=(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; int main() { -#if __has_feature(cxx_noexcept) typedef std::pair<const MoveOnly, MoveOnly> V; { typedef std::map<MoveOnly, MoveOnly> C; @@ -50,5 +52,4 @@ int main() typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } -#endif } diff --git a/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp b/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp index 0f1fd396639e..1c2a242edf43 100644 --- a/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.cons/move_noexcept.pass.cpp @@ -15,6 +15,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <map> #include <cassert> @@ -26,11 +28,11 @@ struct some_comp { typedef T value_type; some_comp(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; int main() { -#if __has_feature(cxx_noexcept) typedef std::pair<const MoveOnly, MoveOnly> V; { typedef std::map<MoveOnly, MoveOnly> C; @@ -48,5 +50,4 @@ int main() typedef std::map<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/associative/map/map.modifiers/clear.pass.cpp b/test/std/containers/associative/map/map.modifiers/clear.pass.cpp index c37499df307a..1f36a6f10cb0 100644 --- a/test/std/containers/associative/map/map.modifiers/clear.pass.cpp +++ b/test/std/containers/associative/map/map.modifiers/clear.pass.cpp @@ -39,7 +39,7 @@ int main() m.clear(); assert(m.size() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; typedef std::pair<int, double> P; diff --git a/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp b/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp index 81846c6647c6..63d014fe8cc5 100644 --- a/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp +++ b/test/std/containers/associative/map/map.modifiers/emplace.pass.cpp @@ -92,7 +92,7 @@ int main() assert(m.begin()->first == 2); assert(m.begin()->second == 3.5); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M; typedef std::pair<M::iterator, bool> R; diff --git a/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp b/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp index 15f74b17e786..319a239525ad 100644 --- a/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp +++ b/test/std/containers/associative/map/map.modifiers/emplace_hint.pass.cpp @@ -64,7 +64,7 @@ int main() assert(m.size() == 1); assert(m.begin()->first == 2); assert(m.begin()->second == Emplaceable()); - r = m.emplace_hint(m.end(), std::piecewise_construct, + r = m.emplace_hint(m.end(), std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(2, 3.5)); assert(r == m.begin()); @@ -89,7 +89,7 @@ int main() assert(m.begin()->first == 2); assert(m.begin()->second == 3.5); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M; typedef M::iterator R; @@ -130,7 +130,7 @@ int main() assert(m.size() == 1); assert(m.begin()->first == 2); assert(m.begin()->second == Emplaceable()); - r = m.emplace_hint(m.end(), std::piecewise_construct, + r = m.emplace_hint(m.end(), std::piecewise_construct, std::forward_as_tuple(1), std::forward_as_tuple(2, 3.5)); assert(r == m.begin()); diff --git a/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp b/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp index 15c5ce041b68..cd65c4302af7 100644 --- a/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp +++ b/test/std/containers/associative/map/map.modifiers/erase_iter.pass.cpp @@ -134,7 +134,7 @@ int main() assert(i == m.begin()); assert(i == m.end()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; typedef std::pair<int, double> P; @@ -242,7 +242,7 @@ int main() assert(i == m.end()); } #endif -#if __cplusplus >= 201402L +#if TEST_STD_VER >= 14 { // This is LWG #2059 typedef TemplateConstructor T; diff --git a/test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp b/test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp index 1b49956d8a5a..144cfac2ccb5 100644 --- a/test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp +++ b/test/std/containers/associative/map/map.modifiers/erase_iter_iter.pass.cpp @@ -86,7 +86,7 @@ int main() assert(i == m.begin()); assert(i == m.end()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; typedef std::pair<int, double> P; diff --git a/test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp b/test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp index e41f5129140e..c1b31e78d3ef 100644 --- a/test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp +++ b/test/std/containers/associative/map/map.modifiers/erase_key.pass.cpp @@ -145,7 +145,7 @@ int main() assert(m.size() == 0); assert(s == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; typedef std::pair<int, double> P; diff --git a/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp new file mode 100644 index 000000000000..d98047d02e7d --- /dev/null +++ b/test/std/containers/associative/map/map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp @@ -0,0 +1,31 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <map> + +// class map + +// insert(...); +// emplace(...); +// emplace_hint(...); + +// UNSUPPORTED: c++98, c++03 + +#include <map> + +#include "container_test_types.h" +#include "../../../map_allocator_requirement_test_templates.h" + +int main() +{ + testMapInsert<TCT::map<> >(); + testMapInsertHint<TCT::map<> >(); + testMapEmplace<TCT::map<> >(); + testMapEmplaceHint<TCT::map<> >(); +} diff --git a/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp index 3d28242fd322..e2ffcba375fa 100644 --- a/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp +++ b/test/std/containers/associative/map/map.modifiers/insert_cv.pass.cpp @@ -16,74 +16,57 @@ #include <map> #include <cassert> +#include "test_macros.h" #include "min_allocator.h" -int main() +template <class Container> +void do_insert_cv_test() { - { - typedef std::map<int, double> M; - typedef std::pair<M::iterator, bool> 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); + typedef Container M; + typedef std::pair<typename M::iterator, bool> R; + typedef typename M::value_type VT; + M m; - 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); + 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); - 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 - { - typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; - typedef std::pair<M::iterator, bool> 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); + 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); - 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); + 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); - 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); + 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); +} - 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); +int main() +{ + do_insert_cv_test<std::map<int, double> >(); +#if TEST_STD_VER >= 11 + { + typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; + do_insert_cv_test<M>(); } #endif } diff --git a/test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp index ab325ed45bfc..9cf3f3dcf74f 100644 --- a/test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp +++ b/test/std/containers/associative/map/map.modifiers/insert_initializer_list.pass.cpp @@ -43,7 +43,7 @@ int main() assert(*next(m.begin()) == V(2, 1)); assert(*next(m.begin(), 2) == V(3, 1)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; std::map<int, double, std::less<int>, min_allocator<V>> m = diff --git a/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp index 278db4631a8c..0c7e124e0d1c 100644 --- a/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp +++ b/test/std/containers/associative/map/map.modifiers/insert_iter_cv.pass.cpp @@ -16,66 +16,53 @@ #include <map> #include <cassert> +#include "test_macros.h" #include "min_allocator.h" -int main() +template <class Container> +void do_insert_iter_cv_test() { - { - typedef std::map<int, double> 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); + typedef Container M; + typedef typename M::iterator R; + typedef typename M::value_type VT; - 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); + 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); - 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 - { - typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> 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); + 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); - 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); + 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); - 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); + 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); +} - 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); +int main() +{ + do_insert_iter_cv_test<std::map<int, double> >(); +#if TEST_STD_VER >= 11 + { + typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; + do_insert_iter_cv_test<M>(); } #endif } diff --git a/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp index 964738b4a68a..edc1a1e2c62b 100644 --- a/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp +++ b/test/std/containers/associative/map/map.modifiers/insert_iter_iter.pass.cpp @@ -47,7 +47,7 @@ int main() assert(next(m.begin(), 2)->first == 3); assert(next(m.begin(), 2)->second == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; typedef std::pair<int, double> P; diff --git a/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp index 9db1e5c70732..3edb9c06e7c0 100644 --- a/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp +++ b/test/std/containers/associative/map/map.modifiers/insert_iter_rv.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <map> // class map @@ -21,70 +23,49 @@ #include "min_allocator.h" #include "test_macros.h" -int main() +template <class Container, class Pair> +void do_insert_iter_rv_test() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - { - typedef std::map<int, MoveOnly> M; - typedef std::pair<int, MoveOnly> 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); + 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(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); + + 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() +{ + do_insert_iter_rv_test<std::map<int, MoveOnly>, std::pair<int, MoveOnly>>(); + do_insert_iter_rv_test<std::map<int, MoveOnly>, std::pair<const int, MoveOnly>>(); - 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<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M; typedef std::pair<int, MoveOnly> 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<const int, MoveOnly> CP; + do_insert_iter_rv_test<M, P>(); + do_insert_iter_rv_test<M, CP>(); } -#endif -#if TEST_STD_VER > 14 { typedef std::map<int, MoveOnly> 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/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp index 484ed06247d1..8689dc7284d5 100644 --- a/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp +++ b/test/std/containers/associative/map/map.modifiers/insert_or_assign.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: c++03, c++11, c++14 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <map> @@ -22,7 +22,6 @@ // template <class M> // iterator insert_or_assign(const_iterator hint, key_type&& k, M&& obj); // C++17 -#include <__config> #include <map> #include <cassert> #include <tuple> @@ -60,9 +59,6 @@ public: int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -#ifndef _LIBCPP_HAS_NO_VARIADICS - { // pair<iterator, bool> insert_or_assign(const key_type& k, M&& obj); typedef std::map<int, Moveable> M; typedef std::pair<M::iterator, bool> R; @@ -186,7 +182,4 @@ int main() assert(r->first.get() == 3); // key assert(r->second.get() == 5); // value } - -#endif // _LIBCPP_HAS_NO_VARIADICS -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -}
\ No newline at end of file +} diff --git a/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp b/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp index 23eb84d687ff..503d9291076d 100644 --- a/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp +++ b/test/std/containers/associative/map/map.modifiers/insert_rv.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <map> // class map @@ -22,76 +24,54 @@ #include "min_allocator.h" #include "test_macros.h" -int main() +template <class Container, class Pair> +void do_insert_rv_test() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - { - typedef std::map<int, MoveOnly> M; - typedef std::pair<M::iterator, bool> 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); + typedef Container M; + typedef Pair P; + typedef std::pair<typename M::iterator, bool> 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(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(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(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(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(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<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M; - typedef std::pair<M::iterator, bool> 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(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(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); +int main() +{ + do_insert_rv_test<std::map<int, MoveOnly>, std::pair<int, MoveOnly>>(); + do_insert_rv_test<std::map<int, MoveOnly>, std::pair<const int, MoveOnly>>(); - 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::map<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M; + typedef std::pair<int, MoveOnly> P; + typedef std::pair<const int, MoveOnly> CP; + do_insert_rv_test<M, P>(); + do_insert_rv_test<M, CP>(); } -#endif -#if TEST_STD_VER > 14 { typedef std::map<int, MoveOnly> M; typedef std::pair<M::iterator, bool> 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/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp b/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp index 8e0dd7577bbd..63704c91440e 100644 --- a/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp +++ b/test/std/containers/associative/map/map.modifiers/try.emplace.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// UNSUPPORTED: c++03, c++11, c++14 +// UNSUPPORTED: c++98, c++03, c++11, c++14 // <map> @@ -22,7 +22,6 @@ // template <class... Args> // iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17 -#include <__config> #include <map> #include <cassert> #include <tuple> @@ -58,9 +57,6 @@ public: int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES -#ifndef _LIBCPP_HAS_NO_VARIADICS - { // pair<iterator, bool> try_emplace(const key_type& k, Args&&... args); typedef std::map<int, Moveable> M; typedef std::pair<M::iterator, bool> R; @@ -104,7 +100,7 @@ int main() assert(r.first->second.get() == -1); // value } - { // pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); + { // pair<iterator, bool> try_emplace(key_type&& k, Args&&... args); typedef std::map<Moveable, Moveable> M; typedef std::pair<M::iterator, bool> R; M m; @@ -140,7 +136,7 @@ int main() m.try_emplace ( i, Moveable(i, (double) i)); assert(m.size() == 10); M::const_iterator it = m.find(2); - + Moveable mv1(3, 3.0); for (int i=0; i < 20; i += 2) { @@ -183,7 +179,4 @@ int main() assert(r->first.get() == 3); // key assert(r->second.get() == 4); // value } - -#endif // _LIBCPP_HAS_NO_VARIADICS -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/associative/map/map.ops/count.pass.cpp b/test/std/containers/associative/map/map.ops/count.pass.cpp index ae87ae8345e9..f3df31951c79 100644 --- a/test/std/containers/associative/map/map.ops/count.pass.cpp +++ b/test/std/containers/associative/map/map.ops/count.pass.cpp @@ -59,7 +59,7 @@ int main() assert(r == 0); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; typedef std::map<int, double, std::less<int>, min_allocator<V>> M; diff --git a/test/std/containers/associative/map/map.ops/count0.pass.cpp b/test/std/containers/associative/map/map.ops/count0.pass.cpp index ce549366e7ab..0278343006a8 100644 --- a/test/std/containers/associative/map/map.ops/count0.pass.cpp +++ b/test/std/containers/associative/map/map.ops/count0.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: c++03, c++11 +// XFAIL: c++98, c++03, c++11 // <map> @@ -15,9 +15,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.ops/count1.fail.cpp b/test/std/containers/associative/map/map.ops/count1.fail.cpp index 9c15059d490e..075a5ba2e0ab 100644 --- a/test/std/containers/associative/map/map.ops/count1.fail.cpp +++ b/test/std/containers/associative/map/map.ops/count1.fail.cpp @@ -13,9 +13,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.ops/count2.fail.cpp b/test/std/containers/associative/map/map.ops/count2.fail.cpp index 7aa1553ef47a..de1899021805 100644 --- a/test/std/containers/associative/map/map.ops/count2.fail.cpp +++ b/test/std/containers/associative/map/map.ops/count2.fail.cpp @@ -13,9 +13,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.ops/count3.fail.cpp b/test/std/containers/associative/map/map.ops/count3.fail.cpp index 7e7bb8f6d370..b139689fec74 100644 --- a/test/std/containers/associative/map/map.ops/count3.fail.cpp +++ b/test/std/containers/associative/map/map.ops/count3.fail.cpp @@ -13,9 +13,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.ops/equal_range.pass.cpp b/test/std/containers/associative/map/map.ops/equal_range.pass.cpp index a71149a47212..8beeb8b30f58 100644 --- a/test/std/containers/associative/map/map.ops/equal_range.pass.cpp +++ b/test/std/containers/associative/map/map.ops/equal_range.pass.cpp @@ -159,7 +159,7 @@ int main() assert(r.second == next(m.begin(), 8)); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; typedef std::map<int, double, std::less<int>, min_allocator<V>> M; diff --git a/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp b/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp index c95c3dffa9a5..3b98426868e4 100644 --- a/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp +++ b/test/std/containers/associative/map/map.ops/equal_range0.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: c++03, c++11 +// XFAIL: c++98, c++03, c++11 // <map> @@ -15,9 +15,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.ops/equal_range1.fail.cpp b/test/std/containers/associative/map/map.ops/equal_range1.fail.cpp index 8f0da08eb322..c66c2c512142 100644 --- a/test/std/containers/associative/map/map.ops/equal_range1.fail.cpp +++ b/test/std/containers/associative/map/map.ops/equal_range1.fail.cpp @@ -13,9 +13,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.ops/equal_range2.fail.cpp b/test/std/containers/associative/map/map.ops/equal_range2.fail.cpp index e73122d6533b..85083d4f4796 100644 --- a/test/std/containers/associative/map/map.ops/equal_range2.fail.cpp +++ b/test/std/containers/associative/map/map.ops/equal_range2.fail.cpp @@ -13,9 +13,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.ops/equal_range3.fail.cpp b/test/std/containers/associative/map/map.ops/equal_range3.fail.cpp index bb72e9e7a6d4..c9f1126e5baf 100644 --- a/test/std/containers/associative/map/map.ops/equal_range3.fail.cpp +++ b/test/std/containers/associative/map/map.ops/equal_range3.fail.cpp @@ -13,9 +13,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.ops/find.pass.cpp b/test/std/containers/associative/map/map.ops/find.pass.cpp index 17463b65740f..225f0f406042 100644 --- a/test/std/containers/associative/map/map.ops/find.pass.cpp +++ b/test/std/containers/associative/map/map.ops/find.pass.cpp @@ -93,7 +93,7 @@ int main() assert(r == next(m.begin(), 8)); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; typedef std::map<int, double, std::less<int>, min_allocator<V>> M; diff --git a/test/std/containers/associative/map/map.ops/find0.pass.cpp b/test/std/containers/associative/map/map.ops/find0.pass.cpp index 5f310b07c599..d7de579d8b44 100644 --- a/test/std/containers/associative/map/map.ops/find0.pass.cpp +++ b/test/std/containers/associative/map/map.ops/find0.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: c++03, c++11 +// XFAIL: c++98, c++03, c++11 // <map> @@ -15,9 +15,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.ops/find1.fail.cpp b/test/std/containers/associative/map/map.ops/find1.fail.cpp index c33b5a9a34cf..4fe61117613c 100644 --- a/test/std/containers/associative/map/map.ops/find1.fail.cpp +++ b/test/std/containers/associative/map/map.ops/find1.fail.cpp @@ -13,9 +13,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.ops/find2.fail.cpp b/test/std/containers/associative/map/map.ops/find2.fail.cpp index 40bf323a4538..3532dc8765b3 100644 --- a/test/std/containers/associative/map/map.ops/find2.fail.cpp +++ b/test/std/containers/associative/map/map.ops/find2.fail.cpp @@ -13,9 +13,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.ops/find3.fail.cpp b/test/std/containers/associative/map/map.ops/find3.fail.cpp index 9526c0e24d9e..be77330a29c8 100644 --- a/test/std/containers/associative/map/map.ops/find3.fail.cpp +++ b/test/std/containers/associative/map/map.ops/find3.fail.cpp @@ -13,9 +13,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.ops/lower_bound.pass.cpp b/test/std/containers/associative/map/map.ops/lower_bound.pass.cpp index 3cbfbf7d869f..e4359fa548b9 100644 --- a/test/std/containers/associative/map/map.ops/lower_bound.pass.cpp +++ b/test/std/containers/associative/map/map.ops/lower_bound.pass.cpp @@ -125,7 +125,7 @@ int main() assert(r == next(m.begin(), 8)); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; typedef std::map<int, double, std::less<int>, min_allocator<V>> M; @@ -317,7 +317,7 @@ int main() r = m.lower_bound(C2Int(20)); assert(r == next(m.begin(), 8)); } - + { typedef PrivateConstructor PC; typedef std::map<PC, double, std::less<>> M; diff --git a/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp b/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp index 2fc095a8f2c1..ea121df73002 100644 --- a/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp +++ b/test/std/containers/associative/map/map.ops/lower_bound0.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: c++03, c++11 +// XFAIL: c++98, c++03, c++11 // <map> @@ -15,9 +15,9 @@ // iterator lower_bound(const key_type& k); // const_iterator lower_bound(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.ops/lower_bound1.fail.cpp b/test/std/containers/associative/map/map.ops/lower_bound1.fail.cpp index a4a986c1a7a4..97bbf553205f 100644 --- a/test/std/containers/associative/map/map.ops/lower_bound1.fail.cpp +++ b/test/std/containers/associative/map/map.ops/lower_bound1.fail.cpp @@ -13,9 +13,9 @@ // iterator lower_bound(const key_type& k); // const_iterator lower_bound(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.ops/lower_bound2.fail.cpp b/test/std/containers/associative/map/map.ops/lower_bound2.fail.cpp index 3f6380e5e25f..eeae8e657387 100644 --- a/test/std/containers/associative/map/map.ops/lower_bound2.fail.cpp +++ b/test/std/containers/associative/map/map.ops/lower_bound2.fail.cpp @@ -13,9 +13,9 @@ // iterator lower_bound(const key_type& k); // const_iterator lower_bound(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.ops/lower_bound3.fail.cpp b/test/std/containers/associative/map/map.ops/lower_bound3.fail.cpp index 18f2c7b71fde..ba27ae3c5172 100644 --- a/test/std/containers/associative/map/map.ops/lower_bound3.fail.cpp +++ b/test/std/containers/associative/map/map.ops/lower_bound3.fail.cpp @@ -13,9 +13,9 @@ // iterator lower_bound(const key_type& k); // const_iterator lower_bound(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.ops/upper_bound.pass.cpp b/test/std/containers/associative/map/map.ops/upper_bound.pass.cpp index 037ceb962cd8..8c721947a2c3 100644 --- a/test/std/containers/associative/map/map.ops/upper_bound.pass.cpp +++ b/test/std/containers/associative/map/map.ops/upper_bound.pass.cpp @@ -124,7 +124,7 @@ int main() assert(r == next(m.begin(), 8)); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; typedef std::map<int, double, std::less<int>, min_allocator<V>> M; @@ -280,7 +280,7 @@ int main() r = m.upper_bound(20); assert(r == next(m.begin(), 8)); } - + { typedef PrivateConstructor PC; typedef std::map<PC, double, std::less<>> M; diff --git a/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp b/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp index c58e55f29793..2e597b85cf0c 100644 --- a/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp +++ b/test/std/containers/associative/map/map.ops/upper_bound0.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: c++03, c++11 +// XFAIL: c++98, c++03, c++11 // <map> @@ -15,9 +15,9 @@ // iterator upper_bound(const key_type& k); // const_iterator upper_bound(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.ops/upper_bound1.fail.cpp b/test/std/containers/associative/map/map.ops/upper_bound1.fail.cpp index 4647681b5cd1..6568e04bfad4 100644 --- a/test/std/containers/associative/map/map.ops/upper_bound1.fail.cpp +++ b/test/std/containers/associative/map/map.ops/upper_bound1.fail.cpp @@ -13,9 +13,9 @@ // iterator upper_bound(const key_type& k); // const_iterator upper_bound(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.ops/upper_bound2.fail.cpp b/test/std/containers/associative/map/map.ops/upper_bound2.fail.cpp index 11852fe0cc9f..bbb857e6f25a 100644 --- a/test/std/containers/associative/map/map.ops/upper_bound2.fail.cpp +++ b/test/std/containers/associative/map/map.ops/upper_bound2.fail.cpp @@ -13,9 +13,9 @@ // iterator upper_bound(const key_type& k); // const_iterator upper_bound(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.ops/upper_bound3.fail.cpp b/test/std/containers/associative/map/map.ops/upper_bound3.fail.cpp index 9cddeb8acbdc..ed9a41e4f03f 100644 --- a/test/std/containers/associative/map/map.ops/upper_bound3.fail.cpp +++ b/test/std/containers/associative/map/map.ops/upper_bound3.fail.cpp @@ -13,9 +13,9 @@ // iterator upper_bound(const key_type& k); // const_iterator upper_bound(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/map/map.special/member_swap.pass.cpp b/test/std/containers/associative/map/map.special/member_swap.pass.cpp index 7c3ad9d50ae4..f0913a77c2eb 100644 --- a/test/std/containers/associative/map/map.special/member_swap.pass.cpp +++ b/test/std/containers/associative/map/map.special/member_swap.pass.cpp @@ -96,7 +96,7 @@ int main() assert(m2 == m1_save); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map<int, double, std::less<int>, min_allocator<V>> M; { diff --git a/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp b/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp index b042a4878f8a..103a57b17e07 100644 --- a/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp +++ b/test/std/containers/associative/map/map.special/non_member_swap.pass.cpp @@ -98,6 +98,7 @@ int main() assert(m1 == m2_save); assert(m2 == m1_save); } + } { typedef test_allocator<V> A; typedef test_compare<std::less<int> > C; @@ -166,8 +167,7 @@ int main() assert(m2.key_comp() == C(1)); assert(m2.get_allocator() == A(1)); } - } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map<int, double, std::less<int>, min_allocator<V>> M; { @@ -242,6 +242,7 @@ int main() assert(m1 == m2_save); assert(m2 == m1_save); } + } { typedef min_allocator<V> A; typedef test_compare<std::less<int> > C; @@ -276,6 +277,5 @@ int main() assert(m2.key_comp() == C(1)); assert(m2.get_allocator() == A()); } - } #endif } diff --git a/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp b/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp index f25dff2c86da..cbbf4577ce62 100644 --- a/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp +++ b/test/std/containers/associative/map/map.special/swap_noexcept.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <map> // void swap(map& c) @@ -15,13 +17,14 @@ // // In C++17, the standard says that swap shall have: // noexcept(allocator_traits<Allocator>::is_always_equal::value && -// noexcept(swap(declval<Compare&>(), declval<Compare&>()))); +// noexcept(swap(declval<Compare&>(), declval<Compare&>()))); // This tests a conforming extension #include <map> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -29,23 +32,20 @@ template <class T> struct some_comp { typedef T value_type; - + some_comp() {} some_comp(const some_comp&) {} - void deallocate(void*, unsigned) {} - - typedef std::true_type propagate_on_container_swap; + bool operator()(const T&, const T&) const { return false; } }; template <class T> struct some_comp2 { typedef T value_type; - + some_comp2() {} some_comp2(const some_comp2&) {} - void deallocate(void*, unsigned) {} - typedef std::true_type propagate_on_container_swap; + bool operator()(const T&, const T&) const { return false; } }; #if TEST_STD_VER >= 14 @@ -57,7 +57,7 @@ template <class T> struct some_alloc { typedef T value_type; - + some_alloc() {} some_alloc(const some_alloc&); void deallocate(void*, unsigned) {} @@ -69,7 +69,7 @@ template <class T> struct some_alloc2 { typedef T value_type; - + some_alloc2() {} some_alloc2(const some_alloc2&); void deallocate(void*, unsigned) {} @@ -82,7 +82,7 @@ template <class T> struct some_alloc3 { typedef T value_type; - + some_alloc3() {} some_alloc3(const some_alloc3&); void deallocate(void*, unsigned) {} @@ -93,7 +93,6 @@ struct some_alloc3 int main() { -#if __has_feature(cxx_noexcept) typedef std::pair<const MoveOnly, MoveOnly> V; { typedef std::map<MoveOnly, MoveOnly> C; @@ -145,5 +144,4 @@ int main() } #endif -#endif } diff --git a/test/std/containers/associative/map/types.pass.cpp b/test/std/containers/associative/map/types.pass.cpp index d117deff693d..67cd5acaae89 100644 --- a/test/std/containers/associative/map/types.pass.cpp +++ b/test/std/containers/associative/map/types.pass.cpp @@ -50,7 +50,7 @@ int main() static_assert((std::is_same<C::size_type, std::size_t>::value), ""); static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), ""); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::map<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C; static_assert((std::is_same<C::key_type, int>::value), ""); diff --git a/test/std/containers/associative/multimap/empty.pass.cpp b/test/std/containers/associative/multimap/empty.pass.cpp index 2384960d10db..f1388d8bfa5a 100644 --- a/test/std/containers/associative/multimap/empty.pass.cpp +++ b/test/std/containers/associative/multimap/empty.pass.cpp @@ -29,7 +29,7 @@ int main() m.clear(); assert(m.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; M m; diff --git a/test/std/containers/associative/multimap/incomplete_type.pass.cpp b/test/std/containers/associative/multimap/incomplete_type.pass.cpp new file mode 100644 index 000000000000..c461eb38139d --- /dev/null +++ b/test/std/containers/associative/multimap/incomplete_type.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <map> + +// Check that std::multimap and it's iterators can be instantiated with an incomplete +// type. + +#include <map> + +struct A { + typedef std::multimap<A, A> Map; + int data; + Map m; + Map::iterator it; + Map::const_iterator cit; +}; + +inline bool operator==(A const& L, A const& R) { return &L == &R; } +inline bool operator<(A const& L, A const& R) { return L.data < R.data; } +int main() { + A a; +} diff --git a/test/std/containers/associative/multimap/iterator.pass.cpp b/test/std/containers/associative/multimap/iterator.pass.cpp index 2763129acc2a..ef7c5ef18af1 100644 --- a/test/std/containers/associative/multimap/iterator.pass.cpp +++ b/test/std/containers/associative/multimap/iterator.pass.cpp @@ -121,7 +121,7 @@ int main() assert(i->second == d); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; V ar[] = diff --git a/test/std/containers/associative/multimap/max_size.pass.cpp b/test/std/containers/associative/multimap/max_size.pass.cpp index ccd8b10638c1..b7cf226d8f13 100644 --- a/test/std/containers/associative/multimap/max_size.pass.cpp +++ b/test/std/containers/associative/multimap/max_size.pass.cpp @@ -25,7 +25,7 @@ int main() M m; assert(m.max_size() != 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; M m; diff --git a/test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp index 87bf0447e5be..69660fcd2772 100644 --- a/test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/alloc.pass.cpp @@ -29,7 +29,7 @@ int main() assert(m.begin() == m.end()); assert(m.get_allocator() == A(5)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::less<int> C; typedef min_allocator<std::pair<const int, double> > A; diff --git a/test/std/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp index 0c8991832529..4c0326d90fe6 100644 --- a/test/std/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/assign_initializer_list.pass.cpp @@ -50,7 +50,7 @@ int main() assert(*++i == V(3, 1.5)); assert(*++i == V(3, 2)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C; typedef C::value_type V; diff --git a/test/std/containers/associative/multimap/multimap.cons/compare.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/compare.pass.cpp index 9a4e0f987fd0..59a972f45687 100644 --- a/test/std/containers/associative/multimap/multimap.cons/compare.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/compare.pass.cpp @@ -28,7 +28,7 @@ int main() assert(m.begin() == m.end()); assert(m.key_comp() == C(3)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef test_compare<std::less<int> > C; std::multimap<int, double, C, min_allocator<std::pair<const int, double>>> m(C(3)); diff --git a/test/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp index 1224884939cf..836532892499 100644 --- a/test/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/compare_alloc.pass.cpp @@ -31,7 +31,7 @@ int main() assert(m.key_comp() == C(4)); assert(m.get_allocator() == A(5)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef test_compare<std::less<int> > C; typedef min_allocator<std::pair<const int, double> > A; diff --git a/test/std/containers/associative/multimap/multimap.cons/compare_copy_constructible.fail.cpp b/test/std/containers/associative/multimap/multimap.cons/compare_copy_constructible.fail.cpp new file mode 100644 index 000000000000..e6f6c3efee5b --- /dev/null +++ b/test/std/containers/associative/multimap/multimap.cons/compare_copy_constructible.fail.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <map> + +// Check that std::multimap fails to instantiate if the comparison predicate is +// not copy-constructible. This is LWG issue 2436 + +#include <map> + +template <class T> +struct Comp { + bool operator () (const T& lhs, const T& rhs) const { return lhs < rhs; } + + Comp () {} +private: + Comp (const Comp &); // declared but not defined + }; + + +int main() { + std::multimap<int, int, Comp<int> > m; +} diff --git a/test/std/containers/associative/multimap/multimap.cons/copy.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/copy.pass.cpp index 3d6626eaadbb..97dcf39e10c9 100644 --- a/test/std/containers/associative/multimap/multimap.cons/copy.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/copy.pass.cpp @@ -74,7 +74,7 @@ int main() assert(mo.key_comp() == C(5)); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; V ar[] = diff --git a/test/std/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp index 22594e32d718..46b9459cad28 100644 --- a/test/std/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/copy_alloc.pass.cpp @@ -47,7 +47,7 @@ int main() assert(mo.get_allocator() == A(7)); assert(mo.key_comp() == C(5)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; V ar[] = diff --git a/test/std/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp index 2bdc4d6a70ab..b0bf8cc135f2 100644 --- a/test/std/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/copy_assign.pass.cpp @@ -94,7 +94,7 @@ int main() assert(mo.get_allocator() == A(2)); assert(mo.key_comp() == C(5)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; V ar[] = diff --git a/test/std/containers/associative/multimap/multimap.cons/default.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/default.pass.cpp index 1c3ab8ce6c4b..d39cc1d0ee8a 100644 --- a/test/std/containers/associative/multimap/multimap.cons/default.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/default.pass.cpp @@ -25,7 +25,7 @@ int main() assert(m.empty()); assert(m.begin() == m.end()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> m; assert(m.empty()); diff --git a/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp index 5f05a0dca28e..6f97a5f3e756 100644 --- a/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/default_noexcept.pass.cpp @@ -17,9 +17,12 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <map> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -28,19 +31,19 @@ struct some_comp { typedef T value_type; some_comp(); + bool operator()(const T&, const T&) const { return false; } }; int main() { -#if __has_feature(cxx_noexcept) typedef std::pair<const MoveOnly, MoveOnly> V; { typedef std::multimap<MoveOnly, MoveOnly> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, test_allocator<V>> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::multimap<MoveOnly, MoveOnly, std::less<MoveOnly>, other_allocator<V>> C; @@ -50,5 +53,4 @@ int main() typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp index dd1701240c63..3a240cd48af3 100644 --- a/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/dtor_noexcept.pass.cpp @@ -11,26 +11,24 @@ // ~multimap() // implied noexcept; +// UNSUPPORTED: c++98, c++03 + #include <map> #include <cassert> #include "MoveOnly.h" #include "test_allocator.h" -#if __has_feature(cxx_noexcept) - template <class T> struct some_comp { typedef T value_type; ~some_comp() noexcept(false); + bool operator()(const T&, const T&) const { return false; } }; -#endif - int main() { -#if __has_feature(cxx_noexcept) typedef std::pair<const MoveOnly, MoveOnly> V; { typedef std::multimap<MoveOnly, MoveOnly> C; @@ -48,5 +46,4 @@ int main() typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_destructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp index 937a202a55ea..6f645b63b44c 100644 --- a/test/std/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/initializer_list.pass.cpp @@ -49,7 +49,7 @@ int main() assert(*++i == V(3, 1.5)); assert(*++i == V(3, 2)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C; typedef C::value_type V; diff --git a/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp index e6677039c90c..6d20d14f4200 100644 --- a/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare.pass.cpp @@ -53,7 +53,7 @@ int main() assert(*++i == V(3, 2)); assert(m.key_comp() == Cmp(4)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef test_compare<std::less<int> > Cmp; typedef std::multimap<int, double, Cmp, min_allocator<std::pair<const int, double>>> C; diff --git a/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp index 0e73f72793e5..f5d3463aec42 100644 --- a/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/initializer_list_compare_alloc.pass.cpp @@ -57,7 +57,7 @@ int main() assert(m.get_allocator() == A(5)); } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef test_compare<std::less<int> > Cmp; typedef min_allocator<std::pair<const int, double> > A; diff --git a/test/std/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp index fa062e2be0b8..46c56aa0b3ff 100644 --- a/test/std/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/iter_iter.pass.cpp @@ -48,7 +48,7 @@ int main() assert(*next(m.begin(), 7) == V(3, 1.5)); assert(*next(m.begin(), 8) == V(3, 2)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; V ar[] = diff --git a/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp index d6de59428dd6..614b3ed8a754 100644 --- a/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp.pass.cpp @@ -52,7 +52,7 @@ int main() assert(*next(m.begin(), 7) == V(3, 1.5)); assert(*next(m.begin(), 8) == V(3, 2)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; V ar[] = diff --git a/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp index 259fbd145ff6..31bf72dac96f 100644 --- a/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/iter_iter_comp_alloc.pass.cpp @@ -55,7 +55,7 @@ int main() assert(*next(m.begin(), 7) == V(3, 1.5)); assert(*next(m.begin(), 8) == V(3, 2)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<const int, double> V; V ar[] = diff --git a/test/std/containers/associative/multimap/multimap.cons/move.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/move.pass.cpp index aed08867c3cc..7edec77365d8 100644 --- a/test/std/containers/associative/multimap/multimap.cons/move.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/move.pass.cpp @@ -75,7 +75,7 @@ int main() assert(mo.size() == 0); assert(distance(mo.begin(), mo.end()) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef test_compare<std::less<int> > C; typedef min_allocator<V> A; diff --git a/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp index 3ec79eea3554..41771f62aaea 100644 --- a/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/move_alloc.pass.cpp @@ -169,7 +169,7 @@ int main() M m1(I(a1), I(a1+num), C(), A()); assert(Counter_base::gConstructed == 2*num); - + M m2(m1); assert(m2 == m1); assert(Counter_base::gConstructed == 3*num); @@ -187,9 +187,9 @@ int main() } assert(Counter_base::gConstructed == 2*num); } - assert(Counter_base::gConstructed == 0); + assert(Counter_base::gConstructed == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<MoveOnly, MoveOnly> V; typedef std::pair<const MoveOnly, MoveOnly> VC; diff --git a/test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp index 48854e388e10..924e9ddf1936 100644 --- a/test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/move_assign.pass.cpp @@ -144,7 +144,7 @@ int main() assert(m3.key_comp() == C(5)); assert(m1.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<MoveOnly, MoveOnly> V; typedef std::pair<const MoveOnly, MoveOnly> VC; diff --git a/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp index 635a8dca0357..890cac867f9e 100644 --- a/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/move_assign_noexcept.pass.cpp @@ -17,6 +17,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <map> #include <cassert> @@ -28,11 +30,11 @@ struct some_comp { typedef T value_type; some_comp& operator=(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; int main() { -#if __has_feature(cxx_noexcept) typedef std::pair<const MoveOnly, MoveOnly> V; { typedef std::multimap<MoveOnly, MoveOnly> C; @@ -50,5 +52,4 @@ int main() typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } -#endif } diff --git a/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp index 0f31f04ff829..8932b4f83d48 100644 --- a/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.cons/move_noexcept.pass.cpp @@ -15,6 +15,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <map> #include <cassert> @@ -26,11 +28,11 @@ struct some_comp { typedef T value_type; some_comp(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; int main() { -#if __has_feature(cxx_noexcept) typedef std::pair<const MoveOnly, MoveOnly> V; { typedef std::multimap<MoveOnly, MoveOnly> C; @@ -48,5 +50,4 @@ int main() typedef std::multimap<MoveOnly, MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/associative/multimap/multimap.modifiers/clear.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/clear.pass.cpp index fe9b8c8ba128..321f4d0bd000 100644 --- a/test/std/containers/associative/multimap/multimap.modifiers/clear.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.modifiers/clear.pass.cpp @@ -39,7 +39,7 @@ int main() m.clear(); assert(m.size() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; typedef std::pair<int, double> P; diff --git a/test/std/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp index 03da4af59372..7f5b698fa068 100644 --- a/test/std/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.modifiers/emplace.pass.cpp @@ -84,7 +84,7 @@ int main() assert(m.begin()->first == 2); assert(m.begin()->second == 3.5); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M; typedef M::iterator R; diff --git a/test/std/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp index 846d5999a17e..a6ed318c7598 100644 --- a/test/std/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.modifiers/emplace_hint.pass.cpp @@ -89,7 +89,7 @@ int main() assert(m.begin()->first == 2); assert(m.begin()->second == 3.5); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, DefaultOnly, std::less<int>, min_allocator<std::pair<const int, DefaultOnly>>> M; typedef M::iterator R; diff --git a/test/std/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp index ba55351c0bde..6729da41378b 100644 --- a/test/std/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.modifiers/erase_iter.pass.cpp @@ -155,7 +155,7 @@ int main() assert(i == m.begin()); assert(i == m.end()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; typedef std::pair<int, double> P; @@ -284,7 +284,7 @@ int main() assert(i == m.end()); } #endif -#if __cplusplus >= 201402L +#if TEST_STD_VER >= 14 { // This is LWG #2059 typedef TemplateConstructor T; diff --git a/test/std/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp index 4d3789493110..1069542c5430 100644 --- a/test/std/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.modifiers/erase_iter_iter.pass.cpp @@ -86,7 +86,7 @@ int main() assert(i == m.begin()); assert(i == m.end()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; typedef std::pair<int, double> P; diff --git a/test/std/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp index 33821d3e3596..44a6abef6ed0 100644 --- a/test/std/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.modifiers/erase_key.pass.cpp @@ -84,7 +84,7 @@ int main() assert(m.size() == 0); assert(i == 3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; typedef std::pair<int, double> P; diff --git a/test/std/containers/associative/map/version.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/insert_allocator_requirements.pass.cpp index b2e3fa43e787..225bf67bb1f6 100644 --- a/test/std/containers/associative/map/version.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.modifiers/insert_allocator_requirements.pass.cpp @@ -9,12 +9,20 @@ // <map> +// class multimap + +// insert(...) + +// UNSUPPORTED: c++98, c++03 + #include <map> -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif +#include "container_test_types.h" +#include "../../../map_allocator_requirement_test_templates.h" + int main() { + testMultimapInsert<TCT::multimap<> >(); + testMultimapInsertHint<TCT::multimap<> >(); } diff --git a/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp index d9afc9d0fdf0..53874311c782 100644 --- a/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.modifiers/insert_cv.pass.cpp @@ -16,66 +16,54 @@ #include <map> #include <cassert> +#include "test_macros.h" #include "min_allocator.h" -int main() -{ - { - typedef std::multimap<int, double> 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); +template <class Container> +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); - 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); + 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); - 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); + 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); - 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); + 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<int, double> Container; + do_insert_test<Container>(); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { - typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> 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<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> Container; + do_insert_test<Container>(); } #endif } diff --git a/test/std/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp index 5e1a1d4125ef..89befb3e9971 100644 --- a/test/std/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.modifiers/insert_initializer_list.pass.cpp @@ -53,7 +53,7 @@ int main() assert(*++i == V(3, 2)); assert(*++i == V(3, 1.5)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C; typedef C::value_type V; diff --git a/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp index b83c802c04cf..05e1096cb547 100644 --- a/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_cv.pass.cpp @@ -16,66 +16,52 @@ #include <map> #include <cassert> +#include "test_macros.h" #include "min_allocator.h" -int main() +template <class Container> +void do_insert_hint_test() { - { - typedef std::multimap<int, double> 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); + 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); - 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); + 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); - 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); + 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); - 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 + 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() +{ + do_insert_hint_test<std::multimap<int, double> >(); +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> 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<M>(); } #endif } diff --git a/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp index 70ff7ef6d6b8..1bf437a93443 100644 --- a/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_iter.pass.cpp @@ -59,7 +59,7 @@ int main() assert(next(m.begin(), 8)->first == 3); assert(next(m.begin(), 8)->second == 2); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; typedef std::pair<int, double> P; diff --git a/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp index 7035de83f990..47e0d371bb48 100644 --- a/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.modifiers/insert_iter_rv.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <map> // class multimap @@ -21,73 +23,53 @@ #include "min_allocator.h" #include "test_macros.h" -int main() +template <class Container, class Pair> +void do_insert_rv_test() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - { - typedef std::multimap<int, MoveOnly> M; - typedef std::pair<int, MoveOnly> 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 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(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, 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() +{ + do_insert_rv_test<std::multimap<int, MoveOnly>, std::pair<int, MoveOnly> >(); + do_insert_rv_test<std::multimap<int, MoveOnly>, std::pair<const int, MoveOnly> >(); - 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<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> M; typedef std::pair<int, MoveOnly> 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<const int, MoveOnly> CP; + do_insert_rv_test<M, P>(); + do_insert_rv_test<M, CP>(); - 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<int, MoveOnly> M; - typedef std::pair<int, MoveOnly> 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/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp b/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp index 825e304f65a8..022de873f7f1 100644 --- a/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.modifiers/insert_rv.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <map> // class multimap @@ -21,68 +23,45 @@ #include "min_allocator.h" #include "test_macros.h" -int main() +template <class Container> +void do_insert_rv_test() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - { - typedef std::multimap<int, MoveOnly> 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); + typedef std::multimap<int, MoveOnly> 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(M::value_type(1, 1)); - assert(r == m.begin()); - assert(m.size() == 2); - assert(r->first == 1); - assert(r->second == 1); + 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(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(VT(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 + 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() +{ + do_insert_rv_test<std::multimap<int, MoveOnly>>(); { typedef std::multimap<int, MoveOnly, std::less<int>, min_allocator<std::pair<const int, MoveOnly>>> 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<M>(); } -#endif -#if TEST_STD_VER > 14 { typedef std::multimap<int, MoveOnly> 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/test/std/containers/associative/multimap/multimap.ops/count.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/count.pass.cpp index c666c295f3a0..92f90f551d44 100644 --- a/test/std/containers/associative/multimap/multimap.ops/count.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/count.pass.cpp @@ -56,7 +56,7 @@ int main() assert(r == 0); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; { diff --git a/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp index 7da13bb0d66d..b993f4f89087 100644 --- a/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/count0.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: c++03, c++11 +// XFAIL: c++98, c++03, c++11 // <map> @@ -15,9 +15,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.ops/count1.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/count1.fail.cpp index f30d1bfd88d6..d0f3f1c0fdb7 100644 --- a/test/std/containers/associative/multimap/multimap.ops/count1.fail.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/count1.fail.cpp @@ -13,9 +13,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.ops/count2.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/count2.fail.cpp index ffb7eb6a559a..86d492f7f5e0 100644 --- a/test/std/containers/associative/multimap/multimap.ops/count2.fail.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/count2.fail.cpp @@ -13,9 +13,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.ops/count3.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/count3.fail.cpp index 4bb9d14634f3..55095efb3d6a 100644 --- a/test/std/containers/associative/multimap/multimap.ops/count3.fail.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/count3.fail.cpp @@ -13,9 +13,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp index 5a071042461a..31eac26816ac 100644 --- a/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/equal_range.pass.cpp @@ -101,7 +101,7 @@ int main() assert(r.second == m.end()); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; { diff --git a/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp index c0f07468ec5e..a3a51e6ccbf9 100644 --- a/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/equal_range0.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: c++03, c++11 +// XFAIL: c++98, c++03, c++11 // <map> @@ -15,9 +15,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.ops/equal_range1.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/equal_range1.fail.cpp index f022e94324fd..f793bf8859ba 100644 --- a/test/std/containers/associative/multimap/multimap.ops/equal_range1.fail.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/equal_range1.fail.cpp @@ -13,9 +13,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.ops/equal_range2.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/equal_range2.fail.cpp index 695e71703e3b..d099a8c81a1b 100644 --- a/test/std/containers/associative/multimap/multimap.ops/equal_range2.fail.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/equal_range2.fail.cpp @@ -13,9 +13,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.ops/equal_range3.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/equal_range3.fail.cpp index 59c2855e8f69..e53fff942793 100644 --- a/test/std/containers/associative/multimap/multimap.ops/equal_range3.fail.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/equal_range3.fail.cpp @@ -13,9 +13,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp index a60e42cf8592..2fd8c05b5f5e 100644 --- a/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/find.pass.cpp @@ -83,7 +83,7 @@ int main() assert(r == m.end()); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; { diff --git a/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp index 4f3369870c8f..03a6e1883051 100644 --- a/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/find0.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: c++03, c++11 +// XFAIL: c++98, c++03, c++11 // <map> @@ -15,9 +15,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.ops/find1.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/find1.fail.cpp index e1eef034064d..2759af46be14 100644 --- a/test/std/containers/associative/multimap/multimap.ops/find1.fail.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/find1.fail.cpp @@ -13,9 +13,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.ops/find2.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/find2.fail.cpp index 4c03f583fa1c..c67f3b39dabd 100644 --- a/test/std/containers/associative/multimap/multimap.ops/find2.fail.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/find2.fail.cpp @@ -13,9 +13,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.ops/find3.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/find3.fail.cpp index f10bc60aa864..e53fc4d55887 100644 --- a/test/std/containers/associative/multimap/multimap.ops/find3.fail.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/find3.fail.cpp @@ -13,9 +13,9 @@ // iterator find(const key_type& k); // const_iterator find(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp index 38b931802f8e..5c0315f956a8 100644 --- a/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/lower_bound.pass.cpp @@ -87,7 +87,7 @@ int main() assert(r == m.end()); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; { diff --git a/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp index c5271f65d7e5..77927bb5abed 100644 --- a/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/lower_bound0.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: c++03, c++11 +// XFAIL: c++98, c++03, c++11 // <map> @@ -15,9 +15,9 @@ // iterator lower_bound(const key_type& k); // const_iterator lower_bound(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.ops/lower_bound1.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/lower_bound1.fail.cpp index b452be864e2b..9b39573a5f42 100644 --- a/test/std/containers/associative/multimap/multimap.ops/lower_bound1.fail.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/lower_bound1.fail.cpp @@ -13,9 +13,9 @@ // iterator lower_bound(const key_type& k); // const_iterator lower_bound(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.ops/lower_bound2.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/lower_bound2.fail.cpp index a2ba30236a40..68710bd1bc38 100644 --- a/test/std/containers/associative/multimap/multimap.ops/lower_bound2.fail.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/lower_bound2.fail.cpp @@ -13,9 +13,9 @@ // iterator lower_bound(const key_type& k); // const_iterator lower_bound(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.ops/lower_bound3.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/lower_bound3.fail.cpp index 50d9fca91ad9..f254ef4785a1 100644 --- a/test/std/containers/associative/multimap/multimap.ops/lower_bound3.fail.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/lower_bound3.fail.cpp @@ -13,9 +13,9 @@ // iterator lower_bound(const key_type& k); // const_iterator lower_bound(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp index 7c647a9426cb..012354cef7bb 100644 --- a/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/upper_bound.pass.cpp @@ -87,7 +87,7 @@ int main() assert(r == m.end()); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; { diff --git a/test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp b/test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp index 322c6f55130c..3f6852d085c3 100644 --- a/test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/upper_bound0.pass.cpp @@ -7,7 +7,7 @@ // //===----------------------------------------------------------------------===// // -// XFAIL: c++03, c++11 +// XFAIL: c++98, c++03, c++11 // <map> @@ -15,9 +15,9 @@ // iterator upper_bound(const key_type& k); // const_iterator upper_bound(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.ops/upper_bound1.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/upper_bound1.fail.cpp index bb78ad698160..d47d7bfc89f4 100644 --- a/test/std/containers/associative/multimap/multimap.ops/upper_bound1.fail.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/upper_bound1.fail.cpp @@ -13,9 +13,9 @@ // iterator upper_bound(const key_type& k); // const_iterator upper_bound(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.ops/upper_bound2.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/upper_bound2.fail.cpp index a79d5938e56e..a3da9d82c95c 100644 --- a/test/std/containers/associative/multimap/multimap.ops/upper_bound2.fail.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/upper_bound2.fail.cpp @@ -13,9 +13,9 @@ // iterator upper_bound(const key_type& k); // const_iterator upper_bound(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.ops/upper_bound3.fail.cpp b/test/std/containers/associative/multimap/multimap.ops/upper_bound3.fail.cpp index 1c1dc74b72c7..6ffdb206cc30 100644 --- a/test/std/containers/associative/multimap/multimap.ops/upper_bound3.fail.cpp +++ b/test/std/containers/associative/multimap/multimap.ops/upper_bound3.fail.cpp @@ -13,9 +13,9 @@ // iterator upper_bound(const key_type& k); // const_iterator upper_bound(const key_type& k) const; -// -// The member function templates find, count, lower_bound, upper_bound, and -// equal_range shall not participate in overload resolution unless the +// +// The member function templates find, count, lower_bound, upper_bound, and +// equal_range shall not participate in overload resolution unless the // qualified-id Compare::is_transparent is valid and denotes a type diff --git a/test/std/containers/associative/multimap/multimap.special/member_swap.pass.cpp b/test/std/containers/associative/multimap/multimap.special/member_swap.pass.cpp index fb17e7340bd4..f216f9f76a11 100644 --- a/test/std/containers/associative/multimap/multimap.special/member_swap.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.special/member_swap.pass.cpp @@ -96,7 +96,7 @@ int main() assert(m2 == m1_save); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; { diff --git a/test/std/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp b/test/std/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp index a91dfebb14a9..a075919bba9a 100644 --- a/test/std/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.special/non_member_swap.pass.cpp @@ -98,6 +98,7 @@ int main() assert(m1 == m2_save); assert(m2 == m1_save); } + } { typedef test_allocator<V> A; typedef test_compare<std::less<int> > C; @@ -166,8 +167,7 @@ int main() assert(m2.key_comp() == C(1)); assert(m2.get_allocator() == A(1)); } - } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; { @@ -242,6 +242,7 @@ int main() assert(m1 == m2_save); assert(m2 == m1_save); } + } { typedef min_allocator<V> A; typedef test_compare<std::less<int> > C; @@ -276,6 +277,5 @@ int main() assert(m2.key_comp() == C(1)); assert(m2.get_allocator() == A()); } - } #endif } diff --git a/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp b/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp index e70ee1fae565..ffc71b0eeb92 100644 --- a/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp +++ b/test/std/containers/associative/multimap/multimap.special/swap_noexcept.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <map> // void swap(multimap& c) @@ -15,13 +17,14 @@ // // In C++17, the standard says that swap shall have: // noexcept(allocator_traits<Allocator>::is_always_equal::value && -// noexcept(swap(declval<Compare&>(), declval<Compare&>()))); +// noexcept(swap(declval<Compare&>(), declval<Compare&>()))); // This tests a conforming extension #include <map> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -29,23 +32,20 @@ template <class T> struct some_comp { typedef T value_type; - + some_comp() {} some_comp(const some_comp&) {} - void deallocate(void*, unsigned) {} - - typedef std::true_type propagate_on_container_swap; + bool operator()(const T&, const T&) const { return false; } }; template <class T> struct some_comp2 { typedef T value_type; - + some_comp2() {} some_comp2(const some_comp2&) {} - void deallocate(void*, unsigned) {} - typedef std::true_type propagate_on_container_swap; + bool operator()(const T&, const T&) const { return false; } }; #if TEST_STD_VER >= 14 @@ -57,7 +57,7 @@ template <class T> struct some_alloc { typedef T value_type; - + some_alloc() {} some_alloc(const some_alloc&); void deallocate(void*, unsigned) {} @@ -69,7 +69,7 @@ template <class T> struct some_alloc2 { typedef T value_type; - + some_alloc2() {} some_alloc2(const some_alloc2&); void deallocate(void*, unsigned) {} @@ -82,7 +82,7 @@ template <class T> struct some_alloc3 { typedef T value_type; - + some_alloc3() {} some_alloc3(const some_alloc3&); void deallocate(void*, unsigned) {} @@ -93,7 +93,6 @@ struct some_alloc3 int main() { -#if __has_feature(cxx_noexcept) typedef std::pair<const MoveOnly, MoveOnly> V; { typedef std::multimap<MoveOnly, MoveOnly> C; @@ -144,6 +143,4 @@ int main() static_assert( noexcept(swap(c1, c2)), ""); } #endif - -#endif } diff --git a/test/std/containers/associative/multimap/size.pass.cpp b/test/std/containers/associative/multimap/size.pass.cpp index ac71d4c95b64..7ba7ceb2be6e 100644 --- a/test/std/containers/associative/multimap/size.pass.cpp +++ b/test/std/containers/associative/multimap/size.pass.cpp @@ -37,7 +37,7 @@ int main() m.erase(m.begin()); assert(m.size() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> M; M m; diff --git a/test/std/containers/associative/multimap/types.pass.cpp b/test/std/containers/associative/multimap/types.pass.cpp index a0f4db056a83..999ecbb7c223 100644 --- a/test/std/containers/associative/multimap/types.pass.cpp +++ b/test/std/containers/associative/multimap/types.pass.cpp @@ -50,7 +50,7 @@ int main() static_assert((std::is_same<C::size_type, std::size_t>::value), ""); static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), ""); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multimap<int, double, std::less<int>, min_allocator<std::pair<const int, double>>> C; static_assert((std::is_same<C::key_type, int>::value), ""); diff --git a/test/std/containers/associative/multiset/clear.pass.cpp b/test/std/containers/associative/multiset/clear.pass.cpp index 3069de5a300d..f762ef7d3504 100644 --- a/test/std/containers/associative/multiset/clear.pass.cpp +++ b/test/std/containers/associative/multiset/clear.pass.cpp @@ -39,7 +39,7 @@ int main() m.clear(); assert(m.size() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multiset<int, std::less<int>, min_allocator<int>> M; typedef int V; diff --git a/test/std/containers/associative/multiset/count.pass.cpp b/test/std/containers/associative/multiset/count.pass.cpp index 93bd6f80eaad..997a949388cf 100644 --- a/test/std/containers/associative/multiset/count.pass.cpp +++ b/test/std/containers/associative/multiset/count.pass.cpp @@ -55,7 +55,7 @@ int main() assert(r == 0); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int V; typedef std::multiset<int, std::less<int>, min_allocator<int>> M; diff --git a/test/std/containers/associative/multiset/emplace.pass.cpp b/test/std/containers/associative/multiset/emplace.pass.cpp index 450ee6cd35a3..93842a250f8e 100644 --- a/test/std/containers/associative/multiset/emplace.pass.cpp +++ b/test/std/containers/associative/multiset/emplace.pass.cpp @@ -68,7 +68,7 @@ int main() assert(m.size() == 1); assert(*r == 2); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multiset<int, std::less<int>, min_allocator<int>> M; typedef M::iterator R; diff --git a/test/std/containers/associative/multiset/emplace_hint.pass.cpp b/test/std/containers/associative/multiset/emplace_hint.pass.cpp index 194adf761c4c..48519fd4356a 100644 --- a/test/std/containers/associative/multiset/emplace_hint.pass.cpp +++ b/test/std/containers/associative/multiset/emplace_hint.pass.cpp @@ -68,7 +68,7 @@ int main() assert(m.size() == 1); assert(*r == 2); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multiset<int, std::less<int>, min_allocator<int>> M; typedef M::iterator R; diff --git a/test/std/containers/associative/multiset/empty.pass.cpp b/test/std/containers/associative/multiset/empty.pass.cpp index 32aef90d4188..acca4e021e0c 100644 --- a/test/std/containers/associative/multiset/empty.pass.cpp +++ b/test/std/containers/associative/multiset/empty.pass.cpp @@ -29,7 +29,7 @@ int main() m.clear(); assert(m.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multiset<int, std::less<int>, min_allocator<int>> M; M m; diff --git a/test/std/containers/associative/multiset/equal_range.pass.cpp b/test/std/containers/associative/multiset/equal_range.pass.cpp index 8c69d0c61ec5..7ab95cfb8f67 100644 --- a/test/std/containers/associative/multiset/equal_range.pass.cpp +++ b/test/std/containers/associative/multiset/equal_range.pass.cpp @@ -100,7 +100,7 @@ int main() assert(r.second == next(m.begin(), 9)); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int V; typedef std::multiset<int, std::less<int>, min_allocator<int>> M; diff --git a/test/std/containers/associative/multiset/erase_iter.pass.cpp b/test/std/containers/associative/multiset/erase_iter.pass.cpp index 1d41540edb8a..8ee45c64cff0 100644 --- a/test/std/containers/associative/multiset/erase_iter.pass.cpp +++ b/test/std/containers/associative/multiset/erase_iter.pass.cpp @@ -106,7 +106,7 @@ int main() assert(i == m.begin()); assert(i == m.end()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multiset<int, std::less<int>, min_allocator<int>> M; typedef int V; @@ -186,7 +186,7 @@ int main() assert(i == m.end()); } #endif -#if __cplusplus >= 201402L +#if TEST_STD_VER >= 14 { // This is LWG #2059 typedef TemplateConstructor T; diff --git a/test/std/containers/associative/multiset/erase_iter_iter.pass.cpp b/test/std/containers/associative/multiset/erase_iter_iter.pass.cpp index e1d7090d816f..70d3477907e3 100644 --- a/test/std/containers/associative/multiset/erase_iter_iter.pass.cpp +++ b/test/std/containers/associative/multiset/erase_iter_iter.pass.cpp @@ -78,7 +78,7 @@ int main() assert(m.size() == 0); assert(i == m.end()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multiset<int, std::less<int>, min_allocator<int>> M; typedef int V; diff --git a/test/std/containers/associative/multiset/erase_key.pass.cpp b/test/std/containers/associative/multiset/erase_key.pass.cpp index e9bce1e1b640..7293bcfb2c35 100644 --- a/test/std/containers/associative/multiset/erase_key.pass.cpp +++ b/test/std/containers/associative/multiset/erase_key.pass.cpp @@ -72,7 +72,7 @@ int main() assert(m.size() == 0); assert(i == 3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multiset<int, std::less<int>, min_allocator<int>> M; typedef int V; diff --git a/test/std/containers/associative/multiset/find.pass.cpp b/test/std/containers/associative/multiset/find.pass.cpp index 364460a6ca3a..3b7d96fe9110 100644 --- a/test/std/containers/associative/multiset/find.pass.cpp +++ b/test/std/containers/associative/multiset/find.pass.cpp @@ -92,7 +92,7 @@ int main() assert(r == next(m.begin(), 8)); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int V; typedef std::multiset<int, std::less<int>, min_allocator<int>> M; diff --git a/test/std/containers/associative/multiset/incomplete_type.pass.cpp b/test/std/containers/associative/multiset/incomplete_type.pass.cpp new file mode 100644 index 000000000000..0355e18f9f29 --- /dev/null +++ b/test/std/containers/associative/multiset/incomplete_type.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <set> + +// Check that std::multiset and it's iterators can be instantiated with an incomplete +// type. + +#include <set> + +struct A { + typedef std::multiset<A> Set; + int data; + Set m; + Set::iterator it; + Set::const_iterator cit; +}; + +inline bool operator==(A const& L, A const& R) { return &L == &R; } +inline bool operator<(A const& L, A const& R) { return L.data < R.data; } +int main() { + A a; +} diff --git a/test/std/containers/associative/set/version.pass.cpp b/test/std/containers/associative/multiset/insert_allocator_requirements.pass.cpp index c3c4d926e5c3..a280d10d5ab2 100644 --- a/test/std/containers/associative/set/version.pass.cpp +++ b/test/std/containers/associative/multiset/insert_allocator_requirements.pass.cpp @@ -9,12 +9,18 @@ // <set> +// class multiset + +// insert(...) + +// UNSUPPORTED: c++98, c++03 + #include <set> -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif +#include "container_test_types.h" +#include "../../set_allocator_requirement_test_templates.h" int main() { + testMultisetInsert<TCT::multiset<> >(); } diff --git a/test/std/containers/associative/multiset/insert_cv.pass.cpp b/test/std/containers/associative/multiset/insert_cv.pass.cpp index 179715753ab0..2aa920d70972 100644 --- a/test/std/containers/associative/multiset/insert_cv.pass.cpp +++ b/test/std/containers/associative/multiset/insert_cv.pass.cpp @@ -44,7 +44,7 @@ int main() assert(m.size() == 4); assert(*r == 3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multiset<int, std::less<int>, min_allocator<int>> M; typedef M::iterator R; diff --git a/test/std/containers/associative/multiset/insert_initializer_list.pass.cpp b/test/std/containers/associative/multiset/insert_initializer_list.pass.cpp index 7e923f2516dd..7b82cea5fbea 100644 --- a/test/std/containers/associative/multiset/insert_initializer_list.pass.cpp +++ b/test/std/containers/associative/multiset/insert_initializer_list.pass.cpp @@ -39,7 +39,7 @@ int main() assert(*++i == V(10)); } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multiset<int, std::less<int>, min_allocator<int>> C; typedef C::value_type V; diff --git a/test/std/containers/associative/multiset/insert_iter_cv.pass.cpp b/test/std/containers/associative/multiset/insert_iter_cv.pass.cpp index 7d204024c212..ca08bacad2f1 100644 --- a/test/std/containers/associative/multiset/insert_iter_cv.pass.cpp +++ b/test/std/containers/associative/multiset/insert_iter_cv.pass.cpp @@ -44,7 +44,7 @@ int main() assert(m.size() == 4); assert(*r == 3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multiset<int, std::less<int>, min_allocator<int>> M; typedef M::iterator R; diff --git a/test/std/containers/associative/multiset/insert_iter_iter.pass.cpp b/test/std/containers/associative/multiset/insert_iter_iter.pass.cpp index 189c45498669..fb664d74e4be 100644 --- a/test/std/containers/associative/multiset/insert_iter_iter.pass.cpp +++ b/test/std/containers/associative/multiset/insert_iter_iter.pass.cpp @@ -51,7 +51,7 @@ int main() assert(*next(m.begin(), 7) == 3); assert(*next(m.begin(), 8) == 3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multiset<int, std::less<int>, min_allocator<int>> M; typedef int V; diff --git a/test/std/containers/associative/multiset/insert_iter_rv.pass.cpp b/test/std/containers/associative/multiset/insert_iter_rv.pass.cpp index ee631f005c93..0afc8dc87c23 100644 --- a/test/std/containers/associative/multiset/insert_iter_rv.pass.cpp +++ b/test/std/containers/associative/multiset/insert_iter_rv.pass.cpp @@ -47,7 +47,7 @@ int main() assert(*r == 3); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multiset<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M; typedef M::iterator R; diff --git a/test/std/containers/associative/multiset/insert_rv.pass.cpp b/test/std/containers/associative/multiset/insert_rv.pass.cpp index 29c233e9a119..3ee464bc5bc7 100644 --- a/test/std/containers/associative/multiset/insert_rv.pass.cpp +++ b/test/std/containers/associative/multiset/insert_rv.pass.cpp @@ -47,7 +47,7 @@ int main() assert(*r == 3); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multiset<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M; typedef M::iterator R; diff --git a/test/std/containers/associative/multiset/iterator.pass.cpp b/test/std/containers/associative/multiset/iterator.pass.cpp index d1f0ecfd6aa0..c152a4398196 100644 --- a/test/std/containers/associative/multiset/iterator.pass.cpp +++ b/test/std/containers/associative/multiset/iterator.pass.cpp @@ -70,7 +70,7 @@ int main() std::multiset<int>::const_iterator k = i; assert(i == k); for (int j = 1; j <= 8; ++j) - for (int k = 0; k < 3; ++k, ++i) + for (int n = 0; n < 3; ++n, ++i) assert(*i == j); } { @@ -113,7 +113,7 @@ int main() for (int k = 0; k < 3; ++k, ++i) assert(*i == j); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int V; V ar[] = @@ -151,7 +151,7 @@ int main() std::multiset<int, std::less<int>, min_allocator<int>>::const_iterator k = i; assert(i == k); for (int j = 1; j <= 8; ++j) - for (int k = 0; k < 3; ++k, ++i) + for (int n = 0; n < 3; ++n, ++i) assert(*i == j); } { diff --git a/test/std/containers/associative/multiset/lower_bound.pass.cpp b/test/std/containers/associative/multiset/lower_bound.pass.cpp index e466791d9356..ae8cfe6eff4d 100644 --- a/test/std/containers/associative/multiset/lower_bound.pass.cpp +++ b/test/std/containers/associative/multiset/lower_bound.pass.cpp @@ -86,7 +86,7 @@ int main() assert(r == next(m.begin(), 9)); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int V; typedef std::multiset<int, std::less<int>, min_allocator<int>> M; diff --git a/test/std/containers/associative/multiset/max_size.pass.cpp b/test/std/containers/associative/multiset/max_size.pass.cpp index 5524f771b341..79492c9b1c40 100644 --- a/test/std/containers/associative/multiset/max_size.pass.cpp +++ b/test/std/containers/associative/multiset/max_size.pass.cpp @@ -25,7 +25,7 @@ int main() M m; assert(m.max_size() != 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multiset<int, std::less<int>, min_allocator<int>> M; M m; diff --git a/test/std/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp index 7d76581d6d8e..2c5318afd73b 100644 --- a/test/std/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/assign_initializer_list.pass.cpp @@ -37,7 +37,7 @@ int main() assert(*++i == V(6)); } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multiset<int, std::less<int>, min_allocator<int>> C; typedef C::value_type V; diff --git a/test/std/containers/associative/multiset/multiset.cons/compare_copy_constructible.fail.cpp b/test/std/containers/associative/multiset/multiset.cons/compare_copy_constructible.fail.cpp new file mode 100644 index 000000000000..2eade5299d6f --- /dev/null +++ b/test/std/containers/associative/multiset/multiset.cons/compare_copy_constructible.fail.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <set> + +// Check that std::multiset fails to instantiate if the comparison predicate is +// not copy-constructible. This is LWG issue 2436 + +#include <set> + +template <class T> +struct Comp { + bool operator () (const T& lhs, const T& rhs) const { return lhs < rhs; } + + Comp () {} +private: + Comp (const Comp &); // declared but not defined + }; + + +int main() { + std::multiset<int, Comp<int> > m; +} diff --git a/test/std/containers/associative/multiset/multiset.cons/default.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/default.pass.cpp index 5bb0312f012b..0bc50ab7aaf8 100644 --- a/test/std/containers/associative/multiset/multiset.cons/default.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/default.pass.cpp @@ -25,7 +25,7 @@ int main() assert(m.empty()); assert(m.begin() == m.end()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::multiset<int, std::less<int>, min_allocator<int>> m; assert(m.empty()); diff --git a/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp index bf8c53b9ee5d..15520e7834ff 100644 --- a/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/default_noexcept.pass.cpp @@ -17,9 +17,12 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <set> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -28,18 +31,18 @@ struct some_comp { typedef T value_type; some_comp(); + bool operator()(const T&, const T&) const { return false; } }; int main() { -#if __has_feature(cxx_noexcept) { typedef std::multiset<MoveOnly> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::multiset<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::multiset<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; @@ -49,5 +52,4 @@ int main() typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp index fd612c06dbbc..f4e868ebbc8f 100644 --- a/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/dtor_noexcept.pass.cpp @@ -11,26 +11,24 @@ // ~multiset() // implied noexcept; +// UNSUPPORTED: c++98, c++03 + #include <set> #include <cassert> #include "MoveOnly.h" #include "test_allocator.h" -#if __has_feature(cxx_noexcept) - template <class T> struct some_comp { typedef T value_type; ~some_comp() noexcept(false); + bool operator()(const T&, const T&) const { return false; } }; -#endif - int main() { -#if __has_feature(cxx_noexcept) { typedef std::multiset<MoveOnly> C; static_assert(std::is_nothrow_destructible<C>::value, ""); @@ -47,5 +45,4 @@ int main() typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_destructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp index dadafec7c3b1..7327bf62646b 100644 --- a/test/std/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/initializer_list.pass.cpp @@ -36,7 +36,7 @@ int main() assert(*++i == V(6)); } #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multiset<int, std::less<int>, min_allocator<int>> C; typedef C::value_type V; diff --git a/test/std/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp index f6c1fd76de14..ebe8353bab1f 100644 --- a/test/std/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/iter_iter.pass.cpp @@ -50,7 +50,7 @@ int main() assert(*next(m.begin(), 7) == 3); assert(*next(m.begin(), 8) == 3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int V; V ar[] = diff --git a/test/std/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp index 4ed00c7124cc..4313f46a03d7 100644 --- a/test/std/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/iter_iter_alloc.pass.cpp @@ -24,6 +24,7 @@ int main() { + { typedef int V; V ar[] = { @@ -55,6 +56,7 @@ int main() assert(*next(m.begin(), 6) == 3); assert(*next(m.begin(), 7) == 3); assert(*next(m.begin(), 8) == 3); + } #if _LIBCPP_STD_VER > 11 { typedef int V; diff --git a/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp index 40321cd247e1..5a905cf15a08 100644 --- a/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/move.pass.cpp @@ -77,7 +77,7 @@ int main() assert(distance(mo.begin(), mo.end()) == 0); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int V; V ar[] = diff --git a/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp index 4408208f2ac4..3da3fc09a45f 100644 --- a/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/move_alloc.pass.cpp @@ -163,7 +163,7 @@ int main() M m1(I(a1), I(a1+num), C(), A()); assert(Counter_base::gConstructed == 2*num); - + M m2(m1); assert(m2 == m1); assert(Counter_base::gConstructed == 3*num); @@ -181,7 +181,7 @@ int main() } assert(Counter_base::gConstructed == 2*num); } - assert(Counter_base::gConstructed == 0); + assert(Counter_base::gConstructed == 0); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp index ca1ba971f5a4..b0ec4f39451c 100644 --- a/test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/move_assign.pass.cpp @@ -142,7 +142,7 @@ int main() assert(m1.empty()); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef MoveOnly V; typedef test_compare<std::less<MoveOnly> > C; diff --git a/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp index 211bb36e7e95..57388637e97a 100644 --- a/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/move_assign_noexcept.pass.cpp @@ -17,6 +17,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <set> #include <cassert> @@ -28,11 +30,11 @@ struct some_comp { typedef T value_type; some_comp& operator=(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; int main() { -#if __has_feature(cxx_noexcept) { typedef std::multiset<MoveOnly> C; static_assert(std::is_nothrow_move_assignable<C>::value, ""); @@ -49,5 +51,4 @@ int main() typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } -#endif } diff --git a/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp index 31a34cbde306..e3a7beedb92b 100644 --- a/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.cons/move_noexcept.pass.cpp @@ -15,6 +15,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <set> #include <cassert> @@ -26,11 +28,11 @@ struct some_comp { typedef T value_type; some_comp(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; int main() { -#if __has_feature(cxx_noexcept) { typedef std::multiset<MoveOnly> C; static_assert(std::is_nothrow_move_constructible<C>::value, ""); @@ -47,5 +49,4 @@ int main() typedef std::multiset<MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/associative/multiset/multiset.special/member_swap.pass.cpp b/test/std/containers/associative/multiset/multiset.special/member_swap.pass.cpp index 7745ddab78c3..7036138f8439 100644 --- a/test/std/containers/associative/multiset/multiset.special/member_swap.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.special/member_swap.pass.cpp @@ -96,7 +96,7 @@ int main() assert(m2 == m1_save); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int V; typedef std::multiset<int, std::less<int>, min_allocator<int>> M; diff --git a/test/std/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp b/test/std/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp index f456de7f6243..91ec4ce93a27 100644 --- a/test/std/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.special/non_member_swap.pass.cpp @@ -21,6 +21,7 @@ int main() { typedef int V; + { typedef std::multiset<int> M; { M m1; @@ -94,6 +95,7 @@ int main() assert(m1 == m2_save); assert(m2 == m1_save); } + } { typedef test_allocator<V> A; typedef test_compare<std::less<int> > C; diff --git a/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp b/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp index 8e2c67c9b5ec..87639943a0b5 100644 --- a/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp +++ b/test/std/containers/associative/multiset/multiset.special/swap_noexcept.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <set> // void swap(multiset& c) @@ -15,13 +17,14 @@ // // In C++17, the standard says that swap shall have: // noexcept(allocator_traits<Allocator>::is_always_equal::value && -// noexcept(swap(declval<Compare&>(), declval<Compare&>()))); +// noexcept(swap(declval<Compare&>(), declval<Compare&>()))); // This tests a conforming extension #include <set> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -29,23 +32,20 @@ template <class T> struct some_comp { typedef T value_type; - + some_comp() {} some_comp(const some_comp&) {} - void deallocate(void*, unsigned) {} - - typedef std::true_type propagate_on_container_swap; + bool operator()(const T&, const T&) const { return false; } }; template <class T> struct some_comp2 { typedef T value_type; - + some_comp2() {} some_comp2(const some_comp2&) {} - void deallocate(void*, unsigned) {} - typedef std::true_type propagate_on_container_swap; + bool operator()(const T&, const T&) const { return false; } }; #if TEST_STD_VER >= 14 @@ -57,7 +57,7 @@ template <class T> struct some_alloc { typedef T value_type; - + some_alloc() {} some_alloc(const some_alloc&); void deallocate(void*, unsigned) {} @@ -69,7 +69,7 @@ template <class T> struct some_alloc2 { typedef T value_type; - + some_alloc2() {} some_alloc2(const some_alloc2&); void deallocate(void*, unsigned) {} @@ -82,7 +82,7 @@ template <class T> struct some_alloc3 { typedef T value_type; - + some_alloc3() {} some_alloc3(const some_alloc3&); void deallocate(void*, unsigned) {} @@ -93,7 +93,6 @@ struct some_alloc3 int main() { -#if __has_feature(cxx_noexcept) { typedef std::multiset<MoveOnly> C; C c1, c2; @@ -143,6 +142,4 @@ int main() static_assert( noexcept(swap(c1, c2)), ""); } #endif - -#endif } diff --git a/test/std/containers/associative/multiset/size.pass.cpp b/test/std/containers/associative/multiset/size.pass.cpp index 68099b566dfd..d11975b79935 100644 --- a/test/std/containers/associative/multiset/size.pass.cpp +++ b/test/std/containers/associative/multiset/size.pass.cpp @@ -37,7 +37,7 @@ int main() m.erase(m.begin()); assert(m.size() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multiset<int, std::less<int>, min_allocator<int>> M; M m; diff --git a/test/std/containers/associative/multiset/types.pass.cpp b/test/std/containers/associative/multiset/types.pass.cpp index e1e3ad9100c3..b37b9b328f8f 100644 --- a/test/std/containers/associative/multiset/types.pass.cpp +++ b/test/std/containers/associative/multiset/types.pass.cpp @@ -50,7 +50,7 @@ int main() static_assert((std::is_same<C::size_type, std::size_t>::value), ""); static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), ""); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::multiset<int, std::less<int>, min_allocator<int>> C; static_assert((std::is_same<C::key_type, int>::value), ""); diff --git a/test/std/containers/associative/multiset/upper_bound.pass.cpp b/test/std/containers/associative/multiset/upper_bound.pass.cpp index 7ad3d6ced3d6..7bb0c3cb41f3 100644 --- a/test/std/containers/associative/multiset/upper_bound.pass.cpp +++ b/test/std/containers/associative/multiset/upper_bound.pass.cpp @@ -86,7 +86,7 @@ int main() assert(r == next(m.begin(), 9)); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int V; typedef std::multiset<int, std::less<int>, min_allocator<int>> M; diff --git a/test/std/containers/associative/set/clear.pass.cpp b/test/std/containers/associative/set/clear.pass.cpp index 4439ad3b1e4e..7a5bf4b14a71 100644 --- a/test/std/containers/associative/set/clear.pass.cpp +++ b/test/std/containers/associative/set/clear.pass.cpp @@ -39,7 +39,7 @@ int main() m.clear(); assert(m.size() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::set<int, std::less<int>, min_allocator<int>> M; typedef int V; diff --git a/test/std/containers/associative/set/count.pass.cpp b/test/std/containers/associative/set/count.pass.cpp index 32fe0b8bcee9..ddc913910b5e 100644 --- a/test/std/containers/associative/set/count.pass.cpp +++ b/test/std/containers/associative/set/count.pass.cpp @@ -56,7 +56,7 @@ int main() r = m.count(4); assert(r == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int V; typedef std::set<int, std::less<int>, min_allocator<int>> M; diff --git a/test/std/containers/associative/set/emplace.pass.cpp b/test/std/containers/associative/set/emplace.pass.cpp index 5ebab4d24b92..47ef455a996b 100644 --- a/test/std/containers/associative/set/emplace.pass.cpp +++ b/test/std/containers/associative/set/emplace.pass.cpp @@ -74,7 +74,7 @@ int main() assert(m.size() == 1); assert(*r.first == 2); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::set<int, std::less<int>, min_allocator<int>> M; typedef std::pair<M::iterator, bool> R; diff --git a/test/std/containers/associative/set/emplace_hint.pass.cpp b/test/std/containers/associative/set/emplace_hint.pass.cpp index 5fdeb4ffef3a..036f4d6dfb68 100644 --- a/test/std/containers/associative/set/emplace_hint.pass.cpp +++ b/test/std/containers/associative/set/emplace_hint.pass.cpp @@ -68,7 +68,7 @@ int main() assert(m.size() == 1); assert(*r == 2); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::set<int, std::less<int>, min_allocator<int>> M; typedef M::iterator R; diff --git a/test/std/containers/associative/set/empty.pass.cpp b/test/std/containers/associative/set/empty.pass.cpp index eb1080263f4f..1eaa8fc90537 100644 --- a/test/std/containers/associative/set/empty.pass.cpp +++ b/test/std/containers/associative/set/empty.pass.cpp @@ -29,7 +29,7 @@ int main() m.clear(); assert(m.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::set<int, std::less<int>, min_allocator<int>> M; M m; diff --git a/test/std/containers/associative/set/equal_range.pass.cpp b/test/std/containers/associative/set/equal_range.pass.cpp index 8a180ef49248..ed41f691a459 100644 --- a/test/std/containers/associative/set/equal_range.pass.cpp +++ b/test/std/containers/associative/set/equal_range.pass.cpp @@ -158,7 +158,7 @@ int main() assert(r.second == next(m.begin(), 8)); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int V; typedef std::set<int, std::less<int>, min_allocator<int>> M; diff --git a/test/std/containers/associative/set/erase_iter.pass.cpp b/test/std/containers/associative/set/erase_iter.pass.cpp index 36828be86f28..85be1f5b9c21 100644 --- a/test/std/containers/associative/set/erase_iter.pass.cpp +++ b/test/std/containers/associative/set/erase_iter.pass.cpp @@ -106,7 +106,7 @@ int main() assert(i == m.begin()); assert(i == m.end()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::set<int, std::less<int>, min_allocator<int>> M; typedef int V; @@ -186,7 +186,7 @@ int main() assert(i == m.end()); } #endif -#if __cplusplus >= 201402L +#if TEST_STD_VER >= 14 { // This is LWG #2059 typedef TemplateConstructor T; diff --git a/test/std/containers/associative/set/erase_iter_iter.pass.cpp b/test/std/containers/associative/set/erase_iter_iter.pass.cpp index 479950316655..775e6cea06fa 100644 --- a/test/std/containers/associative/set/erase_iter_iter.pass.cpp +++ b/test/std/containers/associative/set/erase_iter_iter.pass.cpp @@ -78,7 +78,7 @@ int main() assert(m.size() == 0); assert(i == m.end()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::set<int, std::less<int>, min_allocator<int>> M; typedef int V; diff --git a/test/std/containers/associative/set/erase_key.pass.cpp b/test/std/containers/associative/set/erase_key.pass.cpp index 9d92bd70d700..6fc15d9ccfd4 100644 --- a/test/std/containers/associative/set/erase_key.pass.cpp +++ b/test/std/containers/associative/set/erase_key.pass.cpp @@ -109,7 +109,7 @@ int main() assert(m.size() == 0); assert(i == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::set<int, std::less<int>, min_allocator<int>> M; typedef int V; diff --git a/test/std/containers/associative/set/find.pass.cpp b/test/std/containers/associative/set/find.pass.cpp index d08d2fb1e245..60f16fcd65d4 100644 --- a/test/std/containers/associative/set/find.pass.cpp +++ b/test/std/containers/associative/set/find.pass.cpp @@ -92,7 +92,7 @@ int main() assert(r == next(m.begin(), 8)); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int V; typedef std::set<int, std::less<int>, min_allocator<int>> M; diff --git a/test/std/containers/associative/set/incomplete_type.pass.cpp b/test/std/containers/associative/set/incomplete_type.pass.cpp new file mode 100644 index 000000000000..d3a1d6638d7e --- /dev/null +++ b/test/std/containers/associative/set/incomplete_type.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <set> + +// Check that std::set and it's iterators can be instantiated with an incomplete +// type. + +#include <set> + +struct A { + typedef std::set<A> Set; + int data; + Set m; + Set::iterator it; + Set::const_iterator cit; +}; + +inline bool operator==(A const& L, A const& R) { return &L == &R; } +inline bool operator<(A const& L, A const& R) { return L.data < R.data; } +int main() { + A a; +} diff --git a/test/std/containers/associative/set/insert_and_emplace_allocator_requirements.pass.cpp b/test/std/containers/associative/set/insert_and_emplace_allocator_requirements.pass.cpp new file mode 100644 index 000000000000..b14340b1d763 --- /dev/null +++ b/test/std/containers/associative/set/insert_and_emplace_allocator_requirements.pass.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <set> + +// class set + +// insert(...) +// emplace(...) +// emplace_hint(...) + +// UNSUPPORTED: c++98, c++03 + +#include <set> +#include "container_test_types.h" +#include "../../set_allocator_requirement_test_templates.h" + +int main() +{ + testSetInsert<TCT::set<> >(); + testSetEmplace<TCT::set<> >(); + testSetEmplaceHint<TCT::set<> >(); +} diff --git a/test/std/containers/associative/set/insert_cv.pass.cpp b/test/std/containers/associative/set/insert_cv.pass.cpp index 18d5c2e03395..8d5290a97af9 100644 --- a/test/std/containers/associative/set/insert_cv.pass.cpp +++ b/test/std/containers/associative/set/insert_cv.pass.cpp @@ -48,7 +48,7 @@ int main() assert(m.size() == 3); assert(*r.first == 3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::set<int, std::less<int>, min_allocator<int>> M; typedef std::pair<M::iterator, bool> R; diff --git a/test/std/containers/associative/set/insert_initializer_list.pass.cpp b/test/std/containers/associative/set/insert_initializer_list.pass.cpp index fc6d612b2ebe..60a6e754e17e 100644 --- a/test/std/containers/associative/set/insert_initializer_list.pass.cpp +++ b/test/std/containers/associative/set/insert_initializer_list.pass.cpp @@ -38,7 +38,7 @@ int main() assert(*++i == V(8)); assert(*++i == V(10)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::set<int, std::less<int>, min_allocator<int>> C; typedef C::value_type V; diff --git a/test/std/containers/associative/set/insert_iter_cv.pass.cpp b/test/std/containers/associative/set/insert_iter_cv.pass.cpp index 718e720559f4..12d6402a87c2 100644 --- a/test/std/containers/associative/set/insert_iter_cv.pass.cpp +++ b/test/std/containers/associative/set/insert_iter_cv.pass.cpp @@ -44,7 +44,7 @@ int main() assert(m.size() == 3); assert(*r == 3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::set<int, std::less<int>, min_allocator<int>> M; typedef M::iterator R; diff --git a/test/std/containers/associative/set/insert_iter_iter.pass.cpp b/test/std/containers/associative/set/insert_iter_iter.pass.cpp index ff729a0e7b9b..46edd0db0468 100644 --- a/test/std/containers/associative/set/insert_iter_iter.pass.cpp +++ b/test/std/containers/associative/set/insert_iter_iter.pass.cpp @@ -45,7 +45,7 @@ int main() assert(*next(m.begin()) == 2); assert(*next(m.begin(), 2) == 3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::set<int, std::less<int>, min_allocator<int>> M; typedef int V; diff --git a/test/std/containers/associative/set/insert_iter_rv.pass.cpp b/test/std/containers/associative/set/insert_iter_rv.pass.cpp index 296ead84914d..be827d644d26 100644 --- a/test/std/containers/associative/set/insert_iter_rv.pass.cpp +++ b/test/std/containers/associative/set/insert_iter_rv.pass.cpp @@ -46,7 +46,7 @@ int main() assert(m.size() == 3); assert(*r == 3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::set<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M; typedef M::iterator R; diff --git a/test/std/containers/associative/set/insert_rv.pass.cpp b/test/std/containers/associative/set/insert_rv.pass.cpp index 32cede154956..e528ef347b88 100644 --- a/test/std/containers/associative/set/insert_rv.pass.cpp +++ b/test/std/containers/associative/set/insert_rv.pass.cpp @@ -50,7 +50,7 @@ int main() assert(m.size() == 3); assert(*r.first == 3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::set<MoveOnly, std::less<MoveOnly>, min_allocator<MoveOnly>> M; typedef std::pair<M::iterator, bool> R; diff --git a/test/std/containers/associative/set/iterator.pass.cpp b/test/std/containers/associative/set/iterator.pass.cpp index ecd950f03a00..c318341ce859 100644 --- a/test/std/containers/associative/set/iterator.pass.cpp +++ b/test/std/containers/associative/set/iterator.pass.cpp @@ -111,7 +111,7 @@ int main() for (int j = 1; j <= m.size(); ++j, ++i) assert(*i == j); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int V; V ar[] = diff --git a/test/std/containers/associative/set/lower_bound.pass.cpp b/test/std/containers/associative/set/lower_bound.pass.cpp index df202f31a4c3..55d49a097ef6 100644 --- a/test/std/containers/associative/set/lower_bound.pass.cpp +++ b/test/std/containers/associative/set/lower_bound.pass.cpp @@ -124,7 +124,7 @@ int main() assert(r == next(m.begin(), 8)); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int V; typedef std::set<int, std::less<int>, min_allocator<int>> M; @@ -281,7 +281,7 @@ int main() r = m.lower_bound(20); assert(r == next(m.begin(), 8)); } - + { typedef PrivateConstructor V; typedef std::set<V, std::less<>> M; diff --git a/test/std/containers/associative/set/max_size.pass.cpp b/test/std/containers/associative/set/max_size.pass.cpp index cde4397c7178..9df6a4157e11 100644 --- a/test/std/containers/associative/set/max_size.pass.cpp +++ b/test/std/containers/associative/set/max_size.pass.cpp @@ -25,7 +25,7 @@ int main() M m; assert(m.max_size() != 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::set<int, std::less<int>, min_allocator<int>> M; M m; diff --git a/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp b/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp index 892ae5a0a799..70e174a59612 100644 --- a/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp +++ b/test/std/containers/associative/set/set.cons/assign_initializer_list.pass.cpp @@ -36,7 +36,7 @@ int main() assert(*++i == V(5)); assert(*++i == V(6)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::set<int, std::less<int>, min_allocator<int>> C; typedef C::value_type V; diff --git a/test/std/containers/associative/set/set.cons/compare_copy_constructible.fail.cpp b/test/std/containers/associative/set/set.cons/compare_copy_constructible.fail.cpp new file mode 100644 index 000000000000..dcf23effc443 --- /dev/null +++ b/test/std/containers/associative/set/set.cons/compare_copy_constructible.fail.cpp @@ -0,0 +1,29 @@ +//===----------------------------------------------------------------------===// +// +// The LLVM Compiler Infrastructure +// +// This file is dual licensed under the MIT and the University of Illinois Open +// Source Licenses. See LICENSE.TXT for details. +// +//===----------------------------------------------------------------------===// + +// <set> + +// Check that std::set fails to instantiate if the comparison predicate is +// not copy-constructible. This is LWG issue 2436 + +#include <set> + +template <class T> +struct Comp { + bool operator () (const T& lhs, const T& rhs) const { return lhs < rhs; } + + Comp () {} +private: + Comp (const Comp &); // declared but not defined + }; + + +int main() { + std::set<int, Comp<int> > m; +} diff --git a/test/std/containers/associative/set/set.cons/default.pass.cpp b/test/std/containers/associative/set/set.cons/default.pass.cpp index 746a2d173071..4c924ca70e96 100644 --- a/test/std/containers/associative/set/set.cons/default.pass.cpp +++ b/test/std/containers/associative/set/set.cons/default.pass.cpp @@ -25,7 +25,7 @@ int main() assert(m.empty()); assert(m.begin() == m.end()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::set<int, std::less<int>, min_allocator<int>> m; assert(m.empty()); diff --git a/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp b/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp index 2156169acbc4..6293c24a43d3 100644 --- a/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp +++ b/test/std/containers/associative/set/set.cons/default_noexcept.pass.cpp @@ -17,9 +17,12 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <set> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -28,18 +31,18 @@ struct some_comp { typedef T value_type; some_comp(); + bool operator()(const T&, const T&) const { return false; } }; int main() { -#if __has_feature(cxx_noexcept) { typedef std::set<MoveOnly> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::set<MoveOnly, std::less<MoveOnly>, test_allocator<MoveOnly>> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::set<MoveOnly, std::less<MoveOnly>, other_allocator<MoveOnly>> C; @@ -49,5 +52,4 @@ int main() typedef std::set<MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp b/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp index b554d828d486..60d1d42c3d9c 100644 --- a/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/associative/set/set.cons/dtor_noexcept.pass.cpp @@ -11,26 +11,24 @@ // ~set() // implied noexcept; +// UNSUPPORTED: c++98, c++03 + #include <set> #include <cassert> #include "MoveOnly.h" #include "test_allocator.h" -#if __has_feature(cxx_noexcept) - template <class T> struct some_comp { typedef T value_type; ~some_comp() noexcept(false); + bool operator()(const T&, const T&) const { return false; } }; -#endif - int main() { -#if __has_feature(cxx_noexcept) { typedef std::set<MoveOnly> C; static_assert(std::is_nothrow_destructible<C>::value, ""); @@ -47,5 +45,4 @@ int main() typedef std::set<MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_destructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/associative/set/set.cons/initializer_list.pass.cpp b/test/std/containers/associative/set/set.cons/initializer_list.pass.cpp index 2ad538e143f8..5bb5460ddc0d 100644 --- a/test/std/containers/associative/set/set.cons/initializer_list.pass.cpp +++ b/test/std/containers/associative/set/set.cons/initializer_list.pass.cpp @@ -35,7 +35,7 @@ int main() assert(*++i == V(5)); assert(*++i == V(6)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::set<int, std::less<int>, min_allocator<int>> C; typedef C::value_type V; diff --git a/test/std/containers/associative/set/set.cons/iter_iter.pass.cpp b/test/std/containers/associative/set/set.cons/iter_iter.pass.cpp index 7ca7fe14d6c4..db765bd9e337 100644 --- a/test/std/containers/associative/set/set.cons/iter_iter.pass.cpp +++ b/test/std/containers/associative/set/set.cons/iter_iter.pass.cpp @@ -44,7 +44,7 @@ int main() assert(*next(m.begin()) == 2); assert(*next(m.begin(), 2) == 3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int V; V ar[] = diff --git a/test/std/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp b/test/std/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp index 5ccb6e5cbcd7..077a749caaca 100644 --- a/test/std/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp +++ b/test/std/containers/associative/set/set.cons/iter_iter_alloc.pass.cpp @@ -28,6 +28,7 @@ int main() { + { typedef int V; V ar[] = { @@ -53,6 +54,7 @@ int main() assert(*m.begin() == 1); assert(*next(m.begin()) == 2); assert(*next(m.begin(), 2) == 3); + } #if _LIBCPP_STD_VER > 11 { typedef int V; diff --git a/test/std/containers/associative/set/set.cons/move.pass.cpp b/test/std/containers/associative/set/set.cons/move.pass.cpp index 4026ec70c3e1..c836d4550203 100644 --- a/test/std/containers/associative/set/set.cons/move.pass.cpp +++ b/test/std/containers/associative/set/set.cons/move.pass.cpp @@ -70,7 +70,7 @@ int main() assert(mo.size() == 0); assert(distance(mo.begin(), mo.end()) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int V; V ar[] = diff --git a/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp b/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp index 799f0e402d63..ba2adf5bb520 100644 --- a/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp +++ b/test/std/containers/associative/set/set.cons/move_alloc.pass.cpp @@ -163,7 +163,7 @@ int main() M m1(I(a1), I(a1+num), C(), A()); assert(Counter_base::gConstructed == 3+num); - + M m2(m1); assert(m2 == m1); assert(Counter_base::gConstructed == 6+num); @@ -181,7 +181,7 @@ int main() } assert(Counter_base::gConstructed == 3+num); } - assert(Counter_base::gConstructed == 0); + assert(Counter_base::gConstructed == 0); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES diff --git a/test/std/containers/associative/set/set.cons/move_assign.pass.cpp b/test/std/containers/associative/set/set.cons/move_assign.pass.cpp index ed0e77ae1796..07cb4153fa4a 100644 --- a/test/std/containers/associative/set/set.cons/move_assign.pass.cpp +++ b/test/std/containers/associative/set/set.cons/move_assign.pass.cpp @@ -141,7 +141,7 @@ int main() assert(m3.key_comp() == C(5)); assert(m1.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef MoveOnly V; typedef test_compare<std::less<MoveOnly> > C; diff --git a/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp b/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp index 3999c55e9e7c..3f7d783b7630 100644 --- a/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/associative/set/set.cons/move_assign_noexcept.pass.cpp @@ -17,6 +17,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <set> #include <cassert> @@ -28,11 +30,11 @@ struct some_comp { typedef T value_type; some_comp& operator=(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; int main() { -#if __has_feature(cxx_noexcept) { typedef std::set<MoveOnly> C; static_assert(std::is_nothrow_move_assignable<C>::value, ""); @@ -49,5 +51,4 @@ int main() typedef std::set<MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } -#endif } diff --git a/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp b/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp index 5ccfed4675c5..72c2f7530a9e 100644 --- a/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp +++ b/test/std/containers/associative/set/set.cons/move_noexcept.pass.cpp @@ -15,6 +15,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <set> #include <cassert> @@ -26,11 +28,11 @@ struct some_comp { typedef T value_type; some_comp(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; int main() { -#if __has_feature(cxx_noexcept) { typedef std::set<MoveOnly> C; static_assert(std::is_nothrow_move_constructible<C>::value, ""); @@ -47,5 +49,4 @@ int main() typedef std::set<MoveOnly, some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/associative/set/set.special/member_swap.pass.cpp b/test/std/containers/associative/set/set.special/member_swap.pass.cpp index b5129f880afd..486d5f44291b 100644 --- a/test/std/containers/associative/set/set.special/member_swap.pass.cpp +++ b/test/std/containers/associative/set/set.special/member_swap.pass.cpp @@ -96,7 +96,7 @@ int main() assert(m2 == m1_save); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int V; typedef std::set<int, std::less<int>, min_allocator<int>> M; diff --git a/test/std/containers/associative/set/set.special/non_member_swap.pass.cpp b/test/std/containers/associative/set/set.special/non_member_swap.pass.cpp index 0ac14464c70f..3d2d7d7d3bbc 100644 --- a/test/std/containers/associative/set/set.special/non_member_swap.pass.cpp +++ b/test/std/containers/associative/set/set.special/non_member_swap.pass.cpp @@ -21,6 +21,7 @@ int main() { typedef int V; + { typedef std::set<int> M; { M m1; @@ -94,6 +95,7 @@ int main() assert(m1 == m2_save); assert(m2 == m1_save); } + } { typedef test_allocator<V> A; typedef test_compare<std::less<int> > C; diff --git a/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp b/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp index 3ec697612754..0eb7d871b8b4 100644 --- a/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp +++ b/test/std/containers/associative/set/set.special/swap_noexcept.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <set> // void swap(set& c) @@ -15,13 +17,14 @@ // // In C++17, the standard says that swap shall have: // noexcept(allocator_traits<Allocator>::is_always_equal::value && -// noexcept(swap(declval<Compare&>(), declval<Compare&>()))); +// noexcept(swap(declval<Compare&>(), declval<Compare&>()))); // This tests a conforming extension #include <set> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -29,23 +32,20 @@ template <class T> struct some_comp { typedef T value_type; - + some_comp() {} some_comp(const some_comp&) {} - void deallocate(void*, unsigned) {} - - typedef std::true_type propagate_on_container_swap; + bool operator()(const T&, const T&) const { return false; } }; template <class T> struct some_comp2 { typedef T value_type; - + some_comp2() {} some_comp2(const some_comp2&) {} - void deallocate(void*, unsigned) {} - typedef std::true_type propagate_on_container_swap; + bool operator()(const T&, const T&) const { return false; } }; #if TEST_STD_VER >= 14 @@ -57,7 +57,7 @@ template <class T> struct some_alloc { typedef T value_type; - + some_alloc() {} some_alloc(const some_alloc&); void deallocate(void*, unsigned) {} @@ -69,7 +69,7 @@ template <class T> struct some_alloc2 { typedef T value_type; - + some_alloc2() {} some_alloc2(const some_alloc2&); void deallocate(void*, unsigned) {} @@ -82,7 +82,7 @@ template <class T> struct some_alloc3 { typedef T value_type; - + some_alloc3() {} some_alloc3(const some_alloc3&); void deallocate(void*, unsigned) {} @@ -93,7 +93,6 @@ struct some_alloc3 int main() { -#if __has_feature(cxx_noexcept) { typedef std::set<MoveOnly> C; C c1, c2; @@ -144,5 +143,4 @@ int main() } #endif -#endif } diff --git a/test/std/containers/associative/set/size.pass.cpp b/test/std/containers/associative/set/size.pass.cpp index e78654735508..853aeca74366 100644 --- a/test/std/containers/associative/set/size.pass.cpp +++ b/test/std/containers/associative/set/size.pass.cpp @@ -37,7 +37,7 @@ int main() m.erase(m.begin()); assert(m.size() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::set<int, std::less<int>, min_allocator<int>> M; M m; diff --git a/test/std/containers/associative/set/types.pass.cpp b/test/std/containers/associative/set/types.pass.cpp index 3362c42aee42..f1ce8a7c975c 100644 --- a/test/std/containers/associative/set/types.pass.cpp +++ b/test/std/containers/associative/set/types.pass.cpp @@ -50,7 +50,7 @@ int main() static_assert((std::is_same<C::size_type, std::size_t>::value), ""); static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), ""); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::set<int, std::less<int>, min_allocator<int>> C; static_assert((std::is_same<C::key_type, int>::value), ""); diff --git a/test/std/containers/associative/set/upper_bound.pass.cpp b/test/std/containers/associative/set/upper_bound.pass.cpp index 10a28f064698..9d4ab2805d0d 100644 --- a/test/std/containers/associative/set/upper_bound.pass.cpp +++ b/test/std/containers/associative/set/upper_bound.pass.cpp @@ -124,7 +124,7 @@ int main() assert(r == next(m.begin(), 8)); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int V; typedef std::set<int, std::less<int>, min_allocator<int>> M; @@ -281,7 +281,7 @@ int main() r = m.upper_bound(20); assert(r == next(m.begin(), 8)); } - + { typedef PrivateConstructor V; typedef std::set<V, std::less<>> M; diff --git a/test/std/containers/associative/tree_balance_after_insert.pass.cpp b/test/std/containers/associative/tree_balance_after_insert.pass.cpp deleted file mode 100644 index b0a3e74cab0a..000000000000 --- a/test/std/containers/associative/tree_balance_after_insert.pass.cpp +++ /dev/null @@ -1,1616 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// Not a portable test - -// Precondition: __root->__is_black_ == true -// template <class _NodePtr> -// void -// __tree_balance_after_insert(_NodePtr __root, _NodePtr __x) - -#include <__tree> -#include <cassert> - -struct Node -{ - Node* __left_; - Node* __right_; - Node* __parent_; - bool __is_black_; - - Node() : __left_(), __right_(), __parent_(), __is_black_() {} -}; - -void -test1() -{ - { - Node root; - Node a; - Node b; - Node c; - Node d; - - root.__left_ = &c; - - c.__parent_ = &root; - c.__left_ = &b; - c.__right_ = &d; - c.__is_black_ = true; - - b.__parent_ = &c; - b.__left_ = &a; - b.__right_ = 0; - b.__is_black_ = false; - - d.__parent_ = &c; - d.__left_ = 0; - d.__right_ = 0; - d.__is_black_ = false; - - a.__parent_ = &b; - a.__left_ = 0; - a.__right_ = 0; - a.__is_black_ = false; - - std::__tree_balance_after_insert(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__left_ == &c); - - assert(c.__parent_ == &root); - assert(c.__left_ == &b); - assert(c.__right_ == &d); - assert(c.__is_black_ == true); - - assert(b.__parent_ == &c); - assert(b.__left_ == &a); - assert(b.__right_ == 0); - assert(b.__is_black_ == true); - - assert(d.__parent_ == &c); - assert(d.__left_ == 0); - assert(d.__right_ == 0); - assert(d.__is_black_ == true); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - } - { - Node root; - Node a; - Node b; - Node c; - Node d; - - root.__left_ = &c; - - c.__parent_ = &root; - c.__left_ = &b; - c.__right_ = &d; - c.__is_black_ = true; - - b.__parent_ = &c; - b.__left_ = 0; - b.__right_ = &a; - b.__is_black_ = false; - - d.__parent_ = &c; - d.__left_ = 0; - d.__right_ = 0; - d.__is_black_ = false; - - a.__parent_ = &b; - a.__left_ = 0; - a.__right_ = 0; - a.__is_black_ = false; - - std::__tree_balance_after_insert(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__left_ == &c); - - assert(c.__parent_ == &root); - assert(c.__left_ == &b); - assert(c.__right_ == &d); - assert(c.__is_black_ == true); - - assert(b.__parent_ == &c); - assert(b.__left_ == 0); - assert(b.__right_ == &a); - assert(b.__is_black_ == true); - - assert(d.__parent_ == &c); - assert(d.__left_ == 0); - assert(d.__right_ == 0); - assert(d.__is_black_ == true); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - } - { - Node root; - Node a; - Node b; - Node c; - Node d; - - root.__left_ = &c; - - c.__parent_ = &root; - c.__left_ = &b; - c.__right_ = &d; - c.__is_black_ = true; - - b.__parent_ = &c; - b.__left_ = 0; - b.__right_ = 0; - b.__is_black_ = false; - - d.__parent_ = &c; - d.__left_ = &a; - d.__right_ = 0; - d.__is_black_ = false; - - a.__parent_ = &d; - a.__left_ = 0; - a.__right_ = 0; - a.__is_black_ = false; - - std::__tree_balance_after_insert(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__left_ == &c); - - assert(c.__parent_ == &root); - assert(c.__left_ == &b); - assert(c.__right_ == &d); - assert(c.__is_black_ == true); - - assert(b.__parent_ == &c); - assert(b.__left_ == 0); - assert(b.__right_ == 0); - assert(b.__is_black_ == true); - - assert(d.__parent_ == &c); - assert(d.__left_ == &a); - assert(d.__right_ == 0); - assert(d.__is_black_ == true); - - assert(a.__parent_ == &d); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - } - { - Node root; - Node a; - Node b; - Node c; - Node d; - - root.__left_ = &c; - - c.__parent_ = &root; - c.__left_ = &b; - c.__right_ = &d; - c.__is_black_ = true; - - b.__parent_ = &c; - b.__left_ = 0; - b.__right_ = 0; - b.__is_black_ = false; - - d.__parent_ = &c; - d.__left_ = 0; - d.__right_ = &a; - d.__is_black_ = false; - - a.__parent_ = &d; - a.__left_ = 0; - a.__right_ = 0; - a.__is_black_ = false; - - std::__tree_balance_after_insert(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__left_ == &c); - - assert(c.__parent_ == &root); - assert(c.__left_ == &b); - assert(c.__right_ == &d); - assert(c.__is_black_ == true); - - assert(b.__parent_ == &c); - assert(b.__left_ == 0); - assert(b.__right_ == 0); - assert(b.__is_black_ == true); - - assert(d.__parent_ == &c); - assert(d.__left_ == 0); - assert(d.__right_ == &a); - assert(d.__is_black_ == true); - - assert(a.__parent_ == &d); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - } - { - Node root; - Node a; - Node b; - Node c; - Node d; - Node e; - Node f; - Node g; - Node h; - Node i; - - root.__left_ = &c; - - c.__parent_ = &root; - c.__left_ = &b; - c.__right_ = &d; - c.__is_black_ = true; - - b.__parent_ = &c; - b.__left_ = &a; - b.__right_ = &g; - b.__is_black_ = false; - - d.__parent_ = &c; - d.__left_ = &h; - d.__right_ = &i; - d.__is_black_ = false; - - a.__parent_ = &b; - a.__left_ = &e; - a.__right_ = &f; - a.__is_black_ = false; - - e.__parent_ = &a; - e.__is_black_ = true; - - f.__parent_ = &a; - f.__is_black_ = true; - - g.__parent_ = &b; - g.__is_black_ = true; - - h.__parent_ = &d; - h.__is_black_ = true; - - i.__parent_ = &d; - i.__is_black_ = true; - - std::__tree_balance_after_insert(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__left_ == &c); - - assert(c.__parent_ == &root); - assert(c.__left_ == &b); - assert(c.__right_ == &d); - assert(c.__is_black_ == true); - - assert(b.__parent_ == &c); - assert(b.__left_ == &a); - assert(b.__right_ == &g); - assert(b.__is_black_ == true); - - assert(d.__parent_ == &c); - assert(d.__left_ == &h); - assert(d.__right_ == &i); - assert(d.__is_black_ == true); - - assert(a.__parent_ == &b); - assert(a.__left_ == &e); - assert(a.__right_ == &f); - assert(a.__is_black_ == false); - } - { - Node root; - Node a; - Node b; - Node c; - Node d; - Node e; - Node f; - Node g; - Node h; - Node i; - - root.__left_ = &c; - - c.__parent_ = &root; - c.__left_ = &b; - c.__right_ = &d; - c.__is_black_ = true; - - b.__parent_ = &c; - b.__left_ = &g; - b.__right_ = &a; - b.__is_black_ = false; - - d.__parent_ = &c; - d.__left_ = &h; - d.__right_ = &i; - d.__is_black_ = false; - - a.__parent_ = &b; - a.__left_ = &e; - a.__right_ = &f; - a.__is_black_ = false; - - e.__parent_ = &a; - e.__is_black_ = true; - - f.__parent_ = &a; - f.__is_black_ = true; - - g.__parent_ = &b; - g.__is_black_ = true; - - h.__parent_ = &d; - h.__is_black_ = true; - - i.__parent_ = &d; - i.__is_black_ = true; - - std::__tree_balance_after_insert(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__left_ == &c); - - assert(c.__parent_ == &root); - assert(c.__left_ == &b); - assert(c.__right_ == &d); - assert(c.__is_black_ == true); - - assert(b.__parent_ == &c); - assert(b.__left_ == &g); - assert(b.__right_ == &a); - assert(b.__is_black_ == true); - - assert(d.__parent_ == &c); - assert(d.__left_ == &h); - assert(d.__right_ == &i); - assert(d.__is_black_ == true); - - assert(a.__parent_ == &b); - assert(a.__left_ == &e); - assert(a.__right_ == &f); - assert(a.__is_black_ == false); - } - { - Node root; - Node a; - Node b; - Node c; - Node d; - Node e; - Node f; - Node g; - Node h; - Node i; - - root.__left_ = &c; - - c.__parent_ = &root; - c.__left_ = &b; - c.__right_ = &d; - c.__is_black_ = true; - - b.__parent_ = &c; - b.__left_ = &g; - b.__right_ = &h; - b.__is_black_ = false; - - d.__parent_ = &c; - d.__left_ = &a; - d.__right_ = &i; - d.__is_black_ = false; - - a.__parent_ = &d; - a.__left_ = &e; - a.__right_ = &f; - a.__is_black_ = false; - - e.__parent_ = &a; - e.__is_black_ = true; - - f.__parent_ = &a; - f.__is_black_ = true; - - g.__parent_ = &b; - g.__is_black_ = true; - - h.__parent_ = &b; - h.__is_black_ = true; - - i.__parent_ = &d; - i.__is_black_ = true; - - std::__tree_balance_after_insert(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__left_ == &c); - - assert(c.__parent_ == &root); - assert(c.__left_ == &b); - assert(c.__right_ == &d); - assert(c.__is_black_ == true); - - assert(b.__parent_ == &c); - assert(b.__left_ == &g); - assert(b.__right_ == &h); - assert(b.__is_black_ == true); - - assert(d.__parent_ == &c); - assert(d.__left_ == &a); - assert(d.__right_ == &i); - assert(d.__is_black_ == true); - - assert(a.__parent_ == &d); - assert(a.__left_ == &e); - assert(a.__right_ == &f); - assert(a.__is_black_ == false); - } - { - Node root; - Node a; - Node b; - Node c; - Node d; - Node e; - Node f; - Node g; - Node h; - Node i; - - root.__left_ = &c; - - c.__parent_ = &root; - c.__left_ = &b; - c.__right_ = &d; - c.__is_black_ = true; - - b.__parent_ = &c; - b.__left_ = &g; - b.__right_ = &h; - b.__is_black_ = false; - - d.__parent_ = &c; - d.__left_ = &i; - d.__right_ = &a; - d.__is_black_ = false; - - a.__parent_ = &d; - a.__left_ = &e; - a.__right_ = &f; - a.__is_black_ = false; - - e.__parent_ = &a; - e.__is_black_ = true; - - f.__parent_ = &a; - f.__is_black_ = true; - - g.__parent_ = &b; - g.__is_black_ = true; - - h.__parent_ = &b; - h.__is_black_ = true; - - i.__parent_ = &d; - i.__is_black_ = true; - - std::__tree_balance_after_insert(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__left_ == &c); - - assert(c.__parent_ == &root); - assert(c.__left_ == &b); - assert(c.__right_ == &d); - assert(c.__is_black_ == true); - - assert(b.__parent_ == &c); - assert(b.__left_ == &g); - assert(b.__right_ == &h); - assert(b.__is_black_ == true); - - assert(d.__parent_ == &c); - assert(d.__left_ == &i); - assert(d.__right_ == &a); - assert(d.__is_black_ == true); - - assert(a.__parent_ == &d); - assert(a.__left_ == &e); - assert(a.__right_ == &f); - assert(a.__is_black_ == false); - } -} - -void -test2() -{ - { - Node root; - Node a; - Node b; - Node c; - - root.__left_ = &c; - - c.__parent_ = &root; - c.__left_ = &a; - c.__right_ = 0; - c.__is_black_ = true; - - a.__parent_ = &c; - a.__left_ = 0; - a.__right_ = &b; - a.__is_black_ = false; - - b.__parent_ = &a; - b.__left_ = 0; - b.__right_ = 0; - b.__is_black_ = false; - - std::__tree_balance_after_insert(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__left_ == &b); - - assert(c.__parent_ == &b); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == false); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == &a); - assert(b.__right_ == &c); - assert(b.__is_black_ == true); - } - { - Node root; - Node a; - Node b; - Node c; - - root.__left_ = &a; - - a.__parent_ = &root; - a.__left_ = 0; - a.__right_ = &c; - a.__is_black_ = true; - - c.__parent_ = &a; - c.__left_ = &b; - c.__right_ = 0; - c.__is_black_ = false; - - b.__parent_ = &c; - b.__left_ = 0; - b.__right_ = 0; - b.__is_black_ = false; - - std::__tree_balance_after_insert(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__left_ == &b); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - - assert(c.__parent_ == &b); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == &a); - assert(b.__right_ == &c); - assert(b.__is_black_ == true); - } - { - Node root; - Node a; - Node b; - Node c; - Node d; - Node e; - Node f; - Node g; - - root.__left_ = &c; - - c.__parent_ = &root; - c.__left_ = &a; - c.__right_ = &g; - c.__is_black_ = true; - - a.__parent_ = &c; - a.__left_ = &d; - a.__right_ = &b; - a.__is_black_ = false; - - b.__parent_ = &a; - b.__left_ = &e; - b.__right_ = &f; - b.__is_black_ = false; - - d.__parent_ = &a; - d.__is_black_ = true; - - e.__parent_ = &b; - e.__is_black_ = true; - - f.__parent_ = &b; - f.__is_black_ = true; - - g.__parent_ = &c; - g.__is_black_ = true; - - std::__tree_balance_after_insert(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__left_ == &b); - - assert(c.__parent_ == &b); - assert(c.__left_ == &f); - assert(c.__right_ == &g); - assert(c.__is_black_ == false); - - assert(a.__parent_ == &b); - assert(a.__left_ == &d); - assert(a.__right_ == &e); - assert(a.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == &a); - assert(b.__right_ == &c); - assert(b.__is_black_ == true); - - assert(d.__parent_ == &a); - assert(d.__is_black_ == true); - - assert(e.__parent_ == &a); - assert(e.__is_black_ == true); - - assert(f.__parent_ == &c); - assert(f.__is_black_ == true); - - assert(g.__parent_ == &c); - assert(g.__is_black_ == true); - } - { - Node root; - Node a; - Node b; - Node c; - Node d; - Node e; - Node f; - Node g; - - root.__left_ = &a; - - a.__parent_ = &root; - a.__left_ = &d; - a.__right_ = &c; - a.__is_black_ = true; - - c.__parent_ = &a; - c.__left_ = &b; - c.__right_ = &g; - c.__is_black_ = false; - - b.__parent_ = &c; - b.__left_ = &e; - b.__right_ = &f; - b.__is_black_ = false; - - d.__parent_ = &a; - d.__is_black_ = true; - - e.__parent_ = &b; - e.__is_black_ = true; - - f.__parent_ = &b; - f.__is_black_ = true; - - g.__parent_ = &c; - g.__is_black_ = true; - - std::__tree_balance_after_insert(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__left_ == &b); - - assert(c.__parent_ == &b); - assert(c.__left_ == &f); - assert(c.__right_ == &g); - assert(c.__is_black_ == false); - - assert(a.__parent_ == &b); - assert(a.__left_ == &d); - assert(a.__right_ == &e); - assert(a.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == &a); - assert(b.__right_ == &c); - assert(b.__is_black_ == true); - - assert(d.__parent_ == &a); - assert(d.__is_black_ == true); - - assert(e.__parent_ == &a); - assert(e.__is_black_ == true); - - assert(f.__parent_ == &c); - assert(f.__is_black_ == true); - - assert(g.__parent_ == &c); - assert(g.__is_black_ == true); - } -} - -void -test3() -{ - { - Node root; - Node a; - Node b; - Node c; - - root.__left_ = &c; - - c.__parent_ = &root; - c.__left_ = &b; - c.__right_ = 0; - c.__is_black_ = true; - - b.__parent_ = &c; - b.__left_ = &a; - b.__right_ = 0; - b.__is_black_ = false; - - a.__parent_ = &b; - a.__left_ = 0; - a.__right_ = 0; - a.__is_black_ = false; - - std::__tree_balance_after_insert(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__left_ == &b); - - assert(c.__parent_ == &b); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == false); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == &a); - assert(b.__right_ == &c); - assert(b.__is_black_ == true); - } - { - Node root; - Node a; - Node b; - Node c; - - root.__left_ = &a; - - a.__parent_ = &root; - a.__left_ = 0; - a.__right_ = &b; - a.__is_black_ = true; - - b.__parent_ = &a; - b.__left_ = 0; - b.__right_ = &c; - b.__is_black_ = false; - - c.__parent_ = &b; - c.__left_ = 0; - c.__right_ = 0; - c.__is_black_ = false; - - std::__tree_balance_after_insert(root.__left_, &c); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__left_ == &b); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - - assert(c.__parent_ == &b); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == &a); - assert(b.__right_ == &c); - assert(b.__is_black_ == true); - } - { - Node root; - Node a; - Node b; - Node c; - Node d; - Node e; - Node f; - Node g; - - root.__left_ = &c; - - c.__parent_ = &root; - c.__left_ = &b; - c.__right_ = &g; - c.__is_black_ = true; - - b.__parent_ = &c; - b.__left_ = &a; - b.__right_ = &f; - b.__is_black_ = false; - - a.__parent_ = &b; - a.__left_ = &d; - a.__right_ = &e; - a.__is_black_ = false; - - d.__parent_ = &a; - d.__is_black_ = true; - - e.__parent_ = &a; - e.__is_black_ = true; - - f.__parent_ = &b; - f.__is_black_ = true; - - g.__parent_ = &c; - g.__is_black_ = true; - - std::__tree_balance_after_insert(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__left_ == &b); - - assert(c.__parent_ == &b); - assert(c.__left_ == &f); - assert(c.__right_ == &g); - assert(c.__is_black_ == false); - - assert(a.__parent_ == &b); - assert(a.__left_ == &d); - assert(a.__right_ == &e); - assert(a.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == &a); - assert(b.__right_ == &c); - assert(b.__is_black_ == true); - - assert(d.__parent_ == &a); - assert(d.__is_black_ == true); - - assert(e.__parent_ == &a); - assert(e.__is_black_ == true); - - assert(f.__parent_ == &c); - assert(f.__is_black_ == true); - - assert(g.__parent_ == &c); - assert(g.__is_black_ == true); - } - { - Node root; - Node a; - Node b; - Node c; - Node d; - Node e; - Node f; - Node g; - - root.__left_ = &a; - - a.__parent_ = &root; - a.__left_ = &d; - a.__right_ = &b; - a.__is_black_ = true; - - b.__parent_ = &a; - b.__left_ = &e; - b.__right_ = &c; - b.__is_black_ = false; - - c.__parent_ = &b; - c.__left_ = &f; - c.__right_ = &g; - c.__is_black_ = false; - - d.__parent_ = &a; - d.__is_black_ = true; - - e.__parent_ = &b; - e.__is_black_ = true; - - f.__parent_ = &c; - f.__is_black_ = true; - - g.__parent_ = &c; - g.__is_black_ = true; - - std::__tree_balance_after_insert(root.__left_, &c); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__left_ == &b); - - assert(c.__parent_ == &b); - assert(c.__left_ == &f); - assert(c.__right_ == &g); - assert(c.__is_black_ == false); - - assert(a.__parent_ == &b); - assert(a.__left_ == &d); - assert(a.__right_ == &e); - assert(a.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == &a); - assert(b.__right_ == &c); - assert(b.__is_black_ == true); - - assert(d.__parent_ == &a); - assert(d.__is_black_ == true); - - assert(e.__parent_ == &a); - assert(e.__is_black_ == true); - - assert(f.__parent_ == &c); - assert(f.__is_black_ == true); - - assert(g.__parent_ == &c); - assert(g.__is_black_ == true); - } -} - -void -test4() -{ - Node root; - Node a; - Node b; - Node c; - Node d; - Node e; - Node f; - Node g; - Node h; - - root.__left_ = &a; - a.__parent_ = &root; - - std::__tree_balance_after_insert(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &a); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(a.__parent_ == &root); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == true); - - a.__right_ = &b; - b.__parent_ = &a; - - std::__tree_balance_after_insert(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &a); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(a.__parent_ == &root); - assert(a.__left_ == 0); - assert(a.__right_ == &b); - assert(a.__is_black_ == true); - - assert(b.__parent_ == &a); - assert(b.__left_ == 0); - assert(b.__right_ == 0); - assert(b.__is_black_ == false); - - b.__right_ = &c; - c.__parent_ = &b; - - std::__tree_balance_after_insert(root.__left_, &c); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &b); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == &a); - assert(b.__right_ == &c); - assert(b.__is_black_ == true); - - assert(c.__parent_ == &b); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == false); - - c.__right_ = &d; - d.__parent_ = &c; - - std::__tree_balance_after_insert(root.__left_, &d); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &b); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == true); - - assert(b.__parent_ == &root); - assert(b.__left_ == &a); - assert(b.__right_ == &c); - assert(b.__is_black_ == true); - - assert(c.__parent_ == &b); - assert(c.__left_ == 0); - assert(c.__right_ == &d); - assert(c.__is_black_ == true); - - assert(d.__parent_ == &c); - assert(d.__left_ == 0); - assert(d.__right_ == 0); - assert(d.__is_black_ == false); - - d.__right_ = &e; - e.__parent_ = &d; - - std::__tree_balance_after_insert(root.__left_, &e); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &b); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == &a); - assert(b.__right_ == &d); - assert(b.__is_black_ == true); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == true); - - assert(d.__parent_ == &b); - assert(d.__left_ == &c); - assert(d.__right_ == &e); - assert(d.__is_black_ == true); - - assert(c.__parent_ == &d); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == false); - - assert(e.__parent_ == &d); - assert(e.__left_ == 0); - assert(e.__right_ == 0); - assert(e.__is_black_ == false); - - e.__right_ = &f; - f.__parent_ = &e; - - std::__tree_balance_after_insert(root.__left_, &f); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &b); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == &a); - assert(b.__right_ == &d); - assert(b.__is_black_ == true); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == true); - - assert(d.__parent_ == &b); - assert(d.__left_ == &c); - assert(d.__right_ == &e); - assert(d.__is_black_ == false); - - assert(c.__parent_ == &d); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == true); - - assert(e.__parent_ == &d); - assert(e.__left_ == 0); - assert(e.__right_ == &f); - assert(e.__is_black_ == true); - - assert(f.__parent_ == &e); - assert(f.__left_ == 0); - assert(f.__right_ == 0); - assert(f.__is_black_ == false); - - f.__right_ = &g; - g.__parent_ = &f; - - std::__tree_balance_after_insert(root.__left_, &g); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &b); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == &a); - assert(b.__right_ == &d); - assert(b.__is_black_ == true); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == true); - - assert(d.__parent_ == &b); - assert(d.__left_ == &c); - assert(d.__right_ == &f); - assert(d.__is_black_ == false); - - assert(c.__parent_ == &d); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == true); - - assert(f.__parent_ == &d); - assert(f.__left_ == &e); - assert(f.__right_ == &g); - assert(f.__is_black_ == true); - - assert(e.__parent_ == &f); - assert(e.__left_ == 0); - assert(e.__right_ == 0); - assert(e.__is_black_ == false); - - assert(g.__parent_ == &f); - assert(g.__left_ == 0); - assert(g.__right_ == 0); - assert(g.__is_black_ == false); - - g.__right_ = &h; - h.__parent_ = &g; - - std::__tree_balance_after_insert(root.__left_, &h); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &d); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(d.__parent_ == &root); - assert(d.__left_ == &b); - assert(d.__right_ == &f); - assert(d.__is_black_ == true); - - assert(b.__parent_ == &d); - assert(b.__left_ == &a); - assert(b.__right_ == &c); - assert(b.__is_black_ == false); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == true); - - assert(c.__parent_ == &b); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == true); - - assert(f.__parent_ == &d); - assert(f.__left_ == &e); - assert(f.__right_ == &g); - assert(f.__is_black_ == false); - - assert(e.__parent_ == &f); - assert(e.__left_ == 0); - assert(e.__right_ == 0); - assert(e.__is_black_ == true); - - assert(g.__parent_ == &f); - assert(g.__left_ == 0); - assert(g.__right_ == &h); - assert(g.__is_black_ == true); - - assert(h.__parent_ == &g); - assert(h.__left_ == 0); - assert(h.__right_ == 0); - assert(h.__is_black_ == false); -} - -void -test5() -{ - Node root; - Node a; - Node b; - Node c; - Node d; - Node e; - Node f; - Node g; - Node h; - - root.__left_ = &h; - h.__parent_ = &root; - - std::__tree_balance_after_insert(root.__left_, &h); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &h); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(h.__parent_ == &root); - assert(h.__left_ == 0); - assert(h.__right_ == 0); - assert(h.__is_black_ == true); - - h.__left_ = &g; - g.__parent_ = &h; - - std::__tree_balance_after_insert(root.__left_, &g); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &h); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(h.__parent_ == &root); - assert(h.__left_ == &g); - assert(h.__right_ == 0); - assert(h.__is_black_ == true); - - assert(g.__parent_ == &h); - assert(g.__left_ == 0); - assert(g.__right_ == 0); - assert(g.__is_black_ == false); - - g.__left_ = &f; - f.__parent_ = &g; - - std::__tree_balance_after_insert(root.__left_, &f); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &g); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(g.__parent_ == &root); - assert(g.__left_ == &f); - assert(g.__right_ == &h); - assert(g.__is_black_ == true); - - assert(f.__parent_ == &g); - assert(f.__left_ == 0); - assert(f.__right_ == 0); - assert(f.__is_black_ == false); - - assert(h.__parent_ == &g); - assert(h.__left_ == 0); - assert(h.__right_ == 0); - assert(h.__is_black_ == false); - - f.__left_ = &e; - e.__parent_ = &f; - - std::__tree_balance_after_insert(root.__left_, &e); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &g); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(g.__parent_ == &root); - assert(g.__left_ == &f); - assert(g.__right_ == &h); - assert(g.__is_black_ == true); - - assert(f.__parent_ == &g); - assert(f.__left_ == &e); - assert(f.__right_ == 0); - assert(f.__is_black_ == true); - - assert(e.__parent_ == &f); - assert(e.__left_ == 0); - assert(e.__right_ == 0); - assert(e.__is_black_ == false); - - assert(h.__parent_ == &g); - assert(h.__left_ == 0); - assert(h.__right_ == 0); - assert(h.__is_black_ == true); - - e.__left_ = &d; - d.__parent_ = &e; - - std::__tree_balance_after_insert(root.__left_, &d); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &g); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(g.__parent_ == &root); - assert(g.__left_ == &e); - assert(g.__right_ == &h); - assert(g.__is_black_ == true); - - assert(e.__parent_ == &g); - assert(e.__left_ == &d); - assert(e.__right_ == &f); - assert(e.__is_black_ == true); - - assert(d.__parent_ == &e); - assert(d.__left_ == 0); - assert(d.__right_ == 0); - assert(d.__is_black_ == false); - - assert(f.__parent_ == &e); - assert(f.__left_ == 0); - assert(f.__right_ == 0); - assert(f.__is_black_ == false); - - assert(h.__parent_ == &g); - assert(h.__left_ == 0); - assert(h.__right_ == 0); - assert(h.__is_black_ == true); - - d.__left_ = &c; - c.__parent_ = &d; - - std::__tree_balance_after_insert(root.__left_, &c); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &g); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(g.__parent_ == &root); - assert(g.__left_ == &e); - assert(g.__right_ == &h); - assert(g.__is_black_ == true); - - assert(e.__parent_ == &g); - assert(e.__left_ == &d); - assert(e.__right_ == &f); - assert(e.__is_black_ == false); - - assert(d.__parent_ == &e); - assert(d.__left_ == &c); - assert(d.__right_ == 0); - assert(d.__is_black_ == true); - - assert(c.__parent_ == &d); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == false); - - assert(f.__parent_ == &e); - assert(f.__left_ == 0); - assert(f.__right_ == 0); - assert(f.__is_black_ == true); - - assert(h.__parent_ == &g); - assert(h.__left_ == 0); - assert(h.__right_ == 0); - assert(h.__is_black_ == true); - - c.__left_ = &b; - b.__parent_ = &c; - - std::__tree_balance_after_insert(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &g); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(g.__parent_ == &root); - assert(g.__left_ == &e); - assert(g.__right_ == &h); - assert(g.__is_black_ == true); - - assert(e.__parent_ == &g); - assert(e.__left_ == &c); - assert(e.__right_ == &f); - assert(e.__is_black_ == false); - - assert(c.__parent_ == &e); - assert(c.__left_ == &b); - assert(c.__right_ == &d); - assert(c.__is_black_ == true); - - assert(b.__parent_ == &c); - assert(b.__left_ == 0); - assert(b.__right_ == 0); - assert(b.__is_black_ == false); - - assert(d.__parent_ == &c); - assert(d.__left_ == 0); - assert(d.__right_ == 0); - assert(d.__is_black_ == false); - - assert(f.__parent_ == &e); - assert(f.__left_ == 0); - assert(f.__right_ == 0); - assert(f.__is_black_ == true); - - assert(h.__parent_ == &g); - assert(h.__left_ == 0); - assert(h.__right_ == 0); - assert(h.__is_black_ == true); - - b.__left_ = &a; - a.__parent_ = &b; - - std::__tree_balance_after_insert(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &e); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(e.__parent_ == &root); - assert(e.__left_ == &c); - assert(e.__right_ == &g); - assert(e.__is_black_ == true); - - assert(c.__parent_ == &e); - assert(c.__left_ == &b); - assert(c.__right_ == &d); - assert(c.__is_black_ == false); - - assert(b.__parent_ == &c); - assert(b.__left_ == &a); - assert(b.__right_ == 0); - assert(b.__is_black_ == true); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - - assert(d.__parent_ == &c); - assert(d.__left_ == 0); - assert(d.__right_ == 0); - assert(d.__is_black_ == true); - - assert(g.__parent_ == &e); - assert(g.__left_ == &f); - assert(g.__right_ == &h); - assert(g.__is_black_ == false); - - assert(f.__parent_ == &g); - assert(f.__left_ == 0); - assert(f.__right_ == 0); - assert(f.__is_black_ == true); - - assert(h.__parent_ == &g); - assert(h.__left_ == 0); - assert(h.__right_ == 0); - assert(h.__is_black_ == true); -} - -int main() -{ - test1(); - test2(); - test3(); - test4(); - test5(); -} diff --git a/test/std/containers/associative/tree_left_rotate.pass.cpp b/test/std/containers/associative/tree_left_rotate.pass.cpp deleted file mode 100644 index 774cbc687985..000000000000 --- a/test/std/containers/associative/tree_left_rotate.pass.cpp +++ /dev/null @@ -1,98 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// Not a portable test - -// Precondition: __x->__right_ != nullptr -// template <class _NodePtr> -// void -// __tree_left_rotate(_NodePtr __x); - -#include <__tree> -#include <cassert> - -struct Node -{ - Node* __left_; - Node* __right_; - Node* __parent_; - - Node() : __left_(), __right_(), __parent_() {} -}; - -void -test1() -{ - Node root; - Node x; - Node y; - root.__left_ = &x; - x.__left_ = 0; - x.__right_ = &y; - x.__parent_ = &root; - y.__left_ = 0; - y.__right_ = 0; - y.__parent_ = &x; - std::__tree_left_rotate(&x); - assert(root.__parent_ == 0); - assert(root.__left_ == &y); - assert(root.__right_ == 0); - assert(y.__parent_ == &root); - assert(y.__left_ == &x); - assert(y.__right_ == 0); - assert(x.__parent_ == &y); - assert(x.__left_ == 0); - assert(x.__right_ == 0); -} - -void -test2() -{ - Node root; - Node x; - Node y; - Node a; - Node b; - Node c; - root.__left_ = &x; - x.__left_ = &a; - x.__right_ = &y; - x.__parent_ = &root; - y.__left_ = &b; - y.__right_ = &c; - y.__parent_ = &x; - a.__parent_ = &x; - b.__parent_ = &y; - c.__parent_ = &y; - std::__tree_left_rotate(&x); - assert(root.__parent_ == 0); - assert(root.__left_ == &y); - assert(root.__right_ == 0); - assert(y.__parent_ == &root); - assert(y.__left_ == &x); - assert(y.__right_ == &c); - assert(x.__parent_ == &y); - assert(x.__left_ == &a); - assert(x.__right_ == &b); - assert(a.__parent_ == &x); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(b.__parent_ == &x); - assert(b.__left_ == 0); - assert(b.__right_ == 0); - assert(c.__parent_ == &y); - assert(c.__left_ == 0); - assert(c.__right_ == 0); -} - -int main() -{ - test1(); - test2(); -} diff --git a/test/std/containers/associative/tree_remove.pass.cpp b/test/std/containers/associative/tree_remove.pass.cpp deleted file mode 100644 index fb14bd929e91..000000000000 --- a/test/std/containers/associative/tree_remove.pass.cpp +++ /dev/null @@ -1,1648 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// Not a portable test - -// Returns __tree_next(__z) -// template <class _NodePtr> -// void -// __tree_remove(_NodePtr __root, _NodePtr __z) - -#include <__tree> -#include <cassert> - -struct Node -{ - Node* __left_; - Node* __right_; - Node* __parent_; - bool __is_black_; - - Node() : __left_(), __right_(), __parent_(), __is_black_() {} -}; - -void -test1() -{ - { - // Left - // Case 1 -> Case 2 -> x is red turned to black - Node root; - Node b; - Node c; - Node d; - Node e; - Node y; - - root.__left_ = &b; - - b.__parent_ = &root; - b.__left_ = &y; - b.__right_ = &d; - b.__is_black_ = true; - - y.__parent_ = &b; - y.__left_ = 0; - y.__right_ = 0; - y.__is_black_ = true; - - d.__parent_ = &b; - d.__left_ = &c; - d.__right_ = &e; - d.__is_black_ = false; - - c.__parent_ = &d; - c.__left_ = 0; - c.__right_ = 0; - c.__is_black_ = true; - - e.__parent_ = &d; - e.__left_ = 0; - e.__right_ = 0; - e.__is_black_ = true; - - std::__tree_remove(root.__left_, &y); - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &d); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(d.__parent_ == &root); - assert(d.__left_ == &b); - assert(d.__right_ == &e); - assert(d.__is_black_ == true); - - assert(b.__parent_ == &d); - assert(b.__left_ == 0); - assert(b.__right_ == &c); - assert(b.__is_black_ == true); - - assert(c.__parent_ == &b); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == false); - - assert(e.__parent_ == &d); - assert(e.__left_ == 0); - assert(e.__right_ == 0); - assert(e.__is_black_ == true); - } - { - // Right - // Case 1 -> Case 2 -> x is red turned to black - Node root; - Node b; - Node c; - Node d; - Node e; - Node y; - - root.__left_ = &b; - - b.__parent_ = &root; - b.__right_ = &y; - b.__left_ = &d; - b.__is_black_ = true; - - y.__parent_ = &b; - y.__right_ = 0; - y.__left_ = 0; - y.__is_black_ = true; - - d.__parent_ = &b; - d.__right_ = &c; - d.__left_ = &e; - d.__is_black_ = false; - - c.__parent_ = &d; - c.__right_ = 0; - c.__left_ = 0; - c.__is_black_ = true; - - e.__parent_ = &d; - e.__right_ = 0; - e.__left_ = 0; - e.__is_black_ = true; - - std::__tree_remove(root.__left_, &y); - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &d); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(d.__parent_ == &root); - assert(d.__right_ == &b); - assert(d.__left_ == &e); - assert(d.__is_black_ == true); - - assert(b.__parent_ == &d); - assert(b.__right_ == 0); - assert(b.__left_ == &c); - assert(b.__is_black_ == true); - - assert(c.__parent_ == &b); - assert(c.__right_ == 0); - assert(c.__left_ == 0); - assert(c.__is_black_ == false); - - assert(e.__parent_ == &d); - assert(e.__right_ == 0); - assert(e.__left_ == 0); - assert(e.__is_black_ == true); - } - { - // Left - // Case 1 -> Case 3 -> Case 4 - Node root; - Node b; - Node c; - Node d; - Node e; - Node f; - Node y; - - root.__left_ = &b; - - b.__parent_ = &root; - b.__left_ = &y; - b.__right_ = &d; - b.__is_black_ = true; - - y.__parent_ = &b; - y.__left_ = 0; - y.__right_ = 0; - y.__is_black_ = true; - - d.__parent_ = &b; - d.__left_ = &c; - d.__right_ = &e; - d.__is_black_ = false; - - c.__parent_ = &d; - c.__left_ = &f; - c.__right_ = 0; - c.__is_black_ = true; - - e.__parent_ = &d; - e.__left_ = 0; - e.__right_ = 0; - e.__is_black_ = true; - - f.__parent_ = &c; - f.__left_ = 0; - f.__right_ = 0; - f.__is_black_ = false; - - std::__tree_remove(root.__left_, &y); - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &d); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(d.__parent_ == &root); - assert(d.__left_ == &f); - assert(d.__right_ == &e); - assert(d.__is_black_ == true); - - assert(f.__parent_ == &d); - assert(f.__left_ == &b); - assert(f.__right_ == &c); - assert(f.__is_black_ == false); - - assert(b.__parent_ == &f); - assert(b.__left_ == 0); - assert(b.__right_ == 0); - assert(b.__is_black_ == true); - - assert(c.__parent_ == &f); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == true); - - assert(e.__parent_ == &d); - assert(e.__left_ == 0); - assert(e.__right_ == 0); - assert(e.__is_black_ == true); - } - { - // Right - // Case 1 -> Case 3 -> Case 4 - Node root; - Node b; - Node c; - Node d; - Node e; - Node f; - Node y; - - root.__left_ = &b; - - b.__parent_ = &root; - b.__right_ = &y; - b.__left_ = &d; - b.__is_black_ = true; - - y.__parent_ = &b; - y.__right_ = 0; - y.__left_ = 0; - y.__is_black_ = true; - - d.__parent_ = &b; - d.__right_ = &c; - d.__left_ = &e; - d.__is_black_ = false; - - c.__parent_ = &d; - c.__right_ = &f; - c.__left_ = 0; - c.__is_black_ = true; - - e.__parent_ = &d; - e.__right_ = 0; - e.__left_ = 0; - e.__is_black_ = true; - - f.__parent_ = &c; - f.__right_ = 0; - f.__left_ = 0; - f.__is_black_ = false; - - std::__tree_remove(root.__left_, &y); - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &d); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(d.__parent_ == &root); - assert(d.__right_ == &f); - assert(d.__left_ == &e); - assert(d.__is_black_ == true); - - assert(f.__parent_ == &d); - assert(f.__right_ == &b); - assert(f.__left_ == &c); - assert(f.__is_black_ == false); - - assert(b.__parent_ == &f); - assert(b.__right_ == 0); - assert(b.__left_ == 0); - assert(b.__is_black_ == true); - - assert(c.__parent_ == &f); - assert(c.__right_ == 0); - assert(c.__left_ == 0); - assert(c.__is_black_ == true); - - assert(e.__parent_ == &d); - assert(e.__right_ == 0); - assert(e.__left_ == 0); - assert(e.__is_black_ == true); - } -} - -void -test2() -{ - { - Node root; - Node a; - Node b; - Node c; - - root.__left_ = &b; - - b.__parent_ = &root; - b.__left_ = &a; - b.__right_ = &c; - b.__is_black_ = true; - - a.__parent_ = &b; - a.__left_ = 0; - a.__right_ = 0; - a.__is_black_ = true; - - c.__parent_ = &b; - c.__left_ = 0; - c.__right_ = 0; - c.__is_black_ = true; - - std::__tree_remove(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &b); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == 0); - assert(b.__right_ == &c); - assert(b.__is_black_ == true); - - assert(c.__parent_ == &b); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == false); - - std::__tree_remove(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &c); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(c.__parent_ == &root); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == true); - - std::__tree_remove(root.__left_, &c); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == 0); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - } - { - Node root; - Node a; - Node b; - Node c; - - root.__left_ = &b; - - b.__parent_ = &root; - b.__left_ = &a; - b.__right_ = &c; - b.__is_black_ = true; - - a.__parent_ = &b; - a.__left_ = 0; - a.__right_ = 0; - a.__is_black_ = false; - - c.__parent_ = &b; - c.__left_ = 0; - c.__right_ = 0; - c.__is_black_ = false; - - std::__tree_remove(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &b); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == 0); - assert(b.__right_ == &c); - assert(b.__is_black_ == true); - - assert(c.__parent_ == &b); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == false); - - std::__tree_remove(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &c); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(c.__parent_ == &root); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == true); - - std::__tree_remove(root.__left_, &c); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == 0); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - } - { - Node root; - Node a; - Node b; - Node c; - - root.__left_ = &b; - - b.__parent_ = &root; - b.__left_ = &a; - b.__right_ = &c; - b.__is_black_ = true; - - a.__parent_ = &b; - a.__left_ = 0; - a.__right_ = 0; - a.__is_black_ = true; - - c.__parent_ = &b; - c.__left_ = 0; - c.__right_ = 0; - c.__is_black_ = true; - - std::__tree_remove(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &b); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == 0); - assert(b.__right_ == &c); - assert(b.__is_black_ == true); - - assert(c.__parent_ == &b); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == false); - - std::__tree_remove(root.__left_, &c); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &b); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == 0); - assert(b.__right_ == 0); - assert(b.__is_black_ == true); - - std::__tree_remove(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == 0); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - } - { - Node root; - Node a; - Node b; - Node c; - - root.__left_ = &b; - - b.__parent_ = &root; - b.__left_ = &a; - b.__right_ = &c; - b.__is_black_ = true; - - a.__parent_ = &b; - a.__left_ = 0; - a.__right_ = 0; - a.__is_black_ = false; - - c.__parent_ = &b; - c.__left_ = 0; - c.__right_ = 0; - c.__is_black_ = false; - - std::__tree_remove(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &b); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == 0); - assert(b.__right_ == &c); - assert(b.__is_black_ == true); - - assert(c.__parent_ == &b); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == false); - - std::__tree_remove(root.__left_, &c); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &b); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == 0); - assert(b.__right_ == 0); - assert(b.__is_black_ == true); - - std::__tree_remove(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == 0); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - } - { - Node root; - Node a; - Node b; - Node c; - - root.__left_ = &b; - - b.__parent_ = &root; - b.__left_ = &a; - b.__right_ = &c; - b.__is_black_ = true; - - a.__parent_ = &b; - a.__left_ = 0; - a.__right_ = 0; - a.__is_black_ = true; - - c.__parent_ = &b; - c.__left_ = 0; - c.__right_ = 0; - c.__is_black_ = true; - - std::__tree_remove(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &c); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(a.__parent_ == &c); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - - assert(c.__parent_ == &root); - assert(c.__left_ == &a); - assert(c.__right_ == 0); - assert(c.__is_black_ == true); - - std::__tree_remove(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &c); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(c.__parent_ == &root); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == true); - - std::__tree_remove(root.__left_, &c); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == 0); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - } - { - Node root; - Node a; - Node b; - Node c; - - root.__left_ = &b; - - b.__parent_ = &root; - b.__left_ = &a; - b.__right_ = &c; - b.__is_black_ = true; - - a.__parent_ = &b; - a.__left_ = 0; - a.__right_ = 0; - a.__is_black_ = false; - - c.__parent_ = &b; - c.__left_ = 0; - c.__right_ = 0; - c.__is_black_ = false; - - std::__tree_remove(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &c); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(a.__parent_ == &c); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - - assert(c.__parent_ == &root); - assert(c.__left_ == &a); - assert(c.__right_ == 0); - assert(c.__is_black_ == true); - - std::__tree_remove(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &c); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(c.__parent_ == &root); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == true); - - std::__tree_remove(root.__left_, &c); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == 0); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - } - { - Node root; - Node a; - Node b; - Node c; - - root.__left_ = &b; - - b.__parent_ = &root; - b.__left_ = &a; - b.__right_ = &c; - b.__is_black_ = true; - - a.__parent_ = &b; - a.__left_ = 0; - a.__right_ = 0; - a.__is_black_ = true; - - c.__parent_ = &b; - c.__left_ = 0; - c.__right_ = 0; - c.__is_black_ = true; - - std::__tree_remove(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &c); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(a.__parent_ == &c); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - - assert(c.__parent_ == &root); - assert(c.__left_ == &a); - assert(c.__right_ == 0); - assert(c.__is_black_ == true); - - std::__tree_remove(root.__left_, &c); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &a); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(a.__parent_ == &root); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == true); - - std::__tree_remove(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == 0); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - } - { - Node root; - Node a; - Node b; - Node c; - - root.__left_ = &b; - - b.__parent_ = &root; - b.__left_ = &a; - b.__right_ = &c; - b.__is_black_ = true; - - a.__parent_ = &b; - a.__left_ = 0; - a.__right_ = 0; - a.__is_black_ = false; - - c.__parent_ = &b; - c.__left_ = 0; - c.__right_ = 0; - c.__is_black_ = false; - - std::__tree_remove(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &c); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(a.__parent_ == &c); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - - assert(c.__parent_ == &root); - assert(c.__left_ == &a); - assert(c.__right_ == 0); - assert(c.__is_black_ == true); - - std::__tree_remove(root.__left_, &c); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &a); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(a.__parent_ == &root); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == true); - - std::__tree_remove(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == 0); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - } - { - Node root; - Node a; - Node b; - Node c; - - root.__left_ = &b; - - b.__parent_ = &root; - b.__left_ = &a; - b.__right_ = &c; - b.__is_black_ = true; - - a.__parent_ = &b; - a.__left_ = 0; - a.__right_ = 0; - a.__is_black_ = true; - - c.__parent_ = &b; - c.__left_ = 0; - c.__right_ = 0; - c.__is_black_ = true; - - std::__tree_remove(root.__left_, &c); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &b); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == &a); - assert(b.__right_ == 0); - assert(b.__is_black_ == true); - - std::__tree_remove(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &a); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(a.__parent_ == &root); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == true); - - std::__tree_remove(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == 0); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - } - { - Node root; - Node a; - Node b; - Node c; - - root.__left_ = &b; - - b.__parent_ = &root; - b.__left_ = &a; - b.__right_ = &c; - b.__is_black_ = true; - - a.__parent_ = &b; - a.__left_ = 0; - a.__right_ = 0; - a.__is_black_ = false; - - c.__parent_ = &b; - c.__left_ = 0; - c.__right_ = 0; - c.__is_black_ = false; - - std::__tree_remove(root.__left_, &c); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &b); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == &a); - assert(b.__right_ == 0); - assert(b.__is_black_ == true); - - std::__tree_remove(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &a); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(a.__parent_ == &root); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == true); - - std::__tree_remove(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == 0); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - } - { - Node root; - Node a; - Node b; - Node c; - - root.__left_ = &b; - - b.__parent_ = &root; - b.__left_ = &a; - b.__right_ = &c; - b.__is_black_ = true; - - a.__parent_ = &b; - a.__left_ = 0; - a.__right_ = 0; - a.__is_black_ = true; - - c.__parent_ = &b; - c.__left_ = 0; - c.__right_ = 0; - c.__is_black_ = true; - - std::__tree_remove(root.__left_, &c); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &b); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == &a); - assert(b.__right_ == 0); - assert(b.__is_black_ == true); - - std::__tree_remove(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &b); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == 0); - assert(b.__right_ == 0); - assert(b.__is_black_ == true); - - std::__tree_remove(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == 0); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - } - { - Node root; - Node a; - Node b; - Node c; - - root.__left_ = &b; - - b.__parent_ = &root; - b.__left_ = &a; - b.__right_ = &c; - b.__is_black_ = true; - - a.__parent_ = &b; - a.__left_ = 0; - a.__right_ = 0; - a.__is_black_ = false; - - c.__parent_ = &b; - c.__left_ = 0; - c.__right_ = 0; - c.__is_black_ = false; - - std::__tree_remove(root.__left_, &c); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &b); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == &a); - assert(b.__right_ == 0); - assert(b.__is_black_ == true); - - std::__tree_remove(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &b); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == 0); - assert(b.__right_ == 0); - assert(b.__is_black_ == true); - - std::__tree_remove(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == 0); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - } -} - -void -test3() -{ - Node root; - Node a; - Node b; - Node c; - Node d; - Node e; - Node f; - Node g; - Node h; - - root.__left_ = &e; - - e.__parent_ = &root; - e.__left_ = &c; - e.__right_ = &g; - e.__is_black_ = true; - - c.__parent_ = &e; - c.__left_ = &b; - c.__right_ = &d; - c.__is_black_ = false; - - g.__parent_ = &e; - g.__left_ = &f; - g.__right_ = &h; - g.__is_black_ = false; - - b.__parent_ = &c; - b.__left_ = &a; - b.__right_ = 0; - b.__is_black_ = true; - - d.__parent_ = &c; - d.__left_ = 0; - d.__right_ = 0; - d.__is_black_ = true; - - f.__parent_ = &g; - f.__left_ = 0; - f.__right_ = 0; - f.__is_black_ = true; - - h.__parent_ = &g; - h.__left_ = 0; - h.__right_ = 0; - h.__is_black_ = true; - - a.__parent_ = &b; - a.__left_ = 0; - a.__right_ = 0; - a.__is_black_ = false; - - assert(std::__tree_invariant(root.__left_)); - - std::__tree_remove(root.__left_, &h); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &e); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(e.__parent_ == &root); - assert(e.__left_ == &c); - assert(e.__right_ == &g); - assert(e.__is_black_ == true); - - assert(c.__parent_ == &e); - assert(c.__left_ == &b); - assert(c.__right_ == &d); - assert(c.__is_black_ == false); - - assert(g.__parent_ == &e); - assert(g.__left_ == &f); - assert(g.__right_ == 0); - assert(g.__is_black_ == true); - - assert(b.__parent_ == &c); - assert(b.__left_ == &a); - assert(b.__right_ == 0); - assert(b.__is_black_ == true); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - - assert(d.__parent_ == &c); - assert(d.__left_ == 0); - assert(d.__right_ == 0); - assert(d.__is_black_ == true); - - assert(f.__parent_ == &g); - assert(f.__left_ == 0); - assert(f.__right_ == 0); - assert(f.__is_black_ == false); - - std::__tree_remove(root.__left_, &g); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &e); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(e.__parent_ == &root); - assert(e.__left_ == &c); - assert(e.__right_ == &f); - assert(e.__is_black_ == true); - - assert(c.__parent_ == &e); - assert(c.__left_ == &b); - assert(c.__right_ == &d); - assert(c.__is_black_ == false); - - assert(b.__parent_ == &c); - assert(b.__left_ == &a); - assert(b.__right_ == 0); - assert(b.__is_black_ == true); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - - assert(d.__parent_ == &c); - assert(d.__left_ == 0); - assert(d.__right_ == 0); - assert(d.__is_black_ == true); - - assert(f.__parent_ == &e); - assert(f.__left_ == 0); - assert(f.__right_ == 0); - assert(f.__is_black_ == true); - - std::__tree_remove(root.__left_, &f); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &c); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(c.__parent_ == &root); - assert(c.__left_ == &b); - assert(c.__right_ == &e); - assert(c.__is_black_ == true); - - assert(b.__parent_ == &c); - assert(b.__left_ == &a); - assert(b.__right_ == 0); - assert(b.__is_black_ == true); - - assert(e.__parent_ == &c); - assert(e.__left_ == &d); - assert(e.__right_ == 0); - assert(e.__is_black_ == true); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - - assert(d.__parent_ == &e); - assert(d.__left_ == 0); - assert(d.__right_ == 0); - assert(d.__is_black_ == false); - - std::__tree_remove(root.__left_, &e); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &c); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(c.__parent_ == &root); - assert(c.__left_ == &b); - assert(c.__right_ == &d); - assert(c.__is_black_ == true); - - assert(b.__parent_ == &c); - assert(b.__left_ == &a); - assert(b.__right_ == 0); - assert(b.__is_black_ == true); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - - assert(d.__parent_ == &c); - assert(d.__left_ == 0); - assert(d.__right_ == 0); - assert(d.__is_black_ == true); - - std::__tree_remove(root.__left_, &d); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &b); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == &a); - assert(b.__right_ == &c); - assert(b.__is_black_ == true); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == true); - - assert(c.__parent_ == &b); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == true); - - std::__tree_remove(root.__left_, &c); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &b); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(b.__parent_ == &root); - assert(b.__left_ == &a); - assert(b.__right_ == 0); - assert(b.__is_black_ == true); - - assert(a.__parent_ == &b); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == false); - - std::__tree_remove(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &a); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(a.__parent_ == &root); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(a.__is_black_ == true); - - std::__tree_remove(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == 0); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); -} - -void -test4() -{ - Node root; - Node a; - Node b; - Node c; - Node d; - Node e; - Node f; - Node g; - Node h; - - root.__left_ = &d; - - d.__parent_ = &root; - d.__left_ = &b; - d.__right_ = &f; - d.__is_black_ = true; - - b.__parent_ = &d; - b.__left_ = &a; - b.__right_ = &c; - b.__is_black_ = false; - - f.__parent_ = &d; - f.__left_ = &e; - f.__right_ = &g; - f.__is_black_ = false; - - a.__parent_ = &b; - a.__left_ = 0; - a.__right_ = 0; - a.__is_black_ = true; - - c.__parent_ = &b; - c.__left_ = 0; - c.__right_ = 0; - c.__is_black_ = true; - - e.__parent_ = &f; - e.__left_ = 0; - e.__right_ = 0; - e.__is_black_ = true; - - g.__parent_ = &f; - g.__left_ = 0; - g.__right_ = &h; - g.__is_black_ = true; - - h.__parent_ = &g; - h.__left_ = 0; - h.__right_ = 0; - h.__is_black_ = false; - - assert(std::__tree_invariant(root.__left_)); - - std::__tree_remove(root.__left_, &a); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &d); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(d.__parent_ == &root); - assert(d.__left_ == &b); - assert(d.__right_ == &f); - assert(d.__is_black_ == true); - - assert(b.__parent_ == &d); - assert(b.__left_ == 0); - assert(b.__right_ == &c); - assert(b.__is_black_ == true); - - assert(f.__parent_ == &d); - assert(f.__left_ == &e); - assert(f.__right_ == &g); - assert(f.__is_black_ == false); - - assert(c.__parent_ == &b); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == false); - - assert(e.__parent_ == &f); - assert(e.__left_ == 0); - assert(e.__right_ == 0); - assert(e.__is_black_ == true); - - assert(g.__parent_ == &f); - assert(g.__left_ == 0); - assert(g.__right_ == &h); - assert(g.__is_black_ == true); - - assert(h.__parent_ == &g); - assert(h.__left_ == 0); - assert(h.__right_ == 0); - assert(h.__is_black_ == false); - - std::__tree_remove(root.__left_, &b); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &d); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(d.__parent_ == &root); - assert(d.__left_ == &c); - assert(d.__right_ == &f); - assert(d.__is_black_ == true); - - assert(c.__parent_ == &d); - assert(c.__left_ == 0); - assert(c.__right_ == 0); - assert(c.__is_black_ == true); - - assert(f.__parent_ == &d); - assert(f.__left_ == &e); - assert(f.__right_ == &g); - assert(f.__is_black_ == false); - - assert(e.__parent_ == &f); - assert(e.__left_ == 0); - assert(e.__right_ == 0); - assert(e.__is_black_ == true); - - assert(g.__parent_ == &f); - assert(g.__left_ == 0); - assert(g.__right_ == &h); - assert(g.__is_black_ == true); - - assert(h.__parent_ == &g); - assert(h.__left_ == 0); - assert(h.__right_ == 0); - assert(h.__is_black_ == false); - - std::__tree_remove(root.__left_, &c); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &f); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(f.__parent_ == &root); - assert(f.__left_ == &d); - assert(f.__right_ == &g); - assert(f.__is_black_ == true); - - assert(d.__parent_ == &f); - assert(d.__left_ == 0); - assert(d.__right_ == &e); - assert(d.__is_black_ == true); - - assert(g.__parent_ == &f); - assert(g.__left_ == 0); - assert(g.__right_ == &h); - assert(g.__is_black_ == true); - - assert(e.__parent_ == &d); - assert(e.__left_ == 0); - assert(e.__right_ == 0); - assert(e.__is_black_ == false); - - assert(h.__parent_ == &g); - assert(h.__left_ == 0); - assert(h.__right_ == 0); - assert(h.__is_black_ == false); - - std::__tree_remove(root.__left_, &d); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &f); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(f.__parent_ == &root); - assert(f.__left_ == &e); - assert(f.__right_ == &g); - assert(f.__is_black_ == true); - - assert(e.__parent_ == &f); - assert(e.__left_ == 0); - assert(e.__right_ == 0); - assert(e.__is_black_ == true); - - assert(g.__parent_ == &f); - assert(g.__left_ == 0); - assert(g.__right_ == &h); - assert(g.__is_black_ == true); - - assert(h.__parent_ == &g); - assert(h.__left_ == 0); - assert(h.__right_ == 0); - assert(h.__is_black_ == false); - - std::__tree_remove(root.__left_, &e); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &g); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(g.__parent_ == &root); - assert(g.__left_ == &f); - assert(g.__right_ == &h); - assert(g.__is_black_ == true); - - assert(f.__parent_ == &g); - assert(f.__left_ == 0); - assert(f.__right_ == 0); - assert(f.__is_black_ == true); - - assert(h.__parent_ == &g); - assert(h.__left_ == 0); - assert(h.__right_ == 0); - assert(h.__is_black_ == true); - - std::__tree_remove(root.__left_, &f); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &g); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(g.__parent_ == &root); - assert(g.__left_ == 0); - assert(g.__right_ == &h); - assert(g.__is_black_ == true); - - assert(h.__parent_ == &g); - assert(h.__left_ == 0); - assert(h.__right_ == 0); - assert(h.__is_black_ == false); - - std::__tree_remove(root.__left_, &g); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == &h); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); - - assert(h.__parent_ == &root); - assert(h.__left_ == 0); - assert(h.__right_ == 0); - assert(h.__is_black_ == true); - - std::__tree_remove(root.__left_, &h); - - assert(std::__tree_invariant(root.__left_)); - - assert(root.__parent_ == 0); - assert(root.__left_ == 0); - assert(root.__right_ == 0); - assert(root.__is_black_ == false); -} - -int main() -{ - test1(); - test2(); - test3(); - test4(); -} diff --git a/test/std/containers/associative/tree_right_rotate.pass.cpp b/test/std/containers/associative/tree_right_rotate.pass.cpp deleted file mode 100644 index 06ec7b889452..000000000000 --- a/test/std/containers/associative/tree_right_rotate.pass.cpp +++ /dev/null @@ -1,98 +0,0 @@ -//===----------------------------------------------------------------------===// -// -// The LLVM Compiler Infrastructure -// -// This file is dual licensed under the MIT and the University of Illinois Open -// Source Licenses. See LICENSE.TXT for details. -// -//===----------------------------------------------------------------------===// - -// Not a portable test - -// Precondition: __x->__left_ != nullptr -// template <class _NodePtr> -// void -// __tree_right_rotate(_NodePtr __x); - -#include <__tree> -#include <cassert> - -struct Node -{ - Node* __left_; - Node* __right_; - Node* __parent_; - - Node() : __left_(), __right_(), __parent_() {} -}; - -void -test1() -{ - Node root; - Node x; - Node y; - root.__left_ = &x; - x.__left_ = &y; - x.__right_ = 0; - x.__parent_ = &root; - y.__left_ = 0; - y.__right_ = 0; - y.__parent_ = &x; - std::__tree_right_rotate(&x); - assert(root.__parent_ == 0); - assert(root.__left_ == &y); - assert(root.__right_ == 0); - assert(y.__parent_ == &root); - assert(y.__left_ == 0); - assert(y.__right_ == &x); - assert(x.__parent_ == &y); - assert(x.__left_ == 0); - assert(x.__right_ == 0); -} - -void -test2() -{ - Node root; - Node x; - Node y; - Node a; - Node b; - Node c; - root.__left_ = &x; - x.__left_ = &y; - x.__right_ = &c; - x.__parent_ = &root; - y.__left_ = &a; - y.__right_ = &b; - y.__parent_ = &x; - a.__parent_ = &y; - b.__parent_ = &y; - c.__parent_ = &x; - std::__tree_right_rotate(&x); - assert(root.__parent_ == 0); - assert(root.__left_ == &y); - assert(root.__right_ == 0); - assert(y.__parent_ == &root); - assert(y.__left_ == &a); - assert(y.__right_ == &x); - assert(x.__parent_ == &y); - assert(x.__left_ == &b); - assert(x.__right_ == &c); - assert(a.__parent_ == &y); - assert(a.__left_ == 0); - assert(a.__right_ == 0); - assert(b.__parent_ == &x); - assert(b.__left_ == 0); - assert(b.__right_ == 0); - assert(c.__parent_ == &x); - assert(c.__left_ == 0); - assert(c.__right_ == 0); -} - -int main() -{ - test1(); - test2(); -} |