diff options
Diffstat (limited to 'test/std/containers')
824 files changed, 4847 insertions, 7901 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(); -} diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp index 66ca614126f4..dc5cca3c5568 100644 --- a/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_cont_alloc.pass.cpp @@ -16,6 +16,7 @@ #include <queue> #include <cassert> +#include "test_macros.h" #include "test_allocator.h" template <class C> @@ -41,11 +42,11 @@ struct test : base(comp, a) {} test(const value_compare& comp, const container_type& c, const test_allocator<int>& a) : base(comp, c, a) {} -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 // testing rvalue constructor test(const value_compare& comp, container_type&& c, const test_allocator<int>& a) : base(comp, std::move(c), a) {} test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {} -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif test_allocator<int> get_allocator() {return c.get_allocator();} using base::c; diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp index 643b0c625abb..a27a6e205123 100644 --- a/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons.alloc/ctor_comp_rcont_alloc.pass.cpp @@ -16,6 +16,7 @@ #include <queue> #include <cassert> +#include "test_macros.h" #include "test_allocator.h" template <class C> @@ -41,11 +42,11 @@ struct test : base(comp, a) {} test(const value_compare& comp, const container_type& c, const test_allocator<int>& a) : base(comp, c, a) {} -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 // testing rvalue ctor test(const value_compare& comp, container_type&& c, const test_allocator<int>& a) : base(comp, std::move(c), a) {} test(test&& q, const test_allocator<int>& a) : base(std::move(q), a) {} -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif test_allocator<int> get_allocator() {return c.get_allocator();} using base::c; diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp index cdfa58b58554..c79feb93eb6c 100644 --- a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/default_noexcept.pass.cpp @@ -15,17 +15,18 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <queue> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" int main() { -#if __has_feature(cxx_noexcept) { typedef std::priority_queue<MoveOnly> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp index e3d071d9aad0..3cedefef2c87 100644 --- a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/dtor_noexcept.pass.cpp @@ -11,6 +11,8 @@ // ~priority_queue() // implied noexcept; +// UNSUPPORTED: c++98, c++03 + #include <queue> #include <cassert> @@ -18,10 +20,8 @@ int main() { -#if __has_feature(cxx_noexcept) { typedef std::priority_queue<MoveOnly> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp index 590d82fe6da4..f14c3ae7ce43 100644 --- a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_assign_noexcept.pass.cpp @@ -15,6 +15,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <queue> #include <cassert> @@ -22,10 +24,8 @@ int main() { -#if __has_feature(cxx_noexcept) { typedef std::priority_queue<MoveOnly> C; static_assert(std::is_nothrow_move_assignable<C>::value, ""); } -#endif } diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp index 05ff253d31b4..0218992670f2 100644 --- a/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.cons/move_noexcept.pass.cpp @@ -15,6 +15,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <queue> #include <cassert> @@ -22,10 +24,8 @@ int main() { -#if __has_feature(cxx_noexcept) { typedef std::priority_queue<MoveOnly> C; static_assert(std::is_nothrow_move_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp b/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp index 4d2b441c60ee..bfff607590fe 100644 --- a/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/priority.queue/priqueue.special/swap_noexcept.pass.cpp @@ -15,6 +15,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <queue> #include <cassert> @@ -22,11 +24,9 @@ int main() { -#if __has_feature(cxx_noexcept) { typedef std::priority_queue<MoveOnly> C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } -#endif } diff --git a/test/std/containers/container.adaptors/priority.queue/types.fail.cpp b/test/std/containers/container.adaptors/priority.queue/types.fail.cpp new file mode 100644 index 000000000000..0d3025e1739a --- /dev/null +++ b/test/std/containers/container.adaptors/priority.queue/types.fail.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// template <class T, class Container = vector<T>, +// class Compare = less<typename Container::value_type>> +// class priority_queue +// { +// public: +// typedef Container container_type; +// typedef typename container_type::value_type value_type; +// typedef typename container_type::reference reference; +// typedef typename container_type::const_reference const_reference; +// typedef typename container_type::size_type size_type; +// +// protected: +// container_type c; +// Compare comp; + +#include <queue> +#include <cassert> +#include <type_traits> + +int main() +{ +// LWG#2566 says that the first template param must match the second one's value type + std::priority_queue<double, std::deque<int>> t; +} diff --git a/test/std/containers/container.adaptors/priority.queue/types.pass.cpp b/test/std/containers/container.adaptors/priority.queue/types.pass.cpp index ade20d47d4e3..6bc476a3ce05 100644 --- a/test/std/containers/container.adaptors/priority.queue/types.pass.cpp +++ b/test/std/containers/container.adaptors/priority.queue/types.pass.cpp @@ -15,6 +15,7 @@ // { // public: // typedef Container container_type; +// typedef Compare value_compare; // LWG#2684 // typedef typename container_type::value_type value_type; // typedef typename container_type::reference reference; // typedef typename container_type::const_reference const_reference; @@ -26,7 +27,11 @@ #include <queue> #include <cassert> +#include <deque> +#include <functional> +#include <memory> #include <type_traits> +#include <vector> struct test : private std::priority_queue<int> @@ -48,13 +53,16 @@ struct C int main() { - static_assert((std::is_same<std::priority_queue<int>::container_type, std::vector<int> >::value), ""); - static_assert((std::is_same<std::priority_queue<double, std::deque<int> >::container_type, std::deque<int> >::value), ""); - static_assert((std::is_same<std::priority_queue<double, std::deque<int> >::value_type, int>::value), ""); - static_assert((std::is_same<std::priority_queue<int>::reference, std::vector<int>::reference>::value), ""); - static_assert((std::is_same<std::priority_queue<int>::const_reference, std::vector<int>::const_reference>::value), ""); - static_assert((std::is_same<std::priority_queue<int>::size_type, std::vector<int>::size_type>::value), ""); - static_assert((std::uses_allocator<std::priority_queue<int>, std::allocator<int> >::value), ""); + static_assert(( std::is_same<std::priority_queue<int>::container_type, std::vector<int> >::value), ""); + static_assert(( std::is_same<std::priority_queue<int, std::deque<int> >::container_type, std::deque<int> >::value), ""); + static_assert(( std::is_same<std::priority_queue<int, std::deque<int> >::value_type, int>::value), ""); + static_assert(( std::is_same<std::priority_queue<int>::reference, std::vector<int>::reference>::value), ""); + static_assert(( std::is_same<std::priority_queue<int>::const_reference, std::vector<int>::const_reference>::value), ""); + static_assert(( std::is_same<std::priority_queue<int>::size_type, std::vector<int>::size_type>::value), ""); + static_assert(( std::is_same<std::priority_queue<int>::value_compare, std::less<int> >::value), ""); + static_assert(( std::is_same<std::priority_queue<int, std::deque<int> >::value_compare, std::less<int> >::value), ""); + static_assert(( std::is_same<std::priority_queue<int, std::deque<int>, std::greater<int> >::value_compare, std::greater<int> >::value), ""); + static_assert(( std::uses_allocator<std::priority_queue<int>, std::allocator<int> >::value), ""); static_assert((!std::uses_allocator<std::priority_queue<int, C>, std::allocator<int> >::value), ""); test t; } diff --git a/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp index 392853432669..43045893fe07 100644 --- a/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/queue/queue.cons/default_noexcept.pass.cpp @@ -14,17 +14,18 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <queue> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" int main() { -#if __has_feature(cxx_noexcept) { typedef std::queue<MoveOnly> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/container.adaptors/queue/queue.cons/dtor_noexcept.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/dtor_noexcept.pass.cpp index d9b8f731f28a..2a6783287b09 100644 --- a/test/std/containers/container.adaptors/queue/queue.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/queue/queue.cons/dtor_noexcept.pass.cpp @@ -11,6 +11,8 @@ // ~queue() // implied noexcept; +// UNSUPPORTED: c++98, c++03 + #include <queue> #include <cassert> @@ -18,10 +20,8 @@ int main() { -#if __has_feature(cxx_noexcept) { typedef std::queue<MoveOnly> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/container.adaptors/queue/queue.cons/move_assign_noexcept.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/move_assign_noexcept.pass.cpp index beef0f12ffb7..42e1c458c9da 100644 --- a/test/std/containers/container.adaptors/queue/queue.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/queue/queue.cons/move_assign_noexcept.pass.cpp @@ -14,6 +14,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <queue> #include <cassert> @@ -21,10 +23,8 @@ int main() { -#if __has_feature(cxx_noexcept) { typedef std::queue<MoveOnly> C; static_assert(std::is_nothrow_move_assignable<C>::value, ""); } -#endif } diff --git a/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp b/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp index 2402e609b988..1c13b622c0a5 100644 --- a/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/queue/queue.cons/move_noexcept.pass.cpp @@ -14,6 +14,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <queue> #include <cassert> @@ -21,10 +23,8 @@ int main() { -#if __has_feature(cxx_noexcept) { typedef std::queue<MoveOnly> C; static_assert(std::is_nothrow_move_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/container.adaptors/queue/version.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/types.fail.cpp index 35b94b33c517..2b8341fff009 100644 --- a/test/std/containers/container.adaptors/queue/version.pass.cpp +++ b/test/std/containers/container.adaptors/queue/queue.defn/types.fail.cpp @@ -10,11 +10,11 @@ // <queue> #include <queue> - -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif +#include <cassert> +#include <type_traits> int main() { +// LWG#2566 says that the first template param must match the second one's value type + std::queue<double, std::deque<int>> t; } diff --git a/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp b/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp index cc918a361707..7f1883a16838 100644 --- a/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp +++ b/test/std/containers/container.adaptors/queue/queue.defn/types.pass.cpp @@ -46,13 +46,13 @@ struct C int main() { - static_assert((std::is_same<std::queue<int>::container_type, std::deque<int> >::value), ""); - static_assert((std::is_same<std::queue<double, std::vector<int> >::container_type, std::vector<int> >::value), ""); - static_assert((std::is_same<std::queue<double, std::vector<int> >::value_type, int>::value), ""); - static_assert((std::is_same<std::queue<int>::reference, std::deque<int>::reference>::value), ""); - static_assert((std::is_same<std::queue<int>::const_reference, std::deque<int>::const_reference>::value), ""); - static_assert((std::is_same<std::queue<int>::size_type, std::deque<int>::size_type>::value), ""); - static_assert((std::uses_allocator<std::queue<int>, std::allocator<int> >::value), ""); + static_assert(( std::is_same<std::queue<int>::container_type, std::deque<int> >::value), ""); + static_assert(( std::is_same<std::queue<int, std::vector<int> >::container_type, std::vector<int> >::value), ""); + static_assert(( std::is_same<std::queue<int, std::vector<int> >::value_type, int>::value), ""); + static_assert(( std::is_same<std::queue<int>::reference, std::deque<int>::reference>::value), ""); + static_assert(( std::is_same<std::queue<int>::const_reference, std::deque<int>::const_reference>::value), ""); + static_assert(( std::is_same<std::queue<int>::size_type, std::deque<int>::size_type>::value), ""); + static_assert(( std::uses_allocator<std::queue<int>, std::allocator<int> >::value), ""); static_assert((!std::uses_allocator<std::queue<int, C>, std::allocator<int> >::value), ""); test t; } diff --git a/test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp b/test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp index cfe4a1bb7076..e18f80a91198 100644 --- a/test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/queue/queue.special/swap_noexcept.pass.cpp @@ -14,6 +14,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <queue> #include <cassert> @@ -21,11 +23,9 @@ int main() { -#if __has_feature(cxx_noexcept) { typedef std::queue<MoveOnly> C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } -#endif } diff --git a/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp index bab55863b55f..2d1f9437fc45 100644 --- a/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/stack/stack.cons/default_noexcept.pass.cpp @@ -14,17 +14,18 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <stack> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" int main() { -#if __has_feature(cxx_noexcept) { typedef std::stack<MoveOnly> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp index 477bd57a6d10..0a0111b4dc46 100644 --- a/test/std/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/stack/stack.cons/dtor_noexcept.pass.cpp @@ -11,6 +11,8 @@ // ~stack() // implied noexcept; +// UNSUPPORTED: c++98, c++03 + #include <stack> #include <cassert> @@ -18,10 +20,8 @@ int main() { -#if __has_feature(cxx_noexcept) { typedef std::stack<MoveOnly> C; static_assert(std::is_nothrow_destructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp index dd836796dc17..d5822839cabf 100644 --- a/test/std/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/stack/stack.cons/move_assign_noexcept.pass.cpp @@ -14,6 +14,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <stack> #include <cassert> @@ -21,10 +23,8 @@ int main() { -#if __has_feature(cxx_noexcept) { typedef std::stack<MoveOnly> C; static_assert(std::is_nothrow_move_assignable<C>::value, ""); } -#endif } diff --git a/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp index cfc660b36def..7eb563c76835 100644 --- a/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/stack/stack.cons/move_noexcept.pass.cpp @@ -14,6 +14,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <stack> #include <cassert> @@ -21,10 +23,8 @@ int main() { -#if __has_feature(cxx_noexcept) { typedef std::stack<MoveOnly> C; static_assert(std::is_nothrow_move_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/container.adaptors/stack/stack.defn/types.fail.cpp b/test/std/containers/container.adaptors/stack/stack.defn/types.fail.cpp new file mode 100644 index 000000000000..ee4c5441e7c3 --- /dev/null +++ b/test/std/containers/container.adaptors/stack/stack.defn/types.fail.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <queue> + +// template <class T, class Container = vector<T>, +// class Compare = less<typename Container::value_type>> +// class priority_queue +// { +// public: +// typedef Container container_type; +// typedef typename container_type::value_type value_type; +// typedef typename container_type::reference reference; +// typedef typename container_type::const_reference const_reference; +// typedef typename container_type::size_type size_type; +// +// protected: +// container_type c; +// Compare comp; + +#include <stack> +#include <cassert> +#include <type_traits> + +int main() +{ +// LWG#2566 says that the first template param must match the second one's value type + std::stack<double, std::deque<int>> t; +} diff --git a/test/std/containers/container.adaptors/stack/stack.defn/types.pass.cpp b/test/std/containers/container.adaptors/stack/stack.defn/types.pass.cpp index afc5ebd53753..77a798b8382a 100644 --- a/test/std/containers/container.adaptors/stack/stack.defn/types.pass.cpp +++ b/test/std/containers/container.adaptors/stack/stack.defn/types.pass.cpp @@ -47,13 +47,13 @@ struct C int main() { - static_assert((std::is_same<std::stack<int>::container_type, std::deque<int> >::value), ""); - static_assert((std::is_same<std::stack<double, std::vector<int> >::container_type, std::vector<int> >::value), ""); - static_assert((std::is_same<std::stack<double, std::vector<int> >::value_type, int>::value), ""); - static_assert((std::is_same<std::stack<int>::reference, std::deque<int>::reference>::value), ""); - static_assert((std::is_same<std::stack<int>::const_reference, std::deque<int>::const_reference>::value), ""); - static_assert((std::is_same<std::stack<int>::size_type, std::deque<int>::size_type>::value), ""); - static_assert((std::uses_allocator<std::stack<int>, std::allocator<int> >::value), ""); + static_assert(( std::is_same<std::stack<int>::container_type, std::deque<int> >::value), ""); + static_assert(( std::is_same<std::stack<int, std::vector<int> >::container_type, std::vector<int> >::value), ""); + static_assert(( std::is_same<std::stack<int, std::vector<int> >::value_type, int>::value), ""); + static_assert(( std::is_same<std::stack<int>::reference, std::deque<int>::reference>::value), ""); + static_assert(( std::is_same<std::stack<int>::const_reference, std::deque<int>::const_reference>::value), ""); + static_assert(( std::is_same<std::stack<int>::size_type, std::deque<int>::size_type>::value), ""); + static_assert(( std::uses_allocator<std::stack<int>, std::allocator<int> >::value), ""); static_assert((!std::uses_allocator<std::stack<int, C>, std::allocator<int> >::value), ""); test t; } diff --git a/test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp b/test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp index 80e024f5f1e0..976e362a0483 100644 --- a/test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp +++ b/test/std/containers/container.adaptors/stack/stack.special/swap_noexcept.pass.cpp @@ -14,6 +14,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <stack> #include <cassert> @@ -21,11 +23,9 @@ int main() { -#if __has_feature(cxx_noexcept) { typedef std::stack<MoveOnly> C; C c1, c2; static_assert(noexcept(swap(c1, c2)), ""); } -#endif } diff --git a/test/std/containers/map_allocator_requirement_test_templates.h b/test/std/containers/map_allocator_requirement_test_templates.h new file mode 100644 index 000000000000..2ae3a2e3c87a --- /dev/null +++ b/test/std/containers/map_allocator_requirement_test_templates.h @@ -0,0 +1,743 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +#ifndef MAP_ALLOCATOR_REQUIREMENT_TEST_TEMPLATES_H +#define MAP_ALLOCATOR_REQUIREMENT_TEST_TEMPLATES_H + +// <map> +// <unordered_map> + +// class map +// class unordered_map + +// insert(...); +// emplace(...); +// emplace_hint(...); + +// UNSUPPORTED: c++98, c++03 + +#include <cassert> + +#include "test_macros.h" +#include "count_new.hpp" +#include "container_test_types.h" +#include "assert_checkpoint.h" + + +template <class Container> +void testMapInsert() +{ + typedef typename Container::value_type ValueTp; + typedef typename Container::key_type Key; + typedef typename Container::mapped_type Mapped; + typedef Container C; + typedef std::pair<typename C::iterator, bool> R; + ConstructController* cc = getConstructController(); + cc->reset(); + { + CHECKPOINT("Testing C::insert(const value_type&)"); + Container c; + const ValueTp v(42, 1); + cc->expect<const ValueTp&>(); + assert(c.insert(v).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const ValueTp v2(42, 1); + assert(c.insert(v2).second == false); + } + } + { + CHECKPOINT("Testing C::insert(value_type&)"); + Container c; + ValueTp v(42, 1); + cc->expect<const ValueTp&>(); + assert(c.insert(v).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + ValueTp v2(42, 1); + assert(c.insert(v2).second == false); + } + } + { + CHECKPOINT("Testing C::insert(value_type&&)"); + Container c; + ValueTp v(42, 1); + cc->expect<ValueTp&&>(); + assert(c.insert(std::move(v)).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + ValueTp v2(42, 1); + assert(c.insert(std::move(v2)).second == false); + } + } + { + CHECKPOINT("Testing C::insert(const value_type&&)"); + Container c; + const ValueTp v(42, 1); + cc->expect<const ValueTp&>(); + assert(c.insert(std::move(v)).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const ValueTp v2(42, 1); + assert(c.insert(std::move(v2)).second == false); + } + } + { + CHECKPOINT("Testing C::insert({key, value})"); + Container c; + cc->expect<ValueTp&&>(); + assert(c.insert({42, 1}).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const ValueTp v2(42, 1); + assert(c.insert(std::move(v2)).second == false); + } + } + { + CHECKPOINT("Testing C::insert(std::initializer_list<ValueTp>)"); + Container c; + std::initializer_list<ValueTp> il = { ValueTp(1, 1), ValueTp(2, 1) }; + cc->expect<ValueTp const&>(2); + c.insert(il); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + c.insert(il); + } + } + { + CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type const&"); + Container c; + const ValueTp ValueList[] = { ValueTp(1, 1), ValueTp(2, 1), ValueTp(3, 1) }; + cc->expect<ValueTp const&>(3); + c.insert(std::begin(ValueList), std::end(ValueList)); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + c.insert(std::begin(ValueList), std::end(ValueList)); + } + } + { + CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&&"); + Container c; + ValueTp ValueList[] = { ValueTp(1, 1), ValueTp(2, 1) , ValueTp(3, 1) }; + cc->expect<ValueTp&&>(3); + c.insert(std::move_iterator<ValueTp*>(std::begin(ValueList)), + std::move_iterator<ValueTp*>(std::end(ValueList))); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + ValueTp ValueList2[] = { ValueTp(1, 1), ValueTp(2, 1) , ValueTp(3, 1) }; + c.insert(std::move_iterator<ValueTp*>(std::begin(ValueList2)), + std::move_iterator<ValueTp*>(std::end(ValueList2))); + } + } + { + CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&"); + Container c; + ValueTp ValueList[] = { ValueTp(1, 1), ValueTp(2, 1) , ValueTp(3, 1) }; + cc->expect<ValueTp const&>(3); + c.insert(std::begin(ValueList), std::end(ValueList)); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + c.insert(std::begin(ValueList), std::end(ValueList)); + } + } +} + + +template <class Container> +void testMapInsertHint() +{ + typedef typename Container::value_type ValueTp; + typedef typename Container::key_type Key; + typedef typename Container::mapped_type Mapped; + typedef typename std::pair<Key, Mapped> NonConstKeyPair; + typedef Container C; + typedef typename C::iterator It; + ConstructController* cc = getConstructController(); + cc->reset(); + { + CHECKPOINT("Testing C::insert(p, const value_type&)"); + Container c; + const ValueTp v(42, 1); + cc->expect<const ValueTp&>(); + It ret = c.insert(c.end(), v); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const ValueTp v2(42, 1); + It ret2 = c.insert(c.begin(), v2); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::insert(p, value_type&)"); + Container c; + ValueTp v(42, 1); + cc->expect<ValueTp const&>(); + It ret = c.insert(c.end(), v); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + ValueTp v2(42, 1); + It ret2 = c.insert(c.begin(), v2); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::insert(p, value_type&&)"); + Container c; + ValueTp v(42, 1); + cc->expect<ValueTp&&>(); + It ret = c.insert(c.end(), std::move(v)); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + ValueTp v2(42, 1); + It ret2 = c.insert(c.begin(), std::move(v2)); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::insert(p, {key, value})"); + Container c; + cc->expect<ValueTp&&>(); + It ret = c.insert(c.end(), {42, 1}); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + It ret2 = c.insert(c.begin(), {42, 1}); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::insert(p, const value_type&&)"); + Container c; + const ValueTp v(42, 1); + cc->expect<const ValueTp&>(); + It ret = c.insert(c.end(), std::move(v)); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const ValueTp v2(42, 1); + It ret2 = c.insert(c.begin(), std::move(v2)); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::insert(p, pair<Key, Mapped> const&)"); + Container c; + const NonConstKeyPair v(42, 1); + cc->expect<const NonConstKeyPair&>(); + It ret = c.insert(c.end(), v); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const NonConstKeyPair v2(42, 1); + It ret2 = c.insert(c.begin(), v2); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::insert(p, pair<Key, Mapped>&&)"); + Container c; + NonConstKeyPair v(42, 1); + cc->expect<NonConstKeyPair&&>(); + It ret = c.insert(c.end(), std::move(v)); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + NonConstKeyPair v2(42, 1); + It ret2 = c.insert(c.begin(), std::move(v2)); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + + +} + + +template <class Container> +void testMapEmplace() +{ + typedef typename Container::value_type ValueTp; + typedef typename Container::key_type Key; + typedef typename Container::mapped_type Mapped; + typedef typename std::pair<Key, Mapped> NonConstKeyPair; + typedef Container C; + typedef std::pair<typename C::iterator, bool> R; + ConstructController* cc = getConstructController(); + cc->reset(); + { + CHECKPOINT("Testing C::emplace(const value_type&)"); + Container c; + const ValueTp v(42, 1); + cc->expect<const ValueTp&>(); + assert(c.emplace(v).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const ValueTp v2(42, 1); + assert(c.emplace(v2).second == false); + } + } + { + CHECKPOINT("Testing C::emplace(value_type&)"); + Container c; + ValueTp v(42, 1); + cc->expect<ValueTp&>(); + assert(c.emplace(v).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + ValueTp v2(42, 1); + assert(c.emplace(v2).second == false); + } + } + { + CHECKPOINT("Testing C::emplace(value_type&&)"); + Container c; + ValueTp v(42, 1); + cc->expect<ValueTp&&>(); + assert(c.emplace(std::move(v)).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + ValueTp v2(42, 1); + assert(c.emplace(std::move(v2)).second == false); + } + } + { + CHECKPOINT("Testing C::emplace(const value_type&&)"); + Container c; + const ValueTp v(42, 1); + cc->expect<const ValueTp&&>(); + assert(c.emplace(std::move(v)).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const ValueTp v2(42, 1); + assert(c.emplace(std::move(v2)).second == false); + } + } + { + CHECKPOINT("Testing C::emplace(pair<Key, Mapped> const&)"); + Container c; + const NonConstKeyPair v(42, 1); + cc->expect<const NonConstKeyPair&>(); + assert(c.emplace(v).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const NonConstKeyPair v2(42, 1); + assert(c.emplace(v2).second == false); + } + } + { + CHECKPOINT("Testing C::emplace(pair<Key, Mapped> &&)"); + Container c; + NonConstKeyPair v(42, 1); + cc->expect<NonConstKeyPair&&>(); + assert(c.emplace(std::move(v)).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + NonConstKeyPair v2(42, 1); + assert(c.emplace(std::move(v2)).second == false); + } + } + { + CHECKPOINT("Testing C::emplace(const Key&, ConvertibleToMapped&&)"); + Container c; + const Key k(42); + cc->expect<Key const&, int&&>(); + assert(c.emplace(k, 1).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const Key k2(42); + assert(c.emplace(k2, 2).second == false); + } + } + { + CHECKPOINT("Testing C::emplace(Key&, Mapped&)"); + Container c; + Key k(42); + Mapped m(1); + cc->expect<Key&, Mapped&>(); + assert(c.emplace(k, m).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + Key k2(42); + assert(c.emplace(k2, m).second == false); + } + } + { + CHECKPOINT("Testing C::emplace(Key&&, Mapped&&)"); + Container c; + Key k(42); + Mapped m(1); + cc->expect<Key&&, Mapped&&>(); + assert(c.emplace(std::move(k), std::move(m)).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + Key k2(42); + Mapped m2(2); + assert(c.emplace(std::move(k2), std::move(m2)).second == false); + } + } + { + CHECKPOINT("Testing C::emplace(ConvertibleToKey&&, ConvertibleToMapped&&)"); + Container c; + cc->expect<int&&, int&&>(); + assert(c.emplace(42, 1).second); + assert(!cc->unchecked()); + { + // test that emplacing a duplicate item allocates. We cannot optimize + // this case because int&& does not match the type of key exactly. + cc->expect<int&&, int&&>(); + assert(c.emplace(42, 1).second == false); + assert(!cc->unchecked()); + } + } +} + + +template <class Container> +void testMapEmplaceHint() +{ + typedef typename Container::value_type ValueTp; + typedef typename Container::key_type Key; + typedef typename Container::mapped_type Mapped; + typedef typename std::pair<Key, Mapped> NonConstKeyPair; + typedef Container C; + typedef typename C::iterator It; + ConstructController* cc = getConstructController(); + cc->reset(); + { + CHECKPOINT("Testing C::emplace_hint(p, const value_type&)"); + Container c; + const ValueTp v(42, 1); + cc->expect<const ValueTp&>(); + It ret = c.emplace_hint(c.end(), v); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const ValueTp v2(42, 1); + It ret2 = c.emplace_hint(c.begin(), v2); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::emplace_hint(p, value_type&)"); + Container c; + ValueTp v(42, 1); + cc->expect<ValueTp&>(); + It ret = c.emplace_hint(c.end(), v); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + ValueTp v2(42, 1); + It ret2 = c.emplace_hint(c.begin(), v2); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::emplace_hint(p, value_type&&)"); + Container c; + ValueTp v(42, 1); + cc->expect<ValueTp&&>(); + It ret = c.emplace_hint(c.end(), std::move(v)); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + ValueTp v2(42, 1); + It ret2 = c.emplace_hint(c.begin(), std::move(v2)); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::emplace_hint(p, const value_type&&)"); + Container c; + const ValueTp v(42, 1); + cc->expect<const ValueTp&&>(); + It ret = c.emplace_hint(c.end(), std::move(v)); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const ValueTp v2(42, 1); + It ret2 = c.emplace_hint(c.begin(), std::move(v2)); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::emplace_hint(p, pair<Key, Mapped> const&)"); + Container c; + const NonConstKeyPair v(42, 1); + cc->expect<const NonConstKeyPair&>(); + It ret = c.emplace_hint(c.end(), v); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const NonConstKeyPair v2(42, 1); + It ret2 = c.emplace_hint(c.begin(), v2); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::emplace_hint(p, pair<Key, Mapped>&&)"); + Container c; + NonConstKeyPair v(42, 1); + cc->expect<NonConstKeyPair&&>(); + It ret = c.emplace_hint(c.end(), std::move(v)); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + NonConstKeyPair v2(42, 1); + It ret2 = c.emplace_hint(c.begin(), std::move(v2)); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::emplace_hint(p, const Key&, ConvertibleToMapped&&)"); + Container c; + const Key k(42); + cc->expect<Key const&, int&&>(); + It ret = c.emplace_hint(c.end(), k, 42); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const Key k2(42); + It ret2 = c.emplace_hint(c.begin(), k2, 1); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::emplace_hint(p, Key&, Mapped&)"); + Container c; + Key k(42); + Mapped m(1); + cc->expect<Key&, Mapped&>(); + It ret = c.emplace_hint(c.end(), k, m); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + Key k2(42); + Mapped m2(2); + It ret2 = c.emplace_hint(c.begin(), k2, m2); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::emplace_hint(p, Key&&, Mapped&&)"); + Container c; + Key k(42); + Mapped m(1); + cc->expect<Key&&, Mapped&&>(); + It ret = c.emplace_hint(c.end(), std::move(k), std::move(m)); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + Key k2(42); + Mapped m2(2); + It ret2 = c.emplace_hint(c.begin(), std::move(k2), std::move(m2)); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::emplace_hint(p, ConvertibleToKey&&, ConvertibleToMapped&&)"); + Container c; + cc->expect<int&&, int&&>(); + It ret = c.emplace_hint(c.end(), 42, 1); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + cc->expect<int&&, int&&>(); + It ret2 = c.emplace_hint(c.begin(), 42, 2); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + assert(!cc->unchecked()); + } + } + +} + + +template <class Container> +void testMultimapInsert() +{ + typedef typename Container::value_type ValueTp; + typedef Container C; + ConstructController* cc = getConstructController(); + cc->reset(); + { + CHECKPOINT("Testing C::insert(const value_type&)"); + Container c; + const ValueTp v(42, 1); + cc->expect<const ValueTp&>(); + c.insert(v); + assert(!cc->unchecked()); + } + { + CHECKPOINT("Testing C::insert(value_type&)"); + Container c; + ValueTp v(42, 1); + cc->expect<ValueTp&>(); + c.insert(v); + assert(!cc->unchecked()); + } + { + CHECKPOINT("Testing C::insert(value_type&&)"); + Container c; + ValueTp v(42, 1); + cc->expect<ValueTp&&>(); + c.insert(std::move(v)); + assert(!cc->unchecked()); + } + { + CHECKPOINT("Testing C::insert({key, value})"); + Container c; + cc->expect<ValueTp&&>(); + c.insert({42, 1}); + assert(!cc->unchecked()); + } + { + CHECKPOINT("Testing C::insert(std::initializer_list<ValueTp>)"); + Container c; + std::initializer_list<ValueTp> il = { ValueTp(1, 1), ValueTp(2, 1) }; + cc->expect<ValueTp const&>(2); + c.insert(il); + assert(!cc->unchecked()); + } + { + CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type const&"); + Container c; + const ValueTp ValueList[] = { ValueTp(1, 1), ValueTp(2, 1), ValueTp(3, 1) }; + cc->expect<ValueTp const&>(3); + c.insert(std::begin(ValueList), std::end(ValueList)); + assert(!cc->unchecked()); + } + { + CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&&"); + Container c; + ValueTp ValueList[] = { ValueTp(1, 1), ValueTp(2, 1) , ValueTp(3, 1) }; + cc->expect<ValueTp&&>(3); + c.insert(std::move_iterator<ValueTp*>(std::begin(ValueList)), + std::move_iterator<ValueTp*>(std::end(ValueList))); + assert(!cc->unchecked()); + } + { + CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&"); + Container c; + ValueTp ValueList[] = { ValueTp(1, 1), ValueTp(2, 1) , ValueTp(3, 1) }; + cc->expect<ValueTp&>(3); + c.insert(std::begin(ValueList), std::end(ValueList)); + assert(!cc->unchecked()); + } +} + + +template <class Container> +void testMultimapInsertHint() +{ + typedef typename Container::value_type ValueTp; + typedef Container C; + ConstructController* cc = getConstructController(); + cc->reset(); + { + CHECKPOINT("Testing C::insert(p, const value_type&)"); + Container c; + const ValueTp v(42, 1); + cc->expect<const ValueTp&>(); + c.insert(c.begin(), v); + assert(!cc->unchecked()); + } + { + CHECKPOINT("Testing C::insert(p, value_type&)"); + Container c; + ValueTp v(42, 1); + cc->expect<ValueTp&>(); + c.insert(c.begin(), v); + assert(!cc->unchecked()); + } + { + CHECKPOINT("Testing C::insert(p, value_type&&)"); + Container c; + ValueTp v(42, 1); + cc->expect<ValueTp&&>(); + c.insert(c.begin(), std::move(v)); + assert(!cc->unchecked()); + } + { + CHECKPOINT("Testing C::insert(p, {key, value})"); + Container c; + cc->expect<ValueTp&&>(); + c.insert(c.begin(), {42, 1}); + assert(!cc->unchecked()); + } +} + +#endif diff --git a/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp b/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp index 5e429adb6fc9..64ea75a40064 100644 --- a/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp +++ b/test/std/containers/sequences/array/array.cons/initializer_list.pass.cpp @@ -35,4 +35,18 @@ int main() C c = {}; assert(c.size() == 0); } + + { + typedef double T; + typedef std::array<T, 3> C; + C c = {1}; + assert(c.size() == 3.0); + assert(c[0] == 1); + } + { + typedef int T; + typedef std::array<T, 1> C; + C c = {}; + assert(c.size() == 1); + } } diff --git a/test/std/containers/sequences/array/array.special/swap.pass.cpp b/test/std/containers/sequences/array/array.special/swap.pass.cpp index c1b0b235ab34..413f291a2a36 100644 --- a/test/std/containers/sequences/array/array.special/swap.pass.cpp +++ b/test/std/containers/sequences/array/array.special/swap.pass.cpp @@ -14,10 +14,28 @@ #include <array> #include <cassert> +#include "test_macros.h" // std::array is explicitly allowed to be initialized with A a = { init-list };. // Disable the missing braces warning for this reason. #include "disable_missing_braces_warning.h" +struct NonSwappable { + NonSwappable() {} +private: + NonSwappable(NonSwappable const&); + NonSwappable& operator=(NonSwappable const&); +}; + +template <class Tp> +decltype(swap(std::declval<Tp>(), std::declval<Tp>())) +can_swap_imp(int); + +template <class Tp> +std::false_type can_swap_imp(...); + +template <class Tp> +struct can_swap : std::is_same<decltype(can_swap_imp<Tp>(0)), void> {}; + int main() { { @@ -44,4 +62,24 @@ int main() assert(c1.size() == 0); assert(c2.size() == 0); } + { + typedef NonSwappable T; + typedef std::array<T, 0> C0; + static_assert(can_swap<C0&>::value, ""); + C0 l = {}; + C0 r = {}; + swap(l, r); +#if TEST_STD_VER >= 11 + static_assert(noexcept(swap(l, r)), ""); +#endif + } +#if TEST_STD_VER >= 11 + { + // NonSwappable is still considered swappable in C++03 because there + // is no access control SFINAE. + typedef NonSwappable T; + typedef std::array<T, 42> C1; + static_assert(!can_swap<C1&>::value, ""); + } +#endif } diff --git a/test/std/containers/sequences/array/array.swap/swap.pass.cpp b/test/std/containers/sequences/array/array.swap/swap.pass.cpp index 651798e1e790..8d01dbf959ce 100644 --- a/test/std/containers/sequences/array/array.swap/swap.pass.cpp +++ b/test/std/containers/sequences/array/array.swap/swap.pass.cpp @@ -10,14 +10,24 @@ // <array> // void swap(array& a); +// namespace std { void swap(array<T, N> &x, array<T, N> &y); -#include <array> #include <cassert> +#include <array> + +#include "test_macros.h" // std::array is explicitly allowed to be initialized with A a = { init-list };. // Disable the missing braces warning for this reason. #include "disable_missing_braces_warning.h" +struct NonSwappable { + NonSwappable() {} +private: + NonSwappable(NonSwappable const&); + NonSwappable& operator=(NonSwappable const&); +}; + int main() { { @@ -37,6 +47,22 @@ int main() } { typedef double T; + typedef std::array<T, 3> C; + C c1 = {1, 2, 3.5}; + C c2 = {4, 5, 6.5}; + std::swap(c1, c2); + assert(c1.size() == 3); + assert(c1[0] == 4); + assert(c1[1] == 5); + assert(c1[2] == 6.5); + assert(c2.size() == 3); + assert(c2[0] == 1); + assert(c2[1] == 2); + assert(c2[2] == 3.5); + } + + { + typedef double T; typedef std::array<T, 0> C; C c1 = {}; C c2 = {}; @@ -44,4 +70,24 @@ int main() assert(c1.size() == 0); assert(c2.size() == 0); } + { + typedef double T; + typedef std::array<T, 0> C; + C c1 = {}; + C c2 = {}; + std::swap(c1, c2); + assert(c1.size() == 0); + assert(c2.size() == 0); + } + { + typedef NonSwappable T; + typedef std::array<T, 0> C0; + C0 l = {}; + C0 r = {}; + l.swap(r); +#if TEST_STD_VER >= 11 + static_assert(noexcept(l.swap(r)), ""); +#endif + } + } diff --git a/test/std/containers/sequences/array/at.pass.cpp b/test/std/containers/sequences/array/at.pass.cpp index 5cb89dfeeb9a..9707beeb3946 100644 --- a/test/std/containers/sequences/array/at.pass.cpp +++ b/test/std/containers/sequences/array/at.pass.cpp @@ -49,14 +49,14 @@ int main() const C c = {1, 2, 3.5}; C::const_reference r1 = c.at(0); assert(r1 == 1); - + C::const_reference r2 = c.at(2); assert(r2 == 3.5); try { (void) c.at(3); } catch (const std::out_of_range &) {} } - + #if TEST_STD_VER > 11 { typedef double T; diff --git a/test/std/containers/sequences/array/front_back.pass.cpp b/test/std/containers/sequences/array/front_back.pass.cpp index bccaade986ea..7d53b8265e96 100644 --- a/test/std/containers/sequences/array/front_back.pass.cpp +++ b/test/std/containers/sequences/array/front_back.pass.cpp @@ -34,7 +34,7 @@ int main() assert(r1 == 1); r1 = 5.5; assert(c[0] == 5.5); - + C::reference r2 = c.back(); assert(r2 == 3.5); r2 = 7.5; diff --git a/test/std/containers/sequences/array/indexing.pass.cpp b/test/std/containers/sequences/array/indexing.pass.cpp index 5ccb0b487b95..64d2716a7592 100644 --- a/test/std/containers/sequences/array/indexing.pass.cpp +++ b/test/std/containers/sequences/array/indexing.pass.cpp @@ -33,7 +33,7 @@ int main() assert(r1 == 1); r1 = 5.5; assert(c.front() == 5.5); - + C::reference r2 = c[2]; assert(r2 == 3.5); r2 = 7.5; diff --git a/test/std/containers/sequences/array/iterators.pass.cpp b/test/std/containers/sequences/array/iterators.pass.cpp index 98997d8c26d5..233e9328c4ed 100644 --- a/test/std/containers/sequences/array/iterators.pass.cpp +++ b/test/std/containers/sequences/array/iterators.pass.cpp @@ -59,7 +59,7 @@ int main() assert ( c.cend() == std::cend(c)); assert ( c.rend() == std::rend(c)); assert ( c.crend() == std::crend(c)); - + assert ( std::begin(c) != std::end(c)); assert ( std::rbegin(c) != std::rend(c)); assert ( std::cbegin(c) != std::cend(c)); diff --git a/test/std/containers/sequences/array/types.pass.cpp b/test/std/containers/sequences/array/types.pass.cpp index 065ade959d05..9cf390c4eacb 100644 --- a/test/std/containers/sequences/array/types.pass.cpp +++ b/test/std/containers/sequences/array/types.pass.cpp @@ -29,6 +29,25 @@ #include <iterator> #include <type_traits> +#include "test_macros.h" + +template <class C> +void test_iterators() { + typedef std::iterator_traits<typename C::iterator> ItT; + typedef std::iterator_traits<typename C::const_iterator> CItT; + static_assert((std::is_same<typename ItT::iterator_category, std::random_access_iterator_tag>::value), ""); + static_assert((std::is_same<typename ItT::value_type, typename C::value_type>::value), ""); + static_assert((std::is_same<typename ItT::reference, typename C::reference>::value), ""); + static_assert((std::is_same<typename ItT::pointer, typename C::pointer>::value), ""); + static_assert((std::is_same<typename ItT::difference_type, typename C::difference_type>::value), ""); + + static_assert((std::is_same<typename CItT::iterator_category, std::random_access_iterator_tag>::value), ""); + static_assert((std::is_same<typename CItT::value_type, typename C::value_type>::value), ""); + static_assert((std::is_same<typename CItT::reference, typename C::const_reference>::value), ""); + static_assert((std::is_same<typename CItT::pointer, typename C::const_pointer>::value), ""); + static_assert((std::is_same<typename CItT::difference_type, typename C::difference_type>::value), ""); +} + int main() { { @@ -36,27 +55,43 @@ int main() typedef std::array<T, 10> C; static_assert((std::is_same<C::reference, T&>::value), ""); static_assert((std::is_same<C::const_reference, const T&>::value), ""); - static_assert((std::is_same<C::iterator, T*>::value), ""); - static_assert((std::is_same<C::const_iterator, const T*>::value), ""); + LIBCPP_STATIC_ASSERT((std::is_same<C::iterator, T*>::value), ""); + LIBCPP_STATIC_ASSERT((std::is_same<C::const_iterator, const T*>::value), ""); + test_iterators<C>(); static_assert((std::is_same<C::pointer, T*>::value), ""); static_assert((std::is_same<C::const_pointer, const T*>::value), ""); static_assert((std::is_same<C::size_type, std::size_t>::value), ""); static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), ""); static_assert((std::is_same<C::reverse_iterator, std::reverse_iterator<C::iterator> >::value), ""); static_assert((std::is_same<C::const_reverse_iterator, std::reverse_iterator<C::const_iterator> >::value), ""); + + static_assert((std::is_signed<typename C::difference_type>::value), ""); + static_assert((std::is_unsigned<typename C::size_type>::value), ""); + static_assert((std::is_same<typename C::difference_type, + typename std::iterator_traits<typename C::iterator>::difference_type>::value), ""); + static_assert((std::is_same<typename C::difference_type, + typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), ""); } { typedef int* T; typedef std::array<T, 0> C; static_assert((std::is_same<C::reference, T&>::value), ""); static_assert((std::is_same<C::const_reference, const T&>::value), ""); - static_assert((std::is_same<C::iterator, T*>::value), ""); - static_assert((std::is_same<C::const_iterator, const T*>::value), ""); + LIBCPP_STATIC_ASSERT((std::is_same<C::iterator, T*>::value), ""); + LIBCPP_STATIC_ASSERT((std::is_same<C::const_iterator, const T*>::value), ""); + test_iterators<C>(); static_assert((std::is_same<C::pointer, T*>::value), ""); static_assert((std::is_same<C::const_pointer, const T*>::value), ""); static_assert((std::is_same<C::size_type, std::size_t>::value), ""); static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), ""); static_assert((std::is_same<C::reverse_iterator, std::reverse_iterator<C::iterator> >::value), ""); static_assert((std::is_same<C::const_reverse_iterator, std::reverse_iterator<C::const_iterator> >::value), ""); + + static_assert((std::is_signed<typename C::difference_type>::value), ""); + static_assert((std::is_unsigned<typename C::size_type>::value), ""); + static_assert((std::is_same<typename C::difference_type, + typename std::iterator_traits<typename C::iterator>::difference_type>::value), ""); + static_assert((std::is_same<typename C::difference_type, + typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), ""); } } diff --git a/test/std/containers/sequences/array/version.pass.cpp b/test/std/containers/sequences/array/version.pass.cpp deleted file mode 100644 index b89a8dd8cca3..000000000000 --- a/test/std/containers/sequences/array/version.pass.cpp +++ /dev/null @@ -1,20 +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. -// -//===----------------------------------------------------------------------===// - -// <array> - -#include <array> - -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif - -int main() -{ -} diff --git a/test/std/containers/sequences/deque/deque.capacity/access.pass.cpp b/test/std/containers/sequences/deque/deque.capacity/access.pass.cpp index 996fc9a18fe7..a6a8e7424b25 100644 --- a/test/std/containers/sequences/deque/deque.capacity/access.pass.cpp +++ b/test/std/containers/sequences/deque/deque.capacity/access.pass.cpp @@ -68,7 +68,7 @@ int main() assert(c.front() == 0); assert(c.back() == 9); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::deque<int, min_allocator<int>> c = make<std::deque<int, min_allocator<int>> >(10); for (unsigned i = 0; i < 10; ++i) diff --git a/test/std/containers/sequences/deque/deque.capacity/resize_size.pass.cpp b/test/std/containers/sequences/deque/deque.capacity/resize_size.pass.cpp index 84f04f9d52da..53c6bd3380a2 100644 --- a/test/std/containers/sequences/deque/deque.capacity/resize_size.pass.cpp +++ b/test/std/containers/sequences/deque/deque.capacity/resize_size.pass.cpp @@ -12,6 +12,8 @@ // void resize(size_type n); #include <deque> +#include <algorithm> +#include <iterator> #include <cassert> #include "test_macros.h" diff --git a/test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp b/test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp index 2bf2423fb9af..12af64386bd8 100644 --- a/test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp +++ b/test/std/containers/sequences/deque/deque.capacity/resize_size_value.pass.cpp @@ -12,6 +12,8 @@ // void resize(size_type n, const value_type& v); #include <deque> +#include <algorithm> +#include <iterator> #include <cassert> #include "test_macros.h" diff --git a/test/std/containers/sequences/deque/deque.cons/alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/alloc.pass.cpp index 841bfd9f8a7f..787c2394b38e 100644 --- a/test/std/containers/sequences/deque/deque.cons/alloc.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/alloc.pass.cpp @@ -31,7 +31,7 @@ int main() { test<int>(std::allocator<int>()); test<NotConstructible>(test_allocator<NotConstructible>(3)); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 test<int>(min_allocator<int>()); test<NotConstructible>(min_allocator<NotConstructible>{}); #endif diff --git a/test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp b/test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp index c760b4372444..dea6492a515d 100644 --- a/test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/assign_initializer_list.pass.cpp @@ -28,7 +28,7 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::deque<int, min_allocator<int>> d; d.assign({3, 4, 5, 6}); diff --git a/test/std/containers/sequences/deque/deque.cons/copy.pass.cpp b/test/std/containers/sequences/deque/deque.cons/copy.pass.cpp index fa0c1203ede9..ec73555b9c4f 100644 --- a/test/std/containers/sequences/deque/deque.cons/copy.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/copy.pass.cpp @@ -45,7 +45,7 @@ int main() assert(v2.get_allocator() == other_allocator<int>(-2)); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; int* an = ab + sizeof(ab)/sizeof(ab[0]); diff --git a/test/std/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp index efea4948eba1..3a49a8bc0c66 100644 --- a/test/std/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/copy_alloc.pass.cpp @@ -40,7 +40,7 @@ int main() test(std::deque<int, other_allocator<int> >(ab, an, other_allocator<int>(3)), other_allocator<int>(4)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; int* an = ab + sizeof(ab)/sizeof(ab[0]); diff --git a/test/std/containers/sequences/deque/deque.cons/default.pass.cpp b/test/std/containers/sequences/deque/deque.cons/default.pass.cpp index b725dade70b2..7c42d9e7786e 100644 --- a/test/std/containers/sequences/deque/deque.cons/default.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/default.pass.cpp @@ -24,7 +24,7 @@ test() { std::deque<T, Allocator> d; assert(d.size() == 0); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 std::deque<T, Allocator> d1 = {}; assert(d1.size() == 0); #endif @@ -34,7 +34,7 @@ int main() { test<int, std::allocator<int> >(); test<NotConstructible, stack_allocator<NotConstructible, 1> >(); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 test<int, min_allocator<int> >(); test<NotConstructible, min_allocator<NotConstructible> >(); #endif diff --git a/test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp index c612dbc5e838..30cca929da11 100644 --- a/test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/default_noexcept.pass.cpp @@ -14,9 +14,12 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <deque> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -29,14 +32,13 @@ struct some_alloc int main() { -#if __has_feature(cxx_noexcept) { typedef std::deque<MoveOnly> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::deque<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::deque<MoveOnly, other_allocator<MoveOnly>> C; @@ -46,5 +48,4 @@ int main() typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp index ecdc2404c855..503e1237e9eb 100644 --- a/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/dtor_noexcept.pass.cpp @@ -11,14 +11,14 @@ // ~deque() // implied noexcept; +// UNSUPPORTED: c++98, c++03 + #include <deque> #include <cassert> #include "MoveOnly.h" #include "test_allocator.h" -#if __has_feature(cxx_noexcept) - template <class T> struct some_alloc { @@ -27,11 +27,8 @@ struct some_alloc ~some_alloc() noexcept(false); }; -#endif - int main() { -#if __has_feature(cxx_noexcept) { typedef std::deque<MoveOnly> C; static_assert(std::is_nothrow_destructible<C>::value, ""); @@ -48,5 +45,4 @@ int main() typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_destructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp b/test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp index a9e0218e2e0b..dbf27053a9f9 100644 --- a/test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/initializer_list.pass.cpp @@ -27,7 +27,7 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::deque<int, min_allocator<int>> d = {3, 4, 5, 6}; assert(d.size() == 4); diff --git a/test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp index 36c5af60ee34..9be3c63a6b31 100644 --- a/test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/initializer_list_alloc.pass.cpp @@ -29,7 +29,7 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::deque<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>()); assert(d.get_allocator() == min_allocator<int>()); diff --git a/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp b/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp index faadf2b1a1db..12a7faf686db 100644 --- a/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/iter_iter.pass.cpp @@ -56,7 +56,7 @@ int main() test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an)); test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an)); test<stack_allocator<int, 4096> >(ab, an); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 test<min_allocator<int> >(ab, an); #endif } diff --git a/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp index b8c3e889929d..c8f7759a19d6 100644 --- a/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/iter_iter_alloc.pass.cpp @@ -42,7 +42,7 @@ int main() test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an), test_allocator<int>(4)); test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), test_allocator<int>(5)); test(random_access_iterator<const int*>(ab), random_access_iterator<const int*>(an), test_allocator<int>(6)); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 test(input_iterator<const int*>(ab), input_iterator<const int*>(an), min_allocator<int>()); test(forward_iterator<const int*>(ab), forward_iterator<const int*>(an), min_allocator<int>()); test(bidirectional_iterator<const int*>(ab), bidirectional_iterator<const int*>(an), min_allocator<int>()); diff --git a/test/std/containers/sequences/deque/deque.cons/move.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move.pass.cpp index 4a7aa8a058eb..68875139da1a 100644 --- a/test/std/containers/sequences/deque/deque.cons/move.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/move.pass.cpp @@ -51,7 +51,7 @@ int main() assert(c1.size() == 0); assert(c3.get_allocator() == c1.get_allocator()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; int* an = ab + sizeof(ab)/sizeof(ab[0]); diff --git a/test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp index 1a5db6db6500..4aa0fa6827e7 100644 --- a/test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/move_alloc.pass.cpp @@ -66,7 +66,7 @@ int main() assert(c3.get_allocator() == A(3)); assert(c1.size() != 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; int* an = ab + sizeof(ab)/sizeof(ab[0]); diff --git a/test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp index e50cd8ed508d..ed8f1544bc8f 100644 --- a/test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/move_assign.pass.cpp @@ -69,7 +69,7 @@ int main() assert(c1.size() == 0); assert(c3.get_allocator() == A(5)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; int* an = ab + sizeof(ab)/sizeof(ab[0]); diff --git a/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp index 24180b5b5bdd..cebf76a15a4a 100644 --- a/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/move_assign_noexcept.pass.cpp @@ -16,6 +16,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <deque> #include <cassert> @@ -31,7 +33,6 @@ struct some_alloc int main() { -#if __has_feature(cxx_noexcept) { typedef std::deque<MoveOnly> C; static_assert(std::is_nothrow_move_assignable<C>::value, ""); @@ -48,5 +49,4 @@ int main() typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } -#endif } diff --git a/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp index 0ea0431be8e2..f53e1ba6c807 100644 --- a/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/move_noexcept.pass.cpp @@ -14,6 +14,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <deque> #include <cassert> @@ -29,7 +31,6 @@ struct some_alloc int main() { -#if __has_feature(cxx_noexcept) { typedef std::deque<MoveOnly> C; static_assert(std::is_nothrow_move_constructible<C>::value, ""); @@ -46,5 +47,4 @@ int main() typedef std::deque<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/sequences/deque/deque.cons/op_equal.pass.cpp b/test/std/containers/sequences/deque/deque.cons/op_equal.pass.cpp index 3a6ec8370b84..6aac6b20c49e 100644 --- a/test/std/containers/sequences/deque/deque.cons/op_equal.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/op_equal.pass.cpp @@ -46,7 +46,7 @@ int main() assert(l2 == l); assert(l2.get_allocator() == other_allocator<int>(5)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int ab[] = {3, 4, 2, 8, 0, 1, 44, 34, 45, 96, 80, 1, 13, 31, 45}; int* an = ab + sizeof(ab)/sizeof(ab[0]); diff --git a/test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp b/test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp index 6468e4329bda..597f642db3ce 100644 --- a/test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/op_equal_initializer_list.pass.cpp @@ -28,7 +28,7 @@ int main() assert(d[2] == 5); assert(d[3] == 6); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::deque<int, min_allocator<int>> d; d = {3, 4, 5, 6}; diff --git a/test/std/containers/sequences/deque/deque.cons/size.pass.cpp b/test/std/containers/sequences/deque/deque.cons/size.pass.cpp index d2e324b0e3f5..b3fccf6671c9 100644 --- a/test/std/containers/sequences/deque/deque.cons/size.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/size.pass.cpp @@ -100,7 +100,7 @@ int main() test1<DefaultOnly, stack_allocator<DefaultOnly, 4096> >(4095); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 test<DefaultOnly, min_allocator<DefaultOnly> >(4095); #endif diff --git a/test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp b/test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp index 859deba1e1ae..aeda168d19d4 100644 --- a/test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/size_value.pass.cpp @@ -45,7 +45,7 @@ int main() test<int, std::allocator<int> >(4096, 1165); test<int, std::allocator<int> >(4097, 157); test<int, stack_allocator<int, 4096> >(4095, 90); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 test<int, min_allocator<int> >(4095, 90); #endif } diff --git a/test/std/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp b/test/std/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp index 5693be702de7..ed8a7e13baa5 100644 --- a/test/std/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp +++ b/test/std/containers/sequences/deque/deque.cons/size_value_alloc.pass.cpp @@ -47,7 +47,7 @@ int main() test(4096, 1165, a); test(4097, 157, a); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { min_allocator<int> a; test(0, 5, a); diff --git a/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp index cf717c2e2f27..784b3a38553a 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/emplace_back.pass.cpp @@ -16,6 +16,7 @@ #include "../../../Emplaceable.h" #include "min_allocator.h" +#include "test_allocator.h" #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -74,7 +75,7 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<Emplaceable> >(rng[i], rng[j]); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); @@ -82,6 +83,17 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<Emplaceable, min_allocator<Emplaceable>> >(rng[i], rng[j]); } + { + std::deque<Tag_X, TaggingAllocator<Tag_X>> c; + c.emplace_back(); + assert(c.size() == 1); + c.emplace_back(1, 2, 3); + assert(c.size() == 2); + c.emplace_front(); + assert(c.size() == 3); + c.emplace_front(1, 2, 3); + assert(c.size() == 4); + } #endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp index becf94ffb4ef..afc0e4972e38 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/emplace_front.pass.cpp @@ -74,7 +74,7 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<Emplaceable> >(rng[i], rng[j]); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.modifiers/erase_iter.invalidation.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/erase_iter.invalidation.pass.cpp index 49465cddaef7..a7a93571f509 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/erase_iter.invalidation.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/erase_iter.invalidation.pass.cpp @@ -23,9 +23,9 @@ void del_at_start(C c) typename C::iterator first = c.begin(); typename C::iterator it1 = first + 1; typename C::iterator it2 = c.end() - 1; - + c.erase (first); - + typename C::iterator it3 = c.begin(); typename C::iterator it4 = c.end() - 1; assert( it1 == it3); @@ -42,7 +42,7 @@ void del_at_end(C c) typename C::iterator first = c.end() - 1; typename C::iterator it1 = c.begin(); typename C::iterator it2 = first - 1; - + c.erase (first); typename C::iterator it3 = c.begin(); @@ -60,7 +60,7 @@ int main() std::deque<int> queue; for (int i = 0; i < 20; ++i) queue.push_back(i); - + while (queue.size() > 1) { del_at_start(queue); diff --git a/test/std/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp index a45b75d25c9c..116ed9aa4b5a 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/erase_iter.pass.cpp @@ -12,6 +12,8 @@ // iterator erase(const_iterator p) #include <deque> +#include <algorithm> +#include <iterator> #include <cassert> #include "min_allocator.h" @@ -78,7 +80,7 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<int> >(rng[i], rng[j]); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.invalidation.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.invalidation.pass.cpp index c785e264db06..a0ccd200bfb7 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.invalidation.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.invalidation.pass.cpp @@ -26,9 +26,9 @@ void del_at_start(C c, size_t num) typename C::iterator last = first + num; typename C::iterator it1 = last; typename C::iterator it2 = c.end() - 1; - + c.erase (first, last); - + typename C::iterator it3 = c.begin(); typename C::iterator it4 = c.end() - 1; assert( it1 == it3); @@ -38,7 +38,7 @@ void del_at_start(C c, size_t num) assert( *it2 == *it4); assert(&*it2 == &*it4); } - + template <typename C> void del_at_end(C c, size_t num) { @@ -46,7 +46,7 @@ void del_at_end(C c, size_t num) typename C::iterator first = last - num; typename C::iterator it1 = c.begin(); typename C::iterator it2 = first - 1; - + c.erase (first, last); typename C::iterator it3 = c.begin(); diff --git a/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp index 0576aca5c1a8..a53abaf85d33 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/erase_iter_iter.pass.cpp @@ -14,6 +14,8 @@ // iterator erase(const_iterator f, const_iterator l) #include <deque> +#include <algorithm> +#include <iterator> #include <cassert> #include "min_allocator.h" @@ -84,7 +86,7 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<int> >(rng[i], rng[j]); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.modifiers/pop_back.invalidation.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/pop_back.invalidation.pass.cpp index 1d84f73ccb56..0f5f8e67a24b 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/pop_back.invalidation.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/pop_back.invalidation.pass.cpp @@ -22,9 +22,9 @@ void test(C c) { typename C::iterator it1 = c.begin(); typename C::iterator it2 = c.end() - 2; - + c.pop_back(); - + typename C::iterator it3 = c.begin(); typename C::iterator it4 = c.end() - 1; assert( it1 == it3); @@ -40,7 +40,7 @@ int main() std::deque<int> queue; for (int i = 0; i < 20; ++i) queue.push_back(i); - + while (queue.size() > 1) { test(queue); diff --git a/test/std/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp index b345faaf89e9..aeb62c9d996a 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/pop_back.pass.cpp @@ -72,7 +72,7 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<int> >(rng[i], rng[j]); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.modifiers/pop_front.invalidation.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/pop_front.invalidation.pass.cpp index 78317f3a3f9c..d7fd910cca5f 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/pop_front.invalidation.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/pop_front.invalidation.pass.cpp @@ -22,9 +22,9 @@ void test(C c) { typename C::iterator it1 = c.begin() + 1; typename C::iterator it2 = c.end() - 1; - + c.pop_front(); - + typename C::iterator it3 = c.begin(); typename C::iterator it4 = c.end() - 1; assert( it1 == it3); @@ -40,7 +40,7 @@ int main() std::deque<int> queue; for (int i = 0; i < 20; ++i) queue.push_back(i); - + while (queue.size() > 1) { test(queue); diff --git a/test/std/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp index d570ec333715..c7a3a625eab6 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/pop_front.pass.cpp @@ -72,7 +72,7 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<int> >(rng[i], rng[j]); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_back.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_back.pass.cpp index 96df6097d994..198cbcf67cc7 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/push_back.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/push_back.pass.cpp @@ -62,7 +62,7 @@ int main() for (int j = 0; j < N; ++j) test<std::deque<int> >(rng[j]); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp index b37e961e442f..1fe1da102f37 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/push_back_exception_safety.pass.cpp @@ -26,11 +26,11 @@ class CMyClass { bool equal(const CMyClass &rhs) const { return fTag == rhs.fTag && fMagicValue == rhs.fMagicValue; } - + private: int fMagicValue; int fTag; - + private: static int kStartedConstructionMagicValue; private: static int kFinishedConstructionMagicValue; }; @@ -84,7 +84,7 @@ int main() assert(vec==vec2); } } - + { typedef std::deque<CMyClass, test_allocator<CMyClass> > C; C vec; diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp index d4ab0d3e2f26..b5c881064a95 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/push_back_rvalue.pass.cpp @@ -68,7 +68,7 @@ int main() for (int j = 0; j < N; ++j) test<std::deque<MoveOnly> >(rng[j]); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2046, 2047, 2048, 2049, 4094, 4095, 4096}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_front.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_front.pass.cpp index 4d6443b1f967..ee4f3d7f9ed7 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/push_front.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/push_front.pass.cpp @@ -71,7 +71,7 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<int> >(rng[i], rng[j]); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp index b4caa947aed8..7464870f07e1 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/push_front_exception_safety.pass.cpp @@ -30,7 +30,7 @@ class CMyClass { private: int fMagicValue; int fTag; - + private: static int kStartedConstructionMagicValue; private: static int kFinishedConstructionMagicValue; }; @@ -84,7 +84,7 @@ int main() assert(vec==vec2); } } - + { typedef std::deque<CMyClass, test_allocator<CMyClass> > C; C vec; diff --git a/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp b/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp index ea91ec1b0a44..ab15ca3326bf 100644 --- a/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp +++ b/test/std/containers/sequences/deque/deque.modifiers/push_front_rvalue.pass.cpp @@ -77,7 +77,7 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<MoveOnly> >(rng[i], rng[j]); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.special/copy.pass.cpp b/test/std/containers/sequences/deque/deque.special/copy.pass.cpp index 3a9962b330a4..846d87c6b664 100644 --- a/test/std/containers/sequences/deque/deque.special/copy.pass.cpp +++ b/test/std/containers/sequences/deque/deque.special/copy.pass.cpp @@ -76,7 +76,7 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<int> >(rng[i], rng[j]); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.special/copy_backward.pass.cpp b/test/std/containers/sequences/deque/deque.special/copy_backward.pass.cpp index ccb30a9997d8..e7f37f98d270 100644 --- a/test/std/containers/sequences/deque/deque.special/copy_backward.pass.cpp +++ b/test/std/containers/sequences/deque/deque.special/copy_backward.pass.cpp @@ -75,7 +75,7 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<int> >(rng[i], rng[j]); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.special/move.pass.cpp b/test/std/containers/sequences/deque/deque.special/move.pass.cpp index abd8e079975a..1bdbeaf9d5c6 100644 --- a/test/std/containers/sequences/deque/deque.special/move.pass.cpp +++ b/test/std/containers/sequences/deque/deque.special/move.pass.cpp @@ -75,7 +75,7 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<int> >(rng[i], rng[j]); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.special/move_backward.pass.cpp b/test/std/containers/sequences/deque/deque.special/move_backward.pass.cpp index ea04f6a15acf..8e909c63c912 100644 --- a/test/std/containers/sequences/deque/deque.special/move_backward.pass.cpp +++ b/test/std/containers/sequences/deque/deque.special/move_backward.pass.cpp @@ -75,7 +75,7 @@ int main() for (int j = 0; j < N; ++j) testN<std::deque<int> >(rng[i], rng[j]); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.special/swap.pass.cpp b/test/std/containers/sequences/deque/deque.special/swap.pass.cpp index 26757c351f1a..ab21f434937e 100644 --- a/test/std/containers/sequences/deque/deque.special/swap.pass.cpp +++ b/test/std/containers/sequences/deque/deque.special/swap.pass.cpp @@ -85,7 +85,7 @@ int main() assert((c2 == std::deque<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0])))); assert(c2.get_allocator() == A(1)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int rng[] = {0, 1, 2, 3, 1023, 1024, 1025, 2047, 2048, 2049}; const int N = sizeof(rng)/sizeof(rng[0]); diff --git a/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp b/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp index 83bcac8997ed..2f999e9a7a5d 100644 --- a/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/deque/deque.special/swap_noexcept.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <deque> // void swap(deque& c) @@ -21,6 +23,7 @@ #include <deque> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -28,7 +31,7 @@ template <class T> struct some_alloc { typedef T value_type; - + some_alloc() {} some_alloc(const some_alloc&); void deallocate(void*, unsigned) {} @@ -40,7 +43,7 @@ template <class T> struct some_alloc2 { typedef T value_type; - + some_alloc2() {} some_alloc2(const some_alloc2&); void deallocate(void*, unsigned) {} @@ -51,7 +54,6 @@ struct some_alloc2 int main() { -#if __has_feature(cxx_noexcept) { typedef std::deque<MoveOnly> C; C c1, c2; @@ -86,5 +88,4 @@ int main() } #endif -#endif } diff --git a/test/std/containers/sequences/deque/iterators.pass.cpp b/test/std/containers/sequences/deque/iterators.pass.cpp index 8ec491fae4da..19d7996f824f 100644 --- a/test/std/containers/sequences/deque/iterators.pass.cpp +++ b/test/std/containers/sequences/deque/iterators.pass.cpp @@ -33,7 +33,7 @@ int main() j = c.cbegin(); assert(i == j); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::deque<int, min_allocator<int>> C; C c; @@ -68,7 +68,7 @@ int main() assert ( (cii >= ii1 )); assert (cii - ii1 == 0); assert (ii1 - cii == 0); - + // std::deque<int> c; // assert ( ii1 != c.cbegin()); // assert ( cii != c.begin()); diff --git a/test/std/containers/sequences/deque/types.pass.cpp b/test/std/containers/sequences/deque/types.pass.cpp index da9470d8a6c6..53b33d9e6be9 100644 --- a/test/std/containers/sequences/deque/types.pass.cpp +++ b/test/std/containers/sequences/deque/types.pass.cpp @@ -64,6 +64,12 @@ test() static_assert((std::is_same< typename C::const_reverse_iterator, std::reverse_iterator<typename C::const_iterator> >::value), ""); + static_assert((std::is_signed<typename C::difference_type>::value), ""); + static_assert((std::is_unsigned<typename C::size_type>::value), ""); + static_assert((std::is_same<typename C::difference_type, + typename std::iterator_traits<typename C::iterator>::difference_type>::value), ""); + static_assert((std::is_same<typename C::difference_type, + typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), ""); } int main() @@ -73,7 +79,8 @@ int main() test<Copyable, test_allocator<Copyable> >(); static_assert((std::is_same<std::deque<char>::allocator_type, std::allocator<char> >::value), ""); -#if __cplusplus >= 201103L + +#if TEST_STD_VER >= 11 { typedef std::deque<short, min_allocator<short>> C; static_assert((std::is_same<C::value_type, short>::value), ""); @@ -85,6 +92,13 @@ int main() // min_allocator doesn't have a size_type, so one gets synthesized static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), ""); static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), ""); + + static_assert((std::is_signed<typename C::difference_type>::value), ""); + static_assert((std::is_unsigned<typename C::size_type>::value), ""); + static_assert((std::is_same<typename C::difference_type, + typename std::iterator_traits<typename C::iterator>::difference_type>::value), ""); + static_assert((std::is_same<typename C::difference_type, + typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), ""); } #endif } diff --git a/test/std/containers/sequences/deque/version.pass.cpp b/test/std/containers/sequences/deque/version.pass.cpp deleted file mode 100644 index 22e663d9bc22..000000000000 --- a/test/std/containers/sequences/deque/version.pass.cpp +++ /dev/null @@ -1,20 +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. -// -//===----------------------------------------------------------------------===// - -// <deque> - -#include <deque> - -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif - -int main() -{ -} diff --git a/test/std/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp index 2ec9b8713326..ae14eda50173 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.access/front.pass.cpp @@ -38,7 +38,7 @@ int main() assert(c.front() == 0); assert(*c.begin() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp index 7aba906ec20d..352945c852d8 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/alloc.pass.cpp @@ -28,7 +28,7 @@ int main() assert(c.get_allocator() == A(12)); assert(c.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef min_allocator<NotConstructible> A; typedef A::value_type T; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp index 0b9263db9899..244054477d56 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_copy.pass.cpp @@ -117,7 +117,7 @@ int main() assert(c1 == c0); assert(c1.get_allocator() == A(10)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef min_allocator<int> A; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp index e0382a10db49..d4dda02b8413 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_init.pass.cpp @@ -42,7 +42,7 @@ int main() assert(*i == 10+n); assert(n == 4); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp index 1532b53e7a83..935284831d07 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_move.pass.cpp @@ -159,7 +159,7 @@ int main() assert(c1.get_allocator() == A(10)); assert(c0.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef MoveOnly T; typedef min_allocator<T> A; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp index 551908fea166..3d35916ccacb 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_op_init.pass.cpp @@ -42,7 +42,7 @@ int main() assert(*i == 10+n); assert(n == 4); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp index 0b348e6920ca..ccefa2df7ce0 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_range.pass.cpp @@ -47,7 +47,7 @@ int main() assert(*i == 10+n); assert(n == 4); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp index ea53e1c37320..1a1610d37c2f 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/assign_size_value.pass.cpp @@ -41,7 +41,7 @@ int main() assert(*i == 10); assert(n == 4); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp index 2fc53bc3a514..5240afa82b80 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/copy.pass.cpp @@ -50,7 +50,7 @@ int main() assert(c.get_allocator() == A(-2)); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef min_allocator<int> A; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp index bcc24e1cc68e..e4b73bb54e9b 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/copy_alloc.pass.cpp @@ -48,7 +48,7 @@ int main() assert(c == c0); assert(c.get_allocator() == A(9)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef min_allocator<int> A; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp index 38e95fad8396..04c4524cf980 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/default.pass.cpp @@ -24,7 +24,7 @@ int main() C c; assert(c.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp index 5167a065a9ad..0ec1f80562a8 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/default_noexcept.pass.cpp @@ -14,9 +14,12 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <forward_list> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -29,14 +32,13 @@ struct some_alloc int main() { -#if __has_feature(cxx_noexcept) { typedef std::forward_list<MoveOnly> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::forward_list<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::forward_list<MoveOnly, other_allocator<MoveOnly>> C; @@ -46,5 +48,4 @@ int main() typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp index da41bf4eb1fc..85d929b4e32e 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/dtor_noexcept.pass.cpp @@ -11,14 +11,14 @@ // ~forward_list() // implied noexcept; +// UNSUPPORTED: c++98, c++03 + #include <forward_list> #include <cassert> #include "MoveOnly.h" #include "test_allocator.h" -#if __has_feature(cxx_noexcept) - template <class T> struct some_alloc { @@ -27,11 +27,8 @@ struct some_alloc ~some_alloc() noexcept(false); }; -#endif - int main() { -#if __has_feature(cxx_noexcept) { typedef std::forward_list<MoveOnly> C; static_assert(std::is_nothrow_destructible<C>::value, ""); @@ -48,5 +45,4 @@ int main() typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_destructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp index 5b31c4dad0a0..c783f60ff4c9 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/init.pass.cpp @@ -28,7 +28,7 @@ int main() assert(*i == n); assert(n == 10); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp index 750486b829f2..ba9984f969b5 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/init_alloc.pass.cpp @@ -31,7 +31,7 @@ int main() assert(n == 10); assert(c.get_allocator() == A(14)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef min_allocator<T> A; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp index 88ecb7540951..a3e204ec28da 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move.pass.cpp @@ -52,7 +52,7 @@ int main() assert(c0.empty()); assert(c.get_allocator() == A(10)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef MoveOnly T; typedef min_allocator<T> A; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp index 3f0e45af1f0b..6a1afe1334b0 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_alloc.pass.cpp @@ -52,7 +52,7 @@ int main() assert(!c0.empty()); assert(c.get_allocator() == A(9)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef MoveOnly T; typedef min_allocator<T> A; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp index 28ce2c12b619..b9a6ef7ab8a8 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_assign_noexcept.pass.cpp @@ -16,6 +16,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <forward_list> #include <cassert> @@ -31,7 +33,6 @@ struct some_alloc int main() { -#if __has_feature(cxx_noexcept) { typedef std::forward_list<MoveOnly> C; static_assert(std::is_nothrow_move_assignable<C>::value, ""); @@ -48,5 +49,4 @@ int main() typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } -#endif } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp index 7b001ea67b19..0359133afc9b 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/move_noexcept.pass.cpp @@ -14,6 +14,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <forward_list> #include <cassert> @@ -29,7 +31,6 @@ struct some_alloc int main() { -#if __has_feature(cxx_noexcept) { typedef std::forward_list<MoveOnly> C; static_assert(std::is_nothrow_move_constructible<C>::value, ""); @@ -46,5 +47,4 @@ int main() typedef std::forward_list<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp index 763952439f00..3c0f2b8403ca 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/range.pass.cpp @@ -32,7 +32,7 @@ int main() assert(*i == n); assert(n == std::end(t) - std::begin(t)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp index d72c3581022d..96a29d24e89c 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/range_alloc.pass.cpp @@ -36,7 +36,7 @@ int main() assert(n == std::end(t) - std::begin(t)); assert(c.get_allocator() == A(13)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef min_allocator<T> A; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp index e02dcb4bf691..736d59936aa3 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/size.pass.cpp @@ -45,7 +45,7 @@ int main() #endif assert(n == N); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef DefaultOnly T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp index 05ab98bb205d..56ce632e0a48 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value.pass.cpp @@ -29,7 +29,7 @@ int main() assert(*i == v); assert(n == N); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp index 1d631ab12ba1..86338a275a55 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.cons/size_value_alloc.pass.cpp @@ -32,7 +32,7 @@ int main() assert(n == N); assert(c.get_allocator() == A(12)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef min_allocator<int> A; typedef A::value_type T; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp index 083cec2886da..c6104e73350b 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.iter/before_begin.pass.cpp @@ -60,7 +60,7 @@ int main() C::const_iterator i = c.before_begin(); assert(std::distance(i, c.end()) == 11); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp index 6f3ac548db8b..925cca4d5e8d 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.iter/iterators.pass.cpp @@ -71,7 +71,7 @@ int main() C::iterator i; C::const_iterator j; } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; @@ -127,7 +127,7 @@ int main() std::forward_list<int>::const_iterator cii{}; assert ( ii1 == ii2 ); assert ( ii1 == ii4 ); - + assert (!(ii1 != ii2 )); assert ( (ii1 == cii )); diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp index 2739b49d8eb2..0e625ac76a02 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/clear.pass.cpp @@ -38,7 +38,7 @@ int main() c.clear(); assert(distance(c.begin(), c.end()) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef NotConstructible T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp index e305c5b6ab52..dd8ea88c2c1a 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_after.pass.cpp @@ -52,7 +52,7 @@ int main() assert(*next(c.begin(), 3) == Emplaceable(2, 3.5)); assert(distance(c.begin(), c.end()) == 4); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef Emplaceable T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp index c02337e0562d..18ed69d33f0b 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/emplace_front.pass.cpp @@ -32,7 +32,7 @@ int main() assert(*next(c.begin()) == Emplaceable()); assert(distance(c.begin(), c.end()) == 2); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef Emplaceable T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp index bd9b15300efa..df859c69a117 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_many.pass.cpp @@ -84,7 +84,7 @@ int main() assert(i == c.end()); assert(distance(c.begin(), c.end()) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp index 4f51498bc651..bf6a88a65406 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/erase_after_one.pass.cpp @@ -55,7 +55,7 @@ int main() assert(i == c.end()); assert(distance(c.begin(), c.end()) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp index ec650b695727..82dca739410f 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_const.pass.cpp @@ -50,7 +50,7 @@ int main() assert(*next(c.begin(), 3) == 2); assert(distance(c.begin(), c.end()) == 4); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp index 4d3018199809..15e1a08b08bf 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_init.pass.cpp @@ -44,7 +44,7 @@ int main() assert(*next(c.begin(), 3) == 1); assert(*next(c.begin(), 4) == 2); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp index 103475f1edab..a41f8dbbfb2b 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_range.pass.cpp @@ -48,7 +48,7 @@ int main() assert(*next(c.begin(), 3) == 1); assert(*next(c.begin(), 4) == 2); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp index f7f376caa090..2e21cc79d269 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_rv.pass.cpp @@ -52,7 +52,7 @@ int main() assert(*next(c.begin(), 3) == 2); assert(distance(c.begin(), c.end()) == 4); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef MoveOnly T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp index b2da2ecd3bbd..f4b7e344112a 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/insert_after_size_value.pass.cpp @@ -43,7 +43,7 @@ int main() assert(*next(c.begin(), 3) == 3); assert(*next(c.begin(), 4) == 3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp index 7f14e54a2e6f..d831ceb28918 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/pop_front.pass.cpp @@ -46,7 +46,7 @@ int main() assert(distance(c.begin(), c.end()) == 0); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp index 85958afc1ce3..4b55a0b1d808 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_const.pass.cpp @@ -30,7 +30,7 @@ int main() assert(*next(c.begin()) == 1); assert(distance(c.begin(), c.end()) == 2); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp index d7c9d758aa03..dfcd2cf90ebc 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/push_front_rv.pass.cpp @@ -32,7 +32,7 @@ int main() assert(*next(c.begin()) == 1); assert(distance(c.begin(), c.end()) == 2); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef MoveOnly T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp index ef7ef82626dc..6337cd779722 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size.pass.cpp @@ -64,7 +64,7 @@ int main() assert(*next(c.begin(), 4) == 0); assert(*next(c.begin(), 5) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef DefaultOnly T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp index d4bd6b4e0111..356e0d657c35 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.modifiers/resize_size_value.pass.cpp @@ -14,9 +14,14 @@ #include <forward_list> #include <cassert> +#include "test_macros.h" #include "DefaultOnly.h" #include "min_allocator.h" +#if TEST_STD_VER >= 11 +#include "container_test_types.h" +#endif + int main() { { @@ -49,7 +54,7 @@ int main() assert(*next(c.begin(), 4) == 10); assert(*next(c.begin(), 5) == 10); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; @@ -80,5 +85,19 @@ int main() assert(*next(c.begin(), 4) == 10); assert(*next(c.begin(), 5) == 10); } + { + // Test that the allocator's construct method is being used to + // construct the new elements and that it's called exactly N times. + typedef int T; + typedef std::forward_list<int, ContainerTestAllocator<int, int>> Container; + ConstructController* cc = getConstructController(); + cc->reset(); + { + Container c; + cc->expect<int const&>(6); + c.resize(6, 42); + assert(!cc->unchecked()); + } + } #endif } diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp index 3b6f853c84cd..a67dd1a4b120 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/merge.pass.cpp @@ -31,7 +31,7 @@ int main() C c3(std::begin(t3), std::end(t3)); assert(c1 == c3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp index 7e873bdddd09..6b4e323bd02d 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/merge_pred.pass.cpp @@ -32,7 +32,7 @@ int main() C c3(std::begin(t3), std::end(t3)); assert(c1 == c3); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp index 18d4cae8cc61..b7607e190bbf 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/remove.pass.cpp @@ -103,7 +103,7 @@ int main() } assert ( it == c.end ()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp index ed408fbd685c..ef6f6a0f1887 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/remove_if.pass.cpp @@ -88,7 +88,7 @@ int main() assert(c1 == c2); assert(cp.count() == std::distance(std::begin(t1), std::end(t1))); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef unary_counting_predicate<bool(*)(T), T> Predicate; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp index 9bf0d03a8855..2876f65d0630 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/reverse.pass.cpp @@ -35,7 +35,7 @@ int main() { for (int i = 0; i < 10; ++i) test<std::forward_list<int> >(i); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 for (int i = 0; i < 10; ++i) test<std::forward_list<int, min_allocator<int>> >(i); #endif diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp index 06e40c595ecb..65512e317cea 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/sort.pass.cpp @@ -40,7 +40,7 @@ int main() { for (int i = 0; i < 40; ++i) test<std::forward_list<int> >(i); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 for (int i = 0; i < 40; ++i) test<std::forward_list<int, min_allocator<int>> >(i); #endif diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp index 8b6ca39b2aab..6e5cce39e67d 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/sort_pred.pass.cpp @@ -41,7 +41,7 @@ int main() { for (int i = 0; i < 40; ++i) test<std::forward_list<int> >(i); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 for (int i = 0; i < 40; ++i) test<std::forward_list<int, min_allocator<int>> >(i); #endif diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp index 51da651970cd..c8d4e2d34f1e 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_flist.pass.cpp @@ -55,7 +55,7 @@ int main() } } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { // splicing different containers typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp index 90a159959632..006869d6db69 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/splice_after_range.pass.cpp @@ -121,7 +121,7 @@ int main() } } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { // splicing different containers typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp index 25db6e64b8a9..e79abb6b6519 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/unique.pass.cpp @@ -67,7 +67,7 @@ int main() c1.unique(); assert(c1 == c2); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp index b7dce20b7092..11228afe83e6 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.ops/unique_pred.pass.cpp @@ -72,7 +72,7 @@ int main() c1.unique(g); assert(c1 == c2); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp index 2b2be7b6c222..e7a8d048f6f6 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.spec/member_swap.pass.cpp @@ -176,7 +176,7 @@ int main() assert(distance(c2.begin(), c2.end()) == 0); assert(c2.get_allocator() == A(1)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef min_allocator<T> A; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp index d6ba5a47cbe6..983d8140571b 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.spec/non_member_swap.pass.cpp @@ -177,7 +177,7 @@ int main() assert(distance(c2.begin(), c2.end()) == 0); assert(c2.get_allocator() == A(1)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef min_allocator<T> A; diff --git a/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp b/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp index cbe8142eeb4b..5f8cf95aa737 100644 --- a/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/forwardlist/forwardlist.spec/swap_noexcept.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <forward_list> // void swap(forward_list& c) @@ -21,6 +23,7 @@ #include <forward_list> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -28,7 +31,7 @@ template <class T> struct some_alloc { typedef T value_type; - + some_alloc() {} some_alloc(const some_alloc&); void deallocate(void*, unsigned) {} @@ -40,7 +43,7 @@ template <class T> struct some_alloc2 { typedef T value_type; - + some_alloc2() {} some_alloc2(const some_alloc2&); void deallocate(void*, unsigned) {} @@ -51,7 +54,6 @@ struct some_alloc2 int main() { -#if __has_feature(cxx_noexcept) { typedef std::forward_list<MoveOnly> C; C c1, c2; @@ -85,6 +87,4 @@ int main() static_assert( noexcept(swap(c1, c2)), ""); } #endif - -#endif } diff --git a/test/std/containers/sequences/forwardlist/incomplete.pass.cpp b/test/std/containers/sequences/forwardlist/incomplete.pass.cpp new file mode 100644 index 000000000000..df273449eac1 --- /dev/null +++ b/test/std/containers/sequences/forwardlist/incomplete.pass.cpp @@ -0,0 +1,53 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <forward_list> + +// forward_list() +// forward_list::iterator() +// forward_list::const_iterator() + +#include <forward_list> +#include <cassert> + +#include "test_macros.h" +#include "min_allocator.h" + +struct A { + std::forward_list<A> d; + std::forward_list<A>::iterator it; + std::forward_list<A>::const_iterator it2; +}; + +#if TEST_STD_VER >= 11 +struct B { + typedef std::forward_list<B, min_allocator<B>> FList; + FList d; + FList::iterator it; + FList::const_iterator it2; +}; +#endif + +int main() +{ + { + A a; + assert(a.d.empty()); + a.it = a.d.begin(); + a.it2 = a.d.cbefore_begin(); + } +#if TEST_STD_VER >= 11 + { + B b; + assert(b.d.empty()); + b.it = b.d.begin(); + b.it2 = b.d.cbefore_begin(); + } +#endif +} diff --git a/test/std/containers/sequences/forwardlist/max_size.pass.cpp b/test/std/containers/sequences/forwardlist/max_size.pass.cpp index be7ebaf44b03..a7f39bf90fb8 100644 --- a/test/std/containers/sequences/forwardlist/max_size.pass.cpp +++ b/test/std/containers/sequences/forwardlist/max_size.pass.cpp @@ -24,7 +24,7 @@ int main() C c; assert(c.max_size() > 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::forward_list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/forwardlist/types.pass.cpp b/test/std/containers/sequences/forwardlist/types.pass.cpp index a1f8862debbe..5ed7e34b9202 100644 --- a/test/std/containers/sequences/forwardlist/types.pass.cpp +++ b/test/std/containers/sequences/forwardlist/types.pass.cpp @@ -44,8 +44,15 @@ int main() static_assert((std::is_same<C::const_pointer, const char*>::value), ""); static_assert((std::is_same<C::size_type, std::size_t>::value), ""); static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), ""); + + static_assert((std::is_signed<typename C::difference_type>::value), ""); + static_assert((std::is_unsigned<typename C::size_type>::value), ""); + static_assert((std::is_same<typename C::difference_type, + typename std::iterator_traits<typename C::iterator>::difference_type>::value), ""); + static_assert((std::is_same<typename C::difference_type, + typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), ""); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::forward_list<char, min_allocator<char>> C; static_assert((std::is_same<C::value_type, char>::value), ""); @@ -57,6 +64,13 @@ int main() // min_allocator doesn't have a size_type, so one gets synthesized static_assert((std::is_same<C::size_type, std::make_unsigned<C::difference_type>::type>::value), ""); static_assert((std::is_same<C::difference_type, std::ptrdiff_t>::value), ""); + + static_assert((std::is_signed<typename C::difference_type>::value), ""); + static_assert((std::is_unsigned<typename C::size_type>::value), ""); + static_assert((std::is_same<typename C::difference_type, + typename std::iterator_traits<typename C::iterator>::difference_type>::value), ""); + static_assert((std::is_same<typename C::difference_type, + typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), ""); } #endif } diff --git a/test/std/containers/sequences/forwardlist/version.pass.cpp b/test/std/containers/sequences/forwardlist/version.pass.cpp deleted file mode 100644 index 918c8dd5d73c..000000000000 --- a/test/std/containers/sequences/forwardlist/version.pass.cpp +++ /dev/null @@ -1,20 +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. -// -//===----------------------------------------------------------------------===// - -// <forward_list> - -#include <forward_list> - -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif - -int main() -{ -} diff --git a/test/std/containers/sequences/list/db_back.pass.cpp b/test/std/containers/sequences/list/db_back.pass.cpp deleted file mode 100644 index b16c0e90701e..000000000000 --- a/test/std/containers/sequences/list/db_back.pass.cpp +++ /dev/null @@ -1,56 +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. -// -//===----------------------------------------------------------------------===// - -// <list> - -// Call back() on empty container. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <list> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::list<T> C; - C c(1); - assert(c.back() == 0); - c.clear(); - assert(c.back() == 0); - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::list<T, min_allocator<T>> C; - C c(1); - assert(c.back() == 0); - c.clear(); - assert(c.back() == 0); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/list/db_cback.pass.cpp b/test/std/containers/sequences/list/db_cback.pass.cpp deleted file mode 100644 index ba3977e16f48..000000000000 --- a/test/std/containers/sequences/list/db_cback.pass.cpp +++ /dev/null @@ -1,52 +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. -// -//===----------------------------------------------------------------------===// - -// <list> - -// Call back() on empty const container. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <list> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::list<T> C; - const C c; - assert(c.back() == 0); - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::list<T, min_allocator<T>> C; - const C c; - assert(c.back() == 0); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/list/db_cfront.pass.cpp b/test/std/containers/sequences/list/db_cfront.pass.cpp deleted file mode 100644 index d42290c43c08..000000000000 --- a/test/std/containers/sequences/list/db_cfront.pass.cpp +++ /dev/null @@ -1,52 +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. -// -//===----------------------------------------------------------------------===// - -// <list> - -// Call front() on empty const container. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <list> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::list<T> C; - const C c; - assert(c.front() == 0); - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::list<T, min_allocator<T>> C; - const C c; - assert(c.front() == 0); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/list/db_front.pass.cpp b/test/std/containers/sequences/list/db_front.pass.cpp deleted file mode 100644 index 037b16035c66..000000000000 --- a/test/std/containers/sequences/list/db_front.pass.cpp +++ /dev/null @@ -1,56 +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. -// -//===----------------------------------------------------------------------===// - -// <list> - -// Call front() on empty container. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <list> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::list<T> C; - C c(1); - assert(c.front() == 0); - c.clear(); - assert(c.front() == 0); - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::list<T, min_allocator<T>> C; - C c(1); - assert(c.front() == 0); - c.clear(); - assert(c.front() == 0); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/list/db_iterators_6.pass.cpp b/test/std/containers/sequences/list/db_iterators_6.pass.cpp deleted file mode 100644 index a5b8020b3733..000000000000 --- a/test/std/containers/sequences/list/db_iterators_6.pass.cpp +++ /dev/null @@ -1,58 +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. -// -//===----------------------------------------------------------------------===// - -// <list> - -// Decrement iterator prior to begin. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <list> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::list<T> C; - C c(1); - C::iterator i = c.end(); - --i; - assert(i == c.begin()); - --i; - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::list<T, min_allocator<T>> C; - C c(1); - C::iterator i = c.end(); - --i; - assert(i == c.begin()); - --i; - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/list/db_iterators_7.pass.cpp b/test/std/containers/sequences/list/db_iterators_7.pass.cpp deleted file mode 100644 index 76a491b1184d..000000000000 --- a/test/std/containers/sequences/list/db_iterators_7.pass.cpp +++ /dev/null @@ -1,58 +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. -// -//===----------------------------------------------------------------------===// - -// <list> - -// Increment iterator past end. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <list> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::list<T> C; - C c(1); - C::iterator i = c.begin(); - ++i; - assert(i == c.end()); - ++i; - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::list<T, min_allocator<T>> C; - C c(1); - C::iterator i = c.begin(); - ++i; - assert(i == c.end()); - ++i; - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/list/db_iterators_8.pass.cpp b/test/std/containers/sequences/list/db_iterators_8.pass.cpp deleted file mode 100644 index 1d1ee23a393a..000000000000 --- a/test/std/containers/sequences/list/db_iterators_8.pass.cpp +++ /dev/null @@ -1,54 +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. -// -//===----------------------------------------------------------------------===// - -// <list> - -// Dereference non-dereferenceable iterator. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <list> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::list<T> C; - C c(1); - C::iterator i = c.end(); - T j = *i; - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::list<T, min_allocator<T>> C; - C c(1); - C::iterator i = c.end(); - T j = *i; - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/list/db_iterators_9.pass.cpp b/test/std/containers/sequences/list/db_iterators_9.pass.cpp deleted file mode 100644 index d02fcd6e4497..000000000000 --- a/test/std/containers/sequences/list/db_iterators_9.pass.cpp +++ /dev/null @@ -1,67 +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. -// -//===----------------------------------------------------------------------===// - -// <list> - -// Operations on "NULL" iterators - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) do { if (!x) throw 1; } while(0) - -#include <list> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -struct S { int val; }; - -int main() -{ -#if _LIBCPP_STD_VER > 11 - { - unsigned lib_asserts; - - typedef S T; - typedef std::list<T> C; - C::iterator i{}; - C::const_iterator ci{}; - - lib_asserts = 0; - try { ++i; } catch (int) { ++lib_asserts; } - try { i++; } catch (int) { ++lib_asserts; } - try { ++ci; } catch (int) { ++lib_asserts; } - try { ci++; } catch (int) { ++lib_asserts; } - assert(lib_asserts == 4); - - lib_asserts = 0; - try { --i; } catch (int) { ++lib_asserts; } - try { i--; } catch (int) { ++lib_asserts; } - try { --ci; } catch (int) { ++lib_asserts; } - try { ci--; } catch (int) { ++lib_asserts; } - assert(lib_asserts == 4); - - lib_asserts = 0; - try { *i; } catch (int) { ++lib_asserts; } - try { *ci; } catch (int) { ++lib_asserts; } - try { (void) i->val; } catch (int) { ++lib_asserts; } - try { (void) ci->val; } catch (int) { ++lib_asserts; } - assert(lib_asserts == 4); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/list/iterators.pass.cpp b/test/std/containers/sequences/list/iterators.pass.cpp index a33ee3ecd2db..fe0ac0799687 100644 --- a/test/std/containers/sequences/list/iterators.pass.cpp +++ b/test/std/containers/sequences/list/iterators.pass.cpp @@ -77,7 +77,7 @@ int main() C::iterator i; C::const_iterator j; } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::list<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp b/test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp index 14629b173a6c..df934699d5ad 100644 --- a/test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp +++ b/test/std/containers/sequences/list/list.capacity/resize_size.pass.cpp @@ -47,7 +47,7 @@ int main() assert(std::distance(l.begin(), l.end()) == 20); } #endif // __LIBCPP_MOVE -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> l(5, 2); l.resize(2); diff --git a/test/std/containers/sequences/list/list.capacity/resize_size_value.pass.cpp b/test/std/containers/sequences/list/list.capacity/resize_size_value.pass.cpp index 2738ffbbefdd..4609ef986835 100644 --- a/test/std/containers/sequences/list/list.capacity/resize_size_value.pass.cpp +++ b/test/std/containers/sequences/list/list.capacity/resize_size_value.pass.cpp @@ -33,7 +33,7 @@ int main() assert(l.front() == 2); assert(l.back() == 3.5); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<double, min_allocator<double>> l(5, 2); l.resize(2, 3.5); diff --git a/test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp b/test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp index b851eb9dc5a0..7c8cee2a5581 100644 --- a/test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/assign_copy.pass.cpp @@ -32,7 +32,7 @@ int main() assert(l2 == l); assert(l2.get_allocator() == other_allocator<int>(5)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int> > l(3, 2, min_allocator<int>()); std::list<int, min_allocator<int> > l2(l, min_allocator<int>()); diff --git a/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp b/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp index 24bd140c4e4f..9b2c6d68cbe5 100644 --- a/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/assign_initializer_list.pass.cpp @@ -29,7 +29,7 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> d; d.assign({3, 4, 5, 6}); diff --git a/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp b/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp index 0fd586f84af7..2f863c6169fc 100644 --- a/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/assign_move.pass.cpp @@ -62,7 +62,7 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{}); std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{}); diff --git a/test/std/containers/sequences/list/list.cons/copy.pass.cpp b/test/std/containers/sequences/list/list.cons/copy.pass.cpp index 530690a925d4..a6abd1f3c30b 100644 --- a/test/std/containers/sequences/list/list.cons/copy.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/copy.pass.cpp @@ -38,7 +38,7 @@ int main() assert(l2.get_allocator() == other_allocator<int>(-2)); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> l(3, 2); std::list<int, min_allocator<int>> l2 = l; diff --git a/test/std/containers/sequences/list/list.cons/copy_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/copy_alloc.pass.cpp index 99fe9f115f94..a164298f4fae 100644 --- a/test/std/containers/sequences/list/list.cons/copy_alloc.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/copy_alloc.pass.cpp @@ -31,7 +31,7 @@ int main() assert(l2 == l); assert(l2.get_allocator() == other_allocator<int>(3)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int> > l(3, 2, min_allocator<int>()); std::list<int, min_allocator<int> > l2(l, min_allocator<int>()); diff --git a/test/std/containers/sequences/list/list.cons/default.pass.cpp b/test/std/containers/sequences/list/list.cons/default.pass.cpp index c05bd74ca79e..3c1c2ef166d4 100644 --- a/test/std/containers/sequences/list/list.cons/default.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/default.pass.cpp @@ -33,7 +33,7 @@ int main() assert(l.size() == 0); assert(std::distance(l.begin(), l.end()) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> l; assert(l.size() == 0); diff --git a/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp index 2455fb39a79a..6f76d8c56882 100644 --- a/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/default_noexcept.pass.cpp @@ -14,9 +14,12 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <list> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -29,14 +32,13 @@ struct some_alloc int main() { -#if __has_feature(cxx_noexcept) { typedef std::list<MoveOnly> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::list<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::list<MoveOnly, other_allocator<MoveOnly>> C; @@ -46,5 +48,4 @@ int main() typedef std::list<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp index 9d9946b68966..4b88580e12ca 100644 --- a/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/default_stack_alloc.pass.cpp @@ -33,7 +33,7 @@ int main() assert(l.size() == 0); assert(std::distance(l.begin(), l.end()) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> l; assert(l.size() == 0); diff --git a/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp index ca7ade6d19cb..3d11f13358b5 100644 --- a/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/dtor_noexcept.pass.cpp @@ -11,14 +11,14 @@ // ~list() // implied noexcept; +// UNSUPPORTED: c++98, c++03 + #include <list> #include <cassert> #include "MoveOnly.h" #include "test_allocator.h" -#if __has_feature(cxx_noexcept) - template <class T> struct some_alloc { @@ -27,11 +27,8 @@ struct some_alloc ~some_alloc() noexcept(false); }; -#endif - int main() { -#if __has_feature(cxx_noexcept) { typedef std::list<MoveOnly> C; static_assert(std::is_nothrow_destructible<C>::value, ""); @@ -48,5 +45,4 @@ int main() typedef std::list<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_destructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp b/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp index 3307017989eb..40413203bdfc 100644 --- a/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/initializer_list.pass.cpp @@ -28,7 +28,7 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> d = {3, 4, 5, 6}; assert(d.size() == 4); diff --git a/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp index 4a85e378c1ce..72add79f6670 100644 --- a/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/initializer_list_alloc.pass.cpp @@ -30,7 +30,7 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>()); assert(d.get_allocator() == min_allocator<int>()); diff --git a/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp b/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp index 09eae8ab43c1..0dd71d70f85b 100644 --- a/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/input_iterator.pass.cpp @@ -51,7 +51,7 @@ int main() for (std::list<int>::const_iterator i = l.begin(), e = l.end(); i != e; ++i, ++j) assert(*i == j); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a[] = {0, 1, 2, 3}; std::list<int, min_allocator<int>> l(input_iterator<const int*>(a), diff --git a/test/std/containers/sequences/list/list.cons/move.pass.cpp b/test/std/containers/sequences/list/list.cons/move.pass.cpp index 54209a55f7e2..1049b1b03982 100644 --- a/test/std/containers/sequences/list/list.cons/move.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/move.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // list(list&& c); @@ -19,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::list<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5)); std::list<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5)); @@ -46,7 +47,6 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#if __cplusplus >= 201103L { std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{}); std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{}); @@ -60,15 +60,4 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#endif -#if _LIBCPP_DEBUG >= 1 - { - std::list<int> l1 = {1, 2, 3}; - std::list<int>::iterator i = l1.begin(); - std::list<int> l2 = std::move(l1); - assert(*l2.erase(i) == 2); - assert(l2.size() == 2); - } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES } diff --git a/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp index 8f82702b296f..9f8a536b33c5 100644 --- a/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/move_alloc.pass.cpp @@ -59,7 +59,7 @@ int main() assert(!l.empty()); assert(l2.get_allocator() == other_allocator<MoveOnly>(4)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{}); std::list<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{}); diff --git a/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp index 280d93d486e6..d4f8fde2c8ff 100644 --- a/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/move_assign_noexcept.pass.cpp @@ -16,6 +16,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <list> #include <cassert> @@ -31,7 +33,6 @@ struct some_alloc int main() { -#if __has_feature(cxx_noexcept) { typedef std::list<MoveOnly> C; static_assert(std::is_nothrow_move_assignable<C>::value, ""); @@ -48,5 +49,4 @@ int main() typedef std::list<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } -#endif } diff --git a/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp index e436a29f5d47..da2b6a36cef5 100644 --- a/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/move_noexcept.pass.cpp @@ -14,6 +14,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <list> #include <cassert> @@ -29,7 +31,6 @@ struct some_alloc int main() { -#if __has_feature(cxx_noexcept) { typedef std::list<MoveOnly> C; static_assert(std::is_nothrow_move_constructible<C>::value, ""); @@ -46,5 +47,4 @@ int main() typedef std::list<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp b/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp index 7b7b8a327b88..1097bdab2198 100644 --- a/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/op_equal_initializer_list.pass.cpp @@ -28,7 +28,7 @@ int main() assert(*i++ == 5); assert(*i++ == 6); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> d; d = {3, 4, 5, 6}; diff --git a/test/std/containers/sequences/list/list.cons/size_type.pass.cpp b/test/std/containers/sequences/list/list.cons/size_type.pass.cpp index 75b93a3dfb6b..07b4f14dc3a2 100644 --- a/test/std/containers/sequences/list/list.cons/size_type.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/size_type.pass.cpp @@ -80,7 +80,7 @@ int main() assert(std::distance(l.begin(), l.end()) == 3); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> l(3); assert(l.size() == 3); diff --git a/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp b/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp index 12da86da0a41..ac7b18ea4990 100644 --- a/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp +++ b/test/std/containers/sequences/list/list.cons/size_value_alloc.pass.cpp @@ -52,7 +52,7 @@ int main() ++i; assert(*i == 2); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> l(3, 2); assert(l.size() == 3); diff --git a/test/std/containers/sequences/list/list.modifiers/clear.pass.cpp b/test/std/containers/sequences/list/list.modifiers/clear.pass.cpp index 38696b6eb503..5d8c41fa1976 100644 --- a/test/std/containers/sequences/list/list.modifiers/clear.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/clear.pass.cpp @@ -24,7 +24,7 @@ int main() c.clear(); assert(c.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a[] = {1, 2, 3}; std::list<int, min_allocator<int>> c(a, a+3); diff --git a/test/std/containers/sequences/list/list.modifiers/emplace.pass.cpp b/test/std/containers/sequences/list/list.modifiers/emplace.pass.cpp index 6476d1d6c6ae..e8d46941252e 100644 --- a/test/std/containers/sequences/list/list.modifiers/emplace.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/emplace.pass.cpp @@ -7,17 +7,17 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // template <class... Args> void emplace(const_iterator p, Args&&... args); -#if _LIBCPP_DEBUG >= 1 -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif #include <list> #include <cassert> +#include "test_macros.h" #include "min_allocator.h" class A @@ -37,7 +37,6 @@ public: int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::list<A> c; c.emplace(c.cbegin(), 2, 3.5); @@ -51,17 +50,6 @@ int main() assert(c.back().geti() == 3); assert(c.back().getd() == 4.5); } -#if _LIBCPP_DEBUG >= 1 - { - std::list<A> c1; - std::list<A> c2; - std::list<A>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5); - assert(false); - } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::list<A, min_allocator<A>> c; c.emplace(c.cbegin(), 2, 3.5); @@ -75,14 +63,5 @@ int main() assert(c.back().geti() == 3); assert(c.back().getd() == 4.5); } -#if _LIBCPP_DEBUG >= 1 - { - std::list<A, min_allocator<A>> c1; - std::list<A, min_allocator<A>> c2; - std::list<A, min_allocator<A>>::iterator i = c1.emplace(c2.cbegin(), 2, 3.5); - assert(false); - } -#endif -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#endif + } diff --git a/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp b/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp index 5983efc59ad1..2ff01f1676f2 100644 --- a/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/emplace_back.pass.cpp @@ -47,7 +47,7 @@ int main() assert(c.back().geti() == 3); assert(c.back().getd() == 4.5); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<A, min_allocator<A>> c; c.emplace_back(2, 3.5); diff --git a/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp b/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp index e2e68e331381..8a3df46a31e2 100644 --- a/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/emplace_front.pass.cpp @@ -47,7 +47,7 @@ int main() assert(c.back().geti() == 2); assert(c.back().getd() == 3.5); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<A, min_allocator<A>> c; c.emplace_front(2, 3.5); diff --git a/test/std/containers/sequences/list/list.modifiers/erase_iter.pass.cpp b/test/std/containers/sequences/list/list.modifiers/erase_iter.pass.cpp index c1cc90043670..0924fdb84879 100644 --- a/test/std/containers/sequences/list/list.modifiers/erase_iter.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/erase_iter.pass.cpp @@ -39,7 +39,7 @@ int main() assert(l1.size() == 0); assert(distance(l1.begin(), l1.end()) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {1, 2, 3}; std::list<int, min_allocator<int>> l1(a1, a1+3); diff --git a/test/std/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp b/test/std/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp deleted file mode 100644 index 18c15eb02c85..000000000000 --- a/test/std/containers/sequences/list/list.modifiers/erase_iter_db1.pass.cpp +++ /dev/null @@ -1,51 +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. -// -//===----------------------------------------------------------------------===// - -// <list> - -// Call erase(const_iterator position) with end() - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <list> -#include <cassert> -#include <cstdlib> -#include <exception> - -#include "min_allocator.h" - -int main() -{ - { - int a1[] = {1, 2, 3}; - std::list<int> l1(a1, a1+3); - std::list<int>::const_iterator i = l1.end(); - l1.erase(i); - assert(false); - } -#if __cplusplus >= 201103L - { - int a1[] = {1, 2, 3}; - std::list<int, min_allocator<int>> l1(a1, a1+3); - std::list<int, min_allocator<int>>::const_iterator i = l1.end(); - l1.erase(i); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp b/test/std/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp deleted file mode 100644 index 61ff8409c964..000000000000 --- a/test/std/containers/sequences/list/list.modifiers/erase_iter_db2.pass.cpp +++ /dev/null @@ -1,53 +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. -// -//===----------------------------------------------------------------------===// - -// <list> - -// Call erase(const_iterator position) with iterator from another container - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <list> -#include <cassert> -#include <cstdlib> -#include <exception> - -#include "min_allocator.h" - -int main() -{ - { - int a1[] = {1, 2, 3}; - std::list<int> l1(a1, a1+3); - std::list<int> l2(a1, a1+3); - std::list<int>::const_iterator i = l2.begin(); - l1.erase(i); - assert(false); - } -#if __cplusplus >= 201103L - { - int a1[] = {1, 2, 3}; - std::list<int, min_allocator<int>> l1(a1, a1+3); - std::list<int, min_allocator<int>> l2(a1, a1+3); - std::list<int, min_allocator<int>>::const_iterator i = l2.begin(); - l1.erase(i); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp b/test/std/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp index bd3f66b4116a..06b4f0cc654f 100644 --- a/test/std/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/erase_iter_iter.pass.cpp @@ -49,7 +49,7 @@ int main() assert(distance(l1.cbegin(), l1.cend()) == 0); assert(i == l1.begin()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> l1(a1, a1+3); std::list<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), l1.cbegin()); diff --git a/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp b/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp deleted file mode 100644 index 71ad497e7d97..000000000000 --- a/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db1.pass.cpp +++ /dev/null @@ -1,51 +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. -// -//===----------------------------------------------------------------------===// - -// <list> - -// Call erase(const_iterator first, const_iterator last); with first iterator from another container - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <list> -#include <cassert> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - int a1[] = {1, 2, 3}; - std::list<int> l1(a1, a1+3); - std::list<int> l2(a1, a1+3); - std::list<int>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin())); - assert(false); - } -#if __cplusplus >= 201103L - { - int a1[] = {1, 2, 3}; - std::list<int, min_allocator<int>> l1(a1, a1+3); - std::list<int, min_allocator<int>> l2(a1, a1+3); - std::list<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), next(l1.cbegin())); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp b/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp deleted file mode 100644 index db76b4de4865..000000000000 --- a/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db2.pass.cpp +++ /dev/null @@ -1,51 +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. -// -//===----------------------------------------------------------------------===// - -// <list> - -// Call erase(const_iterator first, const_iterator last); with second iterator from another container - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <list> -#include <cassert> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - int a1[] = {1, 2, 3}; - std::list<int> l1(a1, a1+3); - std::list<int> l2(a1, a1+3); - std::list<int>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin())); - assert(false); - } -#if __cplusplus >= 201103L - { - int a1[] = {1, 2, 3}; - std::list<int, min_allocator<int>> l1(a1, a1+3); - std::list<int, min_allocator<int>> l2(a1, a1+3); - std::list<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l2.cbegin())); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp b/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp deleted file mode 100644 index 25c5c6147a01..000000000000 --- a/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db3.pass.cpp +++ /dev/null @@ -1,51 +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. -// -//===----------------------------------------------------------------------===// - -// <list> - -// Call erase(const_iterator first, const_iterator last); with both iterators from another container - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <list> -#include <cassert> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - int a1[] = {1, 2, 3}; - std::list<int> l1(a1, a1+3); - std::list<int> l2(a1, a1+3); - std::list<int>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin())); - assert(false); - } -#if __cplusplus >= 201103L - { - int a1[] = {1, 2, 3}; - std::list<int, min_allocator<int>> l1(a1, a1+3); - std::list<int, min_allocator<int>> l2(a1, a1+3); - std::list<int, min_allocator<int>>::iterator i = l1.erase(l2.cbegin(), next(l2.cbegin())); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp b/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp deleted file mode 100644 index 35a4ceb4848a..000000000000 --- a/test/std/containers/sequences/list/list.modifiers/erase_iter_iter_db4.pass.cpp +++ /dev/null @@ -1,49 +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. -// -//===----------------------------------------------------------------------===// - -// <list> - -// Call erase(const_iterator first, const_iterator last); with a bad range - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <list> -#include <cassert> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - int a1[] = {1, 2, 3}; - std::list<int> l1(a1, a1+3); - std::list<int>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin()); - assert(false); - } -#if __cplusplus >= 201103L - { - int a1[] = {1, 2, 3}; - std::list<int, min_allocator<int>> l1(a1, a1+3); - std::list<int, min_allocator<int>>::iterator i = l1.erase(next(l1.cbegin()), l1.cbegin()); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp b/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp index a82a2696e82a..91845e564b02 100644 --- a/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/insert_iter_initializer_list.pass.cpp @@ -40,7 +40,7 @@ int main() assert(*i++ == 1); assert(*i++ == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> d(10, 1); std::list<int, min_allocator<int>>::iterator i = d.insert(next(d.cbegin(), 2), {3, 4, 5, 6}); diff --git a/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp b/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp index 736b9baae746..18460a65743c 100644 --- a/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/insert_iter_iter_iter.pass.cpp @@ -7,117 +7,25 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // <list> // template <InputIterator Iter> // iterator insert(const_iterator position, Iter first, Iter last); -// UNSUPPORTED: sanitizer-new-delete - -#if _LIBCPP_DEBUG >= 1 -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - #include <list> #include <cstdlib> #include <cassert> + +#include "test_macros.h" #include "test_iterators.h" #include "min_allocator.h" +#include "count_new.hpp" -int throw_next = 0xFFFF; -int count = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - if (throw_next == 0) - throw std::bad_alloc(); - --throw_next; - ++count; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --count; - std::free(p); -} - -int main() -{ - { - int a1[] = {1, 2, 3}; - std::list<int> l1; - std::list<int>::iterator i = l1.insert(l1.begin(), a1, a1+3); - assert(i == l1.begin()); - assert(l1.size() == 3); - assert(distance(l1.begin(), l1.end()) == 3); - i = l1.begin(); - assert(*i == 1); - ++i; - assert(*i == 2); - ++i; - assert(*i == 3); - int a2[] = {4, 5, 6}; - i = l1.insert(i, a2, a2+3); - assert(*i == 4); - assert(l1.size() == 6); - assert(distance(l1.begin(), l1.end()) == 6); - i = l1.begin(); - assert(*i == 1); - ++i; - assert(*i == 2); - ++i; - assert(*i == 4); - ++i; - assert(*i == 5); - ++i; - assert(*i == 6); - ++i; - assert(*i == 3); - throw_next = 2; - int save_count = count; - try - { - i = l1.insert(i, a2, a2+3); - assert(false); - } - catch (...) - { - } - assert(save_count == count); - assert(l1.size() == 6); - assert(distance(l1.begin(), l1.end()) == 6); - i = l1.begin(); - assert(*i == 1); - ++i; - assert(*i == 2); - ++i; - assert(*i == 4); - ++i; - assert(*i == 5); - ++i; - assert(*i == 6); - ++i; - assert(*i == 3); - } - throw_next = 0xFFFF; -#if _LIBCPP_DEBUG >= 1 - { - std::list<int> v(100); - std::list<int> v2(100); - int a[] = {1, 2, 3, 4, 5}; - const int N = sizeof(a)/sizeof(a[0]); - std::list<int>::iterator i = v.insert(next(v2.cbegin(), 10), input_iterator<const int*>(a), - input_iterator<const int*>(a+N)); - assert(false); - } -#endif -#if __cplusplus >= 201103L - { +template <class List> +void test() { int a1[] = {1, 2, 3}; - std::list<int, min_allocator<int>> l1; - std::list<int, min_allocator<int>>::iterator i = l1.insert(l1.begin(), a1, a1+3); + List l1; + typename List::iterator i = l1.insert(l1.begin(), a1, a1+3); assert(i == l1.begin()); assert(l1.size() == 3); assert(distance(l1.begin(), l1.end()) == 3); @@ -144,8 +52,10 @@ int main() assert(*i == 6); ++i; assert(*i == 3); - throw_next = 2; - int save_count = count; + +#if !defined(TEST_HAS_NO_EXCEPTIONS) && !defined(DISABLE_NEW_COUNT) + globalMemCounter.throw_after = 2; + int save_count = globalMemCounter.outstanding_new; try { i = l1.insert(i, a2, a2+3); @@ -154,7 +64,7 @@ int main() catch (...) { } - assert(save_count == count); + assert(globalMemCounter.checkOutstandingNewEq(save_count)); assert(l1.size() == 6); assert(distance(l1.begin(), l1.end()) == 6); i = l1.begin(); @@ -169,18 +79,13 @@ int main() assert(*i == 6); ++i; assert(*i == 3); - } -#if _LIBCPP_DEBUG >= 1 - { - throw_next = 0xFFFF; - std::list<int, min_allocator<int>> v(100); - std::list<int, min_allocator<int>> v2(100); - int a[] = {1, 2, 3, 4, 5}; - const int N = sizeof(a)/sizeof(a[0]); - std::list<int, min_allocator<int>>::iterator i = v.insert(next(v2.cbegin(), 10), input_iterator<const int*>(a), - input_iterator<const int*>(a+N)); - assert(false); - } #endif +} + +int main() +{ + test<std::list<int> >(); +#if TEST_STD_VER >= 11 + test<std::list<int, min_allocator<int>>>(); #endif } diff --git a/test/std/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp b/test/std/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp index 3d5dec299b95..5d579fcd202e 100644 --- a/test/std/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/insert_iter_rvalue.pass.cpp @@ -7,14 +7,12 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // iterator insert(const_iterator position, value_type&& x); -#if _LIBCPP_DEBUG >= 1 -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - #include <list> #include <cassert> @@ -23,7 +21,6 @@ int main() { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::list<MoveOnly> l1; l1.insert(l1.cend(), MoveOnly(1)); @@ -34,17 +31,6 @@ int main() assert(l1.front() == MoveOnly(2)); assert(l1.back() == MoveOnly(1)); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if _LIBCPP_DEBUG >= 1 - { - std::list<int> v1(3); - std::list<int> v2(3); - v1.insert(v2.begin(), 4); - assert(false); - } -#endif -#if __cplusplus >= 201103L -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { std::list<MoveOnly, min_allocator<MoveOnly>> l1; l1.insert(l1.cend(), MoveOnly(1)); @@ -55,14 +41,4 @@ int main() assert(l1.front() == MoveOnly(2)); assert(l1.back() == MoveOnly(1)); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if _LIBCPP_DEBUG >= 1 - { - std::list<int, min_allocator<int>> v1(3); - std::list<int, min_allocator<int>> v2(3); - v1.insert(v2.begin(), 4); - assert(false); - } -#endif -#endif } diff --git a/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp b/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp index c0f6ed198751..d85c1f4b9987 100644 --- a/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/insert_iter_size_value.pass.cpp @@ -14,75 +14,23 @@ // UNSUPPORTED: sanitizer-new-delete -#if _LIBCPP_DEBUG >= 1 -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - #include <list> #include <cstdlib> #include <cassert> #include "min_allocator.h" +#include "count_new.hpp" -int throw_next = 0xFFFF; -int count = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - if (throw_next == 0) - throw std::bad_alloc(); - --throw_next; - ++count; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --count; - std::free(p); -} - -int main() -{ - { - int a1[] = {1, 2, 3}; - int a2[] = {1, 4, 4, 4, 4, 4, 2, 3}; - std::list<int> l1(a1, a1+3); - std::list<int>::iterator i = l1.insert(next(l1.cbegin()), 5, 4); - assert(i == next(l1.begin())); - assert(l1 == std::list<int>(a2, a2+8)); - throw_next = 4; - int save_count = count; - try - { - i = l1.insert(i, 5, 5); - assert(false); - } - catch (...) - { - } - throw_next = 0xFFFF; - assert(save_count == count); - assert(l1 == std::list<int>(a2, a2+8)); - } -#if _LIBCPP_DEBUG >= 1 - { - std::list<int> c1(100); - std::list<int> c2; - std::list<int>::iterator i = c1.insert(next(c2.cbegin(), 10), 5, 1); - assert(false); - } -#endif -#if __cplusplus >= 201103L - { +template <class List> +void test() { int a1[] = {1, 2, 3}; int a2[] = {1, 4, 4, 4, 4, 4, 2, 3}; - std::list<int, min_allocator<int>> l1(a1, a1+3); - std::list<int, min_allocator<int>>::iterator i = l1.insert(next(l1.cbegin()), 5, 4); + List l1(a1, a1+3); + typename List::iterator i = l1.insert(next(l1.cbegin()), 5, 4); assert(i == next(l1.begin())); - assert((l1 == std::list<int, min_allocator<int>>(a2, a2+8))); - throw_next = 4; - int save_count = count; + assert(l1 == List(a2, a2+8)); + globalMemCounter.throw_after = 4; + int save_count = globalMemCounter.outstanding_new; try { i = l1.insert(i, 5, 5); @@ -91,17 +39,14 @@ int main() catch (...) { } - throw_next = 0xFFFF; - assert(save_count == count); - assert((l1 == std::list<int, min_allocator<int>>(a2, a2+8))); - } -#if _LIBCPP_DEBUG >= 1 - { - std::list<int, min_allocator<int>> c1(100); - std::list<int, min_allocator<int>> c2; - std::list<int, min_allocator<int>>::iterator i = c1.insert(next(c2.cbegin(), 10), 5, 1); - assert(false); - } -#endif + assert(globalMemCounter.checkOutstandingNewEq(save_count)); + assert(l1 == List(a2, a2+8)); +} + +int main() +{ + test<std::list<int> >(); +#if TEST_STD_VER >= 11 + test<std::list<int, min_allocator<int>>>(); #endif } diff --git a/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp b/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp index 1aacb63e4a70..87a033be64e9 100644 --- a/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/insert_iter_value.pass.cpp @@ -7,87 +7,33 @@ // //===----------------------------------------------------------------------===// -// XFAIL: libcpp-no-exceptions // <list> // iterator insert(const_iterator position, const value_type& x); -// UNSUPPORTED: sanitizer-new-delete - -#if _LIBCPP_DEBUG >= 1 -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - #include <list> #include <cstdlib> #include <cassert> +#include "test_macros.h" #include "min_allocator.h" +#include "count_new.hpp" -int throw_next = 0xFFFF; -int count = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - if (throw_next == 0) - throw std::bad_alloc(); - --throw_next; - ++count; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --count; - std::free(p); -} - -int main() +template <class List> +void test() { - { - int a1[] = {1, 2, 3}; - int a2[] = {1, 4, 2, 3}; - std::list<int> l1(a1, a1+3); - std::list<int>::iterator i = l1.insert(next(l1.cbegin()), 4); - assert(i == next(l1.begin())); - assert(l1.size() == 4); - assert(distance(l1.begin(), l1.end()) == 4); - assert(l1 == std::list<int>(a2, a2+4)); - throw_next = 0; - int save_count = count; - try - { - i = l1.insert(i, 5); - assert(false); - } - catch (...) - { - } - throw_next = 0xFFFF; - assert(save_count == count); - assert(l1 == std::list<int>(a2, a2+4)); - } -#if _LIBCPP_DEBUG >= 1 - { - std::list<int> v1(3); - std::list<int> v2(3); - int i = 4; - v1.insert(v2.begin(), i); - assert(false); - } -#endif -#if __cplusplus >= 201103L - { int a1[] = {1, 2, 3}; int a2[] = {1, 4, 2, 3}; - std::list<int, min_allocator<int>> l1(a1, a1+3); - std::list<int, min_allocator<int>>::iterator i = l1.insert(next(l1.cbegin()), 4); + List l1(a1, a1+3); + typename List::iterator i = l1.insert(next(l1.cbegin()), 4); assert(i == next(l1.begin())); assert(l1.size() == 4); assert(distance(l1.begin(), l1.end()) == 4); - assert((l1 == std::list<int, min_allocator<int>>(a2, a2+4))); - throw_next = 0; - int save_count = count; + assert(l1 == List(a2, a2+4)); + +#if !defined(TEST_HAS_NO_EXCEPTIONS) && !defined(DISABLE_NEW_COUNT) + globalMemCounter.throw_after = 0; + int save_count = globalMemCounter.outstanding_new; try { i = l1.insert(i, 5); @@ -96,18 +42,15 @@ int main() catch (...) { } - throw_next = 0xFFFF; - assert(save_count == count); - assert((l1 == std::list<int, min_allocator<int>>(a2, a2+4))); - } -#if _LIBCPP_DEBUG >= 1 - { - std::list<int, min_allocator<int>> v1(3); - std::list<int, min_allocator<int>> v2(3); - int i = 4; - v1.insert(v2.begin(), i); - assert(false); - } + assert(globalMemCounter.checkOutstandingNewEq(save_count)); + assert(l1 == List(a2, a2+4)); #endif +} + +int main() +{ + test<std::list<int> >(); +#if TEST_STD_VER >= 11 + test<std::list<int, min_allocator<int>>>(); #endif } diff --git a/test/std/containers/sequences/list/list.modifiers/pop_back.pass.cpp b/test/std/containers/sequences/list/list.modifiers/pop_back.pass.cpp index 3add8518809c..c5b0277c6eff 100644 --- a/test/std/containers/sequences/list/list.modifiers/pop_back.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/pop_back.pass.cpp @@ -11,13 +11,10 @@ // void pop_back(); -#if _LIBCPP_DEBUG >= 1 -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - #include <list> #include <cassert> +#include "test_macros.h" #include "min_allocator.h" int main() @@ -31,12 +28,8 @@ int main() assert(c == std::list<int>(a, a+1)); c.pop_back(); assert(c.empty()); -#if _LIBCPP_DEBUG >= 1 - c.pop_back(); - assert(false); -#endif } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a[] = {1, 2, 3}; std::list<int, min_allocator<int>> c(a, a+3); @@ -46,10 +39,6 @@ int main() assert((c == std::list<int, min_allocator<int>>(a, a+1))); c.pop_back(); assert(c.empty()); -#if _LIBCPP_DEBUG >= 1 - c.pop_back(); - assert(false); -#endif } #endif } diff --git a/test/std/containers/sequences/list/list.modifiers/pop_front.pass.cpp b/test/std/containers/sequences/list/list.modifiers/pop_front.pass.cpp index aec17cc08f43..bb3ad546984d 100644 --- a/test/std/containers/sequences/list/list.modifiers/pop_front.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/pop_front.pass.cpp @@ -28,7 +28,7 @@ int main() c.pop_front(); assert(c.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a[] = {1, 2, 3}; std::list<int, min_allocator<int>> c(a, a+3); diff --git a/test/std/containers/sequences/list/list.modifiers/push_back.pass.cpp b/test/std/containers/sequences/list/list.modifiers/push_back.pass.cpp index 2638c541fa1c..3b05cd72968e 100644 --- a/test/std/containers/sequences/list/list.modifiers/push_back.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/push_back.pass.cpp @@ -25,7 +25,7 @@ int main() int a[] = {0, 1, 2, 3, 4}; assert(c == std::list<int>(a, a+5)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> c; for (int i = 0; i < 5; ++i) diff --git a/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp b/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp index a2837f813bea..10acede511f4 100644 --- a/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/push_back_rvalue.pass.cpp @@ -30,7 +30,7 @@ int main() assert(l1.front() == MoveOnly(1)); assert(l1.back() == MoveOnly(2)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<MoveOnly, min_allocator<MoveOnly>> l1; l1.push_back(MoveOnly(1)); diff --git a/test/std/containers/sequences/list/list.modifiers/push_front.pass.cpp b/test/std/containers/sequences/list/list.modifiers/push_front.pass.cpp index b7f4febcd385..ed0ef662031a 100644 --- a/test/std/containers/sequences/list/list.modifiers/push_front.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/push_front.pass.cpp @@ -25,7 +25,7 @@ int main() int a[] = {4, 3, 2, 1, 0}; assert(c == std::list<int>(a, a+5)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> c; for (int i = 0; i < 5; ++i) diff --git a/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp b/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp index 4f41c3dd390b..5321ee0faed3 100644 --- a/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp +++ b/test/std/containers/sequences/list/list.modifiers/push_front_rvalue.pass.cpp @@ -30,7 +30,7 @@ int main() assert(l1.front() == MoveOnly(2)); assert(l1.back() == MoveOnly(1)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<MoveOnly, min_allocator<MoveOnly>> l1; l1.push_front(MoveOnly(1)); diff --git a/test/std/containers/sequences/list/list.ops/merge.pass.cpp b/test/std/containers/sequences/list/list.ops/merge.pass.cpp index d226ed5dc642..7c1287706f35 100644 --- a/test/std/containers/sequences/list/list.ops/merge.pass.cpp +++ b/test/std/containers/sequences/list/list.ops/merge.pass.cpp @@ -27,7 +27,7 @@ int main() c1.merge(c2); assert(c1 == std::list<int>(a3, a3+sizeof(a3)/sizeof(a3[0]))); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; diff --git a/test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp b/test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp index ce861a5dcb88..838ff22b3a53 100644 --- a/test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp +++ b/test/std/containers/sequences/list/list.ops/merge_comp.pass.cpp @@ -28,7 +28,7 @@ int main() c1.merge(c2, std::greater<int>()); assert(c1 == std::list<int>(a3, a3+sizeof(a3)/sizeof(a3[0]))); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {10, 9, 7, 3, 1}; int a2[] = {11, 8, 6, 5, 4, 2, 0}; diff --git a/test/std/containers/sequences/list/list.ops/remove.pass.cpp b/test/std/containers/sequences/list/list.ops/remove.pass.cpp index f580c94ef486..fed28e442e12 100644 --- a/test/std/containers/sequences/list/list.ops/remove.pass.cpp +++ b/test/std/containers/sequences/list/list.ops/remove.pass.cpp @@ -57,7 +57,7 @@ int main() } assert ( it == c.end ()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {1, 2, 3, 4}; int a2[] = {1, 2, 4}; diff --git a/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp b/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp index 162919ed85de..1b457823d6ab 100644 --- a/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp +++ b/test/std/containers/sequences/list/list.ops/remove_if.pass.cpp @@ -50,7 +50,7 @@ int main() assert(c == std::list<int>(a2, a2+2)); assert(cp.count() == 4); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {1, 2, 3, 4}; int a2[] = {3, 4}; diff --git a/test/std/containers/sequences/list/list.ops/reverse.pass.cpp b/test/std/containers/sequences/list/list.ops/reverse.pass.cpp index 046453ae5386..120caba38ac9 100644 --- a/test/std/containers/sequences/list/list.ops/reverse.pass.cpp +++ b/test/std/containers/sequences/list/list.ops/reverse.pass.cpp @@ -25,7 +25,7 @@ int main() c1.reverse(); assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0]))); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; diff --git a/test/std/containers/sequences/list/list.ops/sort.pass.cpp b/test/std/containers/sequences/list/list.ops/sort.pass.cpp index 1c11227237a7..d51aa92dd782 100644 --- a/test/std/containers/sequences/list/list.ops/sort.pass.cpp +++ b/test/std/containers/sequences/list/list.ops/sort.pass.cpp @@ -25,7 +25,7 @@ int main() c1.sort(); assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0]))); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9}; int a2[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11}; diff --git a/test/std/containers/sequences/list/list.ops/sort_comp.pass.cpp b/test/std/containers/sequences/list/list.ops/sort_comp.pass.cpp index 28125ab83c00..517eb62ccae2 100644 --- a/test/std/containers/sequences/list/list.ops/sort_comp.pass.cpp +++ b/test/std/containers/sequences/list/list.ops/sort_comp.pass.cpp @@ -26,7 +26,7 @@ int main() c1.sort(std::greater<int>()); assert(c1 == std::list<int>(a2, a2+sizeof(a2)/sizeof(a2[0]))); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {4, 8, 1, 0, 5, 7, 2, 3, 6, 11, 10, 9}; int a2[] = {11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0}; diff --git a/test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp b/test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp index 354871c20afa..41d861da0d55 100644 --- a/test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp +++ b/test/std/containers/sequences/list/list.ops/splice_pos_list.pass.cpp @@ -11,13 +11,10 @@ // void splice(const_iterator position, list& x); -#if _LIBCPP_DEBUG >= 1 -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - #include <list> #include <cassert> +#include "test_macros.h" #include "min_allocator.h" int main() @@ -403,15 +400,7 @@ int main() ++i; assert(*i == 6); } -#if _LIBCPP_DEBUG >= 1 - { - std::list<int> v1(3); - std::list<int> v2(3); - v1.splice(v2.begin(), v2); - assert(false); - } -#endif -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> l1; std::list<int, min_allocator<int>> l2; @@ -791,13 +780,5 @@ int main() ++i; assert(*i == 6); } -#if _LIBCPP_DEBUG >= 1 - { - std::list<int, min_allocator<int>> v1(3); - std::list<int, min_allocator<int>> v2(3); - v1.splice(v2.begin(), v2); - assert(false); - } -#endif #endif } diff --git a/test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp b/test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp index 5082c3f85175..427624a1cc3e 100644 --- a/test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp +++ b/test/std/containers/sequences/list/list.ops/splice_pos_list_iter.pass.cpp @@ -11,13 +11,10 @@ // void splice(const_iterator position, list<T,Allocator>& x, iterator i); -#if _LIBCPP_DEBUG >= 1 -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - #include <list> #include <cassert> +#include "test_macros.h" #include "min_allocator.h" int main() @@ -180,15 +177,7 @@ int main() ++i; assert(*i == 2); } -#if _LIBCPP_DEBUG >= 1 - { - std::list<int> v1(3); - std::list<int> v2(3); - v1.splice(v1.begin(), v2, v1.begin()); - assert(false); - } -#endif -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> l1; std::list<int, min_allocator<int>> l2(a2, a2+1); @@ -345,13 +334,5 @@ int main() ++i; assert(*i == 2); } -#if _LIBCPP_DEBUG >= 1 - { - std::list<int, min_allocator<int>> v1(3); - std::list<int, min_allocator<int>> v2(3); - v1.splice(v1.begin(), v2, v1.begin()); - assert(false); - } -#endif #endif } diff --git a/test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp b/test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp index fcc4acceec57..b7010636d20e 100644 --- a/test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp +++ b/test/std/containers/sequences/list/list.ops/splice_pos_list_iter_iter.pass.cpp @@ -11,13 +11,10 @@ // void splice(const_iterator position, list& x, iterator first, iterator last); -#if _LIBCPP_DEBUG >= 1 -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - #include <list> #include <cassert> +#include "test_macros.h" #include "min_allocator.h" int main() @@ -120,15 +117,7 @@ int main() i = l2.begin(); assert(*i == 4); } -#if _LIBCPP_DEBUG >= 1 - { - std::list<int> v1(3); - std::list<int> v2(3); - v1.splice(v1.begin(), v2, v2.begin(), v1.end()); - assert(false); - } -#endif -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::list<int, min_allocator<int>> l1(a1, a1+3); l1.splice(l1.begin(), l1, next(l1.begin()), next(l1.begin())); @@ -225,13 +214,5 @@ int main() i = l2.begin(); assert(*i == 4); } -#if _LIBCPP_DEBUG >= 1 - { - std::list<int, min_allocator<int>> v1(3); - std::list<int, min_allocator<int>> v2(3); - v1.splice(v1.begin(), v2, v2.begin(), v1.end()); - assert(false); - } -#endif #endif } diff --git a/test/std/containers/sequences/list/list.ops/unique.pass.cpp b/test/std/containers/sequences/list/list.ops/unique.pass.cpp index 48cad1ddd156..fa85b0eae77c 100644 --- a/test/std/containers/sequences/list/list.ops/unique.pass.cpp +++ b/test/std/containers/sequences/list/list.ops/unique.pass.cpp @@ -25,7 +25,7 @@ int main() c.unique(); assert(c == std::list<int>(a2, a2+4)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3}; int a2[] = {2, 1, 4, 3}; diff --git a/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp b/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp index f8935b81f6a7..de6347d46f39 100644 --- a/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp +++ b/test/std/containers/sequences/list/list.ops/unique_pred.pass.cpp @@ -30,7 +30,7 @@ int main() c.unique(g); assert(c == std::list<int>(a2, a2+4)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {2, 1, 1, 4, 4, 4, 4, 3, 3}; int a2[] = {2, 1, 4, 3}; diff --git a/test/std/containers/sequences/list/list.special/db_swap_1.pass.cpp b/test/std/containers/sequences/list/list.special/db_swap_1.pass.cpp deleted file mode 100644 index f7171795cd5f..000000000000 --- a/test/std/containers/sequences/list/list.special/db_swap_1.pass.cpp +++ /dev/null @@ -1,59 +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. -// -//===----------------------------------------------------------------------===// - -// <list> - -// template <class T, class Alloc> -// void swap(list<T,Alloc>& x, list<T,Alloc>& y); - -#if _LIBCPP_DEBUG >= 1 -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) -#endif - -#include <list> -#include <cassert> - -#include <__debug> -#include "min_allocator.h" - -int main() -{ -#if _LIBCPP_DEBUG >= 1 - { - int a1[] = {1, 3, 7, 9, 10}; - int a2[] = {0, 2, 4, 5, 6, 8, 11}; - std::list<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); - std::list<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0])); - std::list<int>::iterator i1 = c1.begin(); - std::list<int>::iterator i2 = c2.begin(); - swap(c1, c2); - c1.erase(i2); - c2.erase(i1); - std::list<int>::iterator j = i1; - c1.erase(i1); - assert(false); - } -#if __cplusplus >= 201103L - { - int a1[] = {1, 3, 7, 9, 10}; - int a2[] = {0, 2, 4, 5, 6, 8, 11}; - std::list<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); - std::list<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0])); - std::list<int, min_allocator<int>>::iterator i1 = c1.begin(); - std::list<int, min_allocator<int>>::iterator i2 = c2.begin(); - swap(c1, c2); - c1.erase(i2); - c2.erase(i1); - std::list<int, min_allocator<int>>::iterator j = i1; - c1.erase(i1); - assert(false); - } -#endif -#endif -} diff --git a/test/std/containers/sequences/list/list.special/swap.pass.cpp b/test/std/containers/sequences/list/list.special/swap.pass.cpp index bc5f4857edc7..54b262572ded 100644 --- a/test/std/containers/sequences/list/list.special/swap.pass.cpp +++ b/test/std/containers/sequences/list/list.special/swap.pass.cpp @@ -59,21 +59,18 @@ int main() assert(c2.empty()); assert(distance(c2.begin(), c2.end()) == 0); } -#ifndef _LIBCPP_DEBUG_LEVEL -// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1 { int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; typedef test_allocator<int> A; std::list<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1)); - std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2)); + std::list<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(1)); swap(c1, c2); assert((c1 == std::list<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0])))); assert(c1.get_allocator() == A(1)); assert((c2 == std::list<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0])))); - assert(c2.get_allocator() == A(2)); + assert(c2.get_allocator() == A(1)); } -#endif { int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; @@ -86,7 +83,7 @@ int main() assert((c2 == std::list<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0])))); assert(c2.get_allocator() == A(1)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; @@ -127,8 +124,6 @@ int main() assert(c2.empty()); assert(distance(c2.begin(), c2.end()) == 0); } -#ifndef _LIBCPP_DEBUG_LEVEL -// This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1 { int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; @@ -142,5 +137,4 @@ int main() assert(c2.get_allocator() == A()); } #endif -#endif } diff --git a/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp b/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp index 9c83ad58fed4..820da4c78f81 100644 --- a/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/list/list.special/swap_noexcept.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <list> // void swap(list& c) @@ -21,6 +23,7 @@ #include <list> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -28,7 +31,7 @@ template <class T> struct some_alloc { typedef T value_type; - + some_alloc() {} some_alloc(const some_alloc&); void deallocate(void*, unsigned) {} @@ -40,7 +43,7 @@ template <class T> struct some_alloc2 { typedef T value_type; - + some_alloc2() {} some_alloc2(const some_alloc2&); void deallocate(void*, unsigned) {} @@ -51,7 +54,6 @@ struct some_alloc2 int main() { -#if __has_feature(cxx_noexcept) { typedef std::list<MoveOnly> C; C c1, c2; @@ -86,5 +88,4 @@ int main() } #endif -#endif } diff --git a/test/std/containers/sequences/list/types.pass.cpp b/test/std/containers/sequences/list/types.pass.cpp index 77303601ae97..7d5f5b6fa2f0 100644 --- a/test/std/containers/sequences/list/types.pass.cpp +++ b/test/std/containers/sequences/list/types.pass.cpp @@ -31,18 +31,39 @@ struct A { std::list<A> v; }; // incomplete type support int main() { - static_assert((std::is_same<std::list<int>::value_type, int>::value), ""); - static_assert((std::is_same<std::list<int>::allocator_type, std::allocator<int> >::value), ""); - static_assert((std::is_same<std::list<int>::reference, std::allocator<int>::reference>::value), ""); - static_assert((std::is_same<std::list<int>::const_reference, std::allocator<int>::const_reference>::value), ""); - static_assert((std::is_same<std::list<int>::pointer, std::allocator<int>::pointer>::value), ""); - static_assert((std::is_same<std::list<int>::const_pointer, std::allocator<int>::const_pointer>::value), ""); -#if __cplusplus >= 201103L - static_assert((std::is_same<std::list<int, min_allocator<int>>::value_type, int>::value), ""); - static_assert((std::is_same<std::list<int, min_allocator<int>>::allocator_type, min_allocator<int> >::value), ""); - static_assert((std::is_same<std::list<int, min_allocator<int>>::reference, int&>::value), ""); - static_assert((std::is_same<std::list<int, min_allocator<int>>::const_reference, const int&>::value), ""); - static_assert((std::is_same<std::list<int, min_allocator<int>>::pointer, min_pointer<int>>::value), ""); - static_assert((std::is_same<std::list<int, min_allocator<int>>::const_pointer, min_pointer<const int>>::value), ""); + { + typedef std::list<int> C; + static_assert((std::is_same<C::value_type, int>::value), ""); + static_assert((std::is_same<C::allocator_type, std::allocator<int> >::value), ""); + static_assert((std::is_same<C::reference, std::allocator<int>::reference>::value), ""); + static_assert((std::is_same<C::const_reference, std::allocator<int>::const_reference>::value), ""); + static_assert((std::is_same<C::pointer, std::allocator<int>::pointer>::value), ""); + static_assert((std::is_same<C::const_pointer, std::allocator<int>::const_pointer>::value), ""); + + static_assert((std::is_signed<typename C::difference_type>::value), ""); + static_assert((std::is_unsigned<typename C::size_type>::value), ""); + static_assert((std::is_same<typename C::difference_type, + typename std::iterator_traits<typename C::iterator>::difference_type>::value), ""); + static_assert((std::is_same<typename C::difference_type, + typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), ""); + } + +#if TEST_STD_VER >= 11 + { + typedef std::list<int, min_allocator<int>> C; + static_assert((std::is_same<C::value_type, int>::value), ""); + static_assert((std::is_same<C::allocator_type, min_allocator<int> >::value), ""); + static_assert((std::is_same<C::reference, int&>::value), ""); + static_assert((std::is_same<C::const_reference, const int&>::value), ""); + static_assert((std::is_same<C::pointer, min_pointer<int>>::value), ""); + static_assert((std::is_same<C::const_pointer, min_pointer<const int>>::value), ""); + + static_assert((std::is_signed<typename C::difference_type>::value), ""); + static_assert((std::is_unsigned<typename C::size_type>::value), ""); + static_assert((std::is_same<typename C::difference_type, + typename std::iterator_traits<typename C::iterator>::difference_type>::value), ""); + static_assert((std::is_same<typename C::difference_type, + typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), ""); + } #endif } diff --git a/test/std/containers/sequences/list/version.pass.cpp b/test/std/containers/sequences/list/version.pass.cpp deleted file mode 100644 index 097c013f52cb..000000000000 --- a/test/std/containers/sequences/list/version.pass.cpp +++ /dev/null @@ -1,20 +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. -// -//===----------------------------------------------------------------------===// - -// <list> - -#include <list> - -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif - -int main() -{ -} diff --git a/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp b/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp index 9501799ae3d0..54b7e84bb092 100644 --- a/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp +++ b/test/std/containers/sequences/vector.bool/assign_copy.pass.cpp @@ -19,22 +19,22 @@ int main() { { - std::vector<bool, test_allocator<bool> > l(3, 2, test_allocator<bool>(5)); + std::vector<bool, test_allocator<bool> > l(3, true, test_allocator<bool>(5)); std::vector<bool, test_allocator<bool> > l2(l, test_allocator<bool>(3)); l2 = l; assert(l2 == l); assert(l2.get_allocator() == test_allocator<bool>(3)); } { - std::vector<bool, other_allocator<bool> > l(3, 2, other_allocator<bool>(5)); + std::vector<bool, other_allocator<bool> > l(3, true, other_allocator<bool>(5)); std::vector<bool, other_allocator<bool> > l2(l, other_allocator<bool>(3)); l2 = l; assert(l2 == l); assert(l2.get_allocator() == other_allocator<bool>(5)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { - std::vector<bool, min_allocator<bool> > l(3, 2, min_allocator<bool>()); + std::vector<bool, min_allocator<bool> > l(3, true, min_allocator<bool>()); std::vector<bool, min_allocator<bool> > l2(l, min_allocator<bool>()); l2 = l; assert(l2 == l); diff --git a/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp index 2925fbc66745..ac7a2ce38adf 100644 --- a/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector.bool/assign_initializer_list.pass.cpp @@ -28,7 +28,7 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d; d.assign({true, false, false, true}); diff --git a/test/std/containers/sequences/vector.bool/assign_move.pass.cpp b/test/std/containers/sequences/vector.bool/assign_move.pass.cpp index df98c817fd59..f07c1d90059d 100644 --- a/test/std/containers/sequences/vector.bool/assign_move.pass.cpp +++ b/test/std/containers/sequences/vector.bool/assign_move.pass.cpp @@ -61,7 +61,7 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{}); std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{}); diff --git a/test/std/containers/sequences/vector.bool/capacity.pass.cpp b/test/std/containers/sequences/vector.bool/capacity.pass.cpp index 63bff25f9f9a..3cbb09fe4ef0 100644 --- a/test/std/containers/sequences/vector.bool/capacity.pass.cpp +++ b/test/std/containers/sequences/vector.bool/capacity.pass.cpp @@ -29,7 +29,7 @@ int main() v.push_back(0); assert(v.capacity() >= 101); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> v; assert(v.capacity() == 0); diff --git a/test/std/containers/sequences/vector.bool/construct_default.pass.cpp b/test/std/containers/sequences/vector.bool/construct_default.pass.cpp index 07824098fc6f..983d363d1940 100644 --- a/test/std/containers/sequences/vector.bool/construct_default.pass.cpp +++ b/test/std/containers/sequences/vector.bool/construct_default.pass.cpp @@ -29,12 +29,12 @@ test0() static_assert((noexcept(C()) == noexcept(typename C::allocator_type())), "" ); #endif C c; - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(c.empty()); assert(c.get_allocator() == typename C::allocator_type()); #if TEST_STD_VER >= 11 C c1 = {}; - assert(c1.__invariants()); + LIBCPP_ASSERT(c1.__invariants()); assert(c1.empty()); assert(c1.get_allocator() == typename C::allocator_type()); #endif @@ -50,7 +50,7 @@ test1(const typename C::allocator_type& a) static_assert((noexcept(C(typename C::allocator_type())) == std::is_nothrow_copy_constructible<typename C::allocator_type>::value), "" ); #endif C c(a); - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(c.empty()); assert(c.get_allocator() == a); } diff --git a/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp b/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp index 94e6801825d8..3d11239702c9 100644 --- a/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp +++ b/test/std/containers/sequences/vector.bool/construct_iter_iter.pass.cpp @@ -15,6 +15,7 @@ #include <vector> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" #include "min_allocator.h" @@ -23,7 +24,7 @@ void test(Iterator first, Iterator last) { C c(first, last); - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(c.size() == std::distance(first, last)); for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first) assert(*i == *first); @@ -38,7 +39,7 @@ int main() test<std::vector<bool> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an)); test<std::vector<bool> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an)); test<std::vector<bool> >(a, an); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 test<std::vector<bool, min_allocator<bool>> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an)); test<std::vector<bool, min_allocator<bool>> >(forward_iterator<const bool*>(a), forward_iterator<const bool*>(an)); test<std::vector<bool, min_allocator<bool>> >(bidirectional_iterator<const bool*>(a), bidirectional_iterator<const bool*>(an)); diff --git a/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp index ea9d41d342f8..196694d73998 100644 --- a/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp +++ b/test/std/containers/sequences/vector.bool/construct_iter_iter_alloc.pass.cpp @@ -16,6 +16,7 @@ #include <vector> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" #include "min_allocator.h" @@ -24,7 +25,7 @@ void test(Iterator first, Iterator last, const typename C::allocator_type& a) { C c(first, last, a); - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(c.size() == std::distance(first, last)); for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first) assert(*i == *first); @@ -42,7 +43,7 @@ int main() test<std::vector<bool> >(random_access_iterator<const bool*>(a), random_access_iterator<const bool*>(an), alloc); test<std::vector<bool> >(a, an, alloc); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { min_allocator<bool> alloc; test<std::vector<bool, min_allocator<bool>> >(input_iterator<const bool*>(a), input_iterator<const bool*>(an), alloc); diff --git a/test/std/containers/sequences/vector.bool/construct_size.pass.cpp b/test/std/containers/sequences/vector.bool/construct_size.pass.cpp index 93ecbe87c380..271e4ee33aa4 100644 --- a/test/std/containers/sequences/vector.bool/construct_size.pass.cpp +++ b/test/std/containers/sequences/vector.bool/construct_size.pass.cpp @@ -15,22 +15,22 @@ #include <vector> #include <cassert> +#include "test_macros.h" #include "min_allocator.h" #include "test_allocator.h" template <class C> void -test2(typename C::size_type n, typename C::allocator_type const& a = typename C::allocator_type ()) +test2(typename C::size_type n, + typename C::allocator_type const& a = typename C::allocator_type ()) { -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER >= 14 C c(n, a); - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(c.size() == n); assert(c.get_allocator() == a); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) assert(*i == typename C::value_type()); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif } @@ -39,7 +39,7 @@ void test1(typename C::size_type n) { C c(n); - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(c.size() == n); assert(c.get_allocator() == typename C::allocator_type()); for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) @@ -57,7 +57,7 @@ test(typename C::size_type n) int main() { test<std::vector<bool> >(50); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 test<std::vector<bool, min_allocator<bool>> >(50); test2<std::vector<bool, test_allocator<bool>> >( 100, test_allocator<bool>(23)); #endif diff --git a/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp b/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp index fc772f10dfc4..c66fd4972899 100644 --- a/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp +++ b/test/std/containers/sequences/vector.bool/construct_size_value.pass.cpp @@ -15,6 +15,7 @@ #include <vector> #include <cassert> +#include "test_macros.h" #include "min_allocator.h" template <class C> @@ -22,7 +23,7 @@ void test(typename C::size_type n, const typename C::value_type& x) { C c(n, x); - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(c.size() == n); for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) assert(*i == x); @@ -30,8 +31,8 @@ test(typename C::size_type n, const typename C::value_type& x) int main() { - test<std::vector<bool> >(50, 3); -#if __cplusplus >= 201103L - test<std::vector<bool, min_allocator<bool>> >(50, 3); + test<std::vector<bool> >(50, true); +#if TEST_STD_VER >= 11 + test<std::vector<bool, min_allocator<bool>> >(50, true); #endif } diff --git a/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp index 6cca948ed834..2ef501271f52 100644 --- a/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp +++ b/test/std/containers/sequences/vector.bool/construct_size_value_alloc.pass.cpp @@ -15,6 +15,7 @@ #include <vector> #include <cassert> +#include "test_macros.h" #include "min_allocator.h" template <class C> @@ -23,7 +24,7 @@ test(typename C::size_type n, const typename C::value_type& x, const typename C::allocator_type& a) { C c(n, x, a); - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(a == c.get_allocator()); assert(c.size() == n); for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) @@ -32,8 +33,8 @@ test(typename C::size_type n, const typename C::value_type& x, int main() { - test<std::vector<bool> >(50, 3, std::allocator<bool>()); -#if __cplusplus >= 201103L - test<std::vector<bool, min_allocator<bool>> >(50, 3, min_allocator<bool>()); + test<std::vector<bool> >(50, true, std::allocator<bool>()); +#if TEST_STD_VER >= 11 + test<std::vector<bool, min_allocator<bool>> >(50, true, min_allocator<bool>()); #endif } diff --git a/test/std/containers/sequences/vector.bool/copy.pass.cpp b/test/std/containers/sequences/vector.bool/copy.pass.cpp index 58822782ff8b..b3cf9b551f96 100644 --- a/test/std/containers/sequences/vector.bool/copy.pass.cpp +++ b/test/std/containers/sequences/vector.bool/copy.pass.cpp @@ -14,6 +14,8 @@ #include <vector> #include <cassert> + +#include "test_macros.h" #include "test_allocator.h" #include "min_allocator.h" @@ -23,7 +25,7 @@ test(const C& x) { unsigned s = x.size(); C c(x); - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(c.size() == s); assert(c == x); } @@ -36,27 +38,25 @@ int main() test(std::vector<bool>(a, an)); } { - std::vector<bool, test_allocator<bool> > v(3, 2, test_allocator<bool>(5)); + std::vector<bool, test_allocator<bool> > v(3, true, test_allocator<bool>(5)); std::vector<bool, test_allocator<bool> > v2 = v; assert(v2 == v); assert(v2.get_allocator() == v.get_allocator()); } -#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE +#if TEST_STD_VER >= 11 { - std::vector<bool, other_allocator<bool> > v(3, 2, other_allocator<bool>(5)); + std::vector<bool, other_allocator<bool> > v(3, true, other_allocator<bool>(5)); std::vector<bool, other_allocator<bool> > v2 = v; assert(v2 == v); assert(v2.get_allocator() == other_allocator<bool>(-2)); } -#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE -#if __cplusplus >= 201103L { bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}; bool* an = a + sizeof(a)/sizeof(a[0]); test(std::vector<bool, min_allocator<bool>>(a, an)); } { - std::vector<bool, min_allocator<bool> > v(3, 2, min_allocator<bool>()); + std::vector<bool, min_allocator<bool> > v(3, true, min_allocator<bool>()); std::vector<bool, min_allocator<bool> > v2 = v; assert(v2 == v); assert(v2.get_allocator() == v.get_allocator()); diff --git a/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp index 2f0192b995ad..aa8646a9b819 100644 --- a/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp +++ b/test/std/containers/sequences/vector.bool/copy_alloc.pass.cpp @@ -13,6 +13,8 @@ #include <vector> #include <cassert> + +#include "test_macros.h" #include "test_allocator.h" #include "min_allocator.h" @@ -22,7 +24,7 @@ test(const C& x, const typename C::allocator_type& a) { unsigned s = x.size(); C c(x, a); - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(c.size() == s); assert(c == x); } @@ -30,30 +32,30 @@ test(const C& x, const typename C::allocator_type& a) int main() { { - int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0}; - int* an = a + sizeof(a)/sizeof(a[0]); + bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}; + bool* an = a + sizeof(a)/sizeof(a[0]); test(std::vector<bool>(a, an), std::allocator<bool>()); } { - std::vector<bool, test_allocator<bool> > l(3, 2, test_allocator<bool>(5)); + std::vector<bool, test_allocator<bool> > l(3, true, test_allocator<bool>(5)); std::vector<bool, test_allocator<bool> > l2(l, test_allocator<bool>(3)); assert(l2 == l); assert(l2.get_allocator() == test_allocator<bool>(3)); } { - std::vector<bool, other_allocator<bool> > l(3, 2, other_allocator<bool>(5)); + std::vector<bool, other_allocator<bool> > l(3, true, other_allocator<bool>(5)); std::vector<bool, other_allocator<bool> > l2(l, other_allocator<bool>(3)); assert(l2 == l); assert(l2.get_allocator() == other_allocator<bool>(3)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { - int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0}; - int* an = a + sizeof(a)/sizeof(a[0]); + bool a[] = {0, 1, 0, 0, 1, 1, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0}; + bool* an = a + sizeof(a)/sizeof(a[0]); test(std::vector<bool, min_allocator<bool>>(a, an), min_allocator<bool>()); } { - std::vector<bool, min_allocator<bool> > l(3, 2, min_allocator<bool>()); + std::vector<bool, min_allocator<bool> > l(3, true, min_allocator<bool>()); std::vector<bool, min_allocator<bool> > l2(l, min_allocator<bool>()); assert(l2 == l); assert(l2.get_allocator() == min_allocator<bool>()); diff --git a/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp index b94588ead93b..4f860dabac95 100644 --- a/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/default_noexcept.pass.cpp @@ -14,9 +14,12 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <vector> #include <cassert> +#include "test_macros.h" #include "test_allocator.h" template <class T> @@ -28,14 +31,13 @@ struct some_alloc int main() { -#if __has_feature(cxx_noexcept) { typedef std::vector<bool> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::vector<bool, test_allocator<bool>> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::vector<bool, other_allocator<bool>> C; @@ -45,5 +47,4 @@ int main() typedef std::vector<bool, some_alloc<bool>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp index 682e74ef03c2..bd2534ad3de7 100644 --- a/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/dtor_noexcept.pass.cpp @@ -11,13 +11,13 @@ // ~vector<bool>() // implied noexcept; +// UNSUPPORTED: c++98, c++03 + #include <vector> #include <cassert> #include "test_allocator.h" -#if __has_feature(cxx_noexcept) - template <class T> struct some_alloc { @@ -26,11 +26,8 @@ struct some_alloc ~some_alloc() noexcept(false); }; -#endif - int main() { -#if __has_feature(cxx_noexcept) { typedef std::vector<bool> C; static_assert(std::is_nothrow_destructible<C>::value, ""); @@ -47,5 +44,4 @@ int main() typedef std::vector<bool, some_alloc<bool>> C; static_assert(!std::is_nothrow_destructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/sequences/vector.bool/emplace.pass.cpp b/test/std/containers/sequences/vector.bool/emplace.pass.cpp index f3fd1e9926f0..ccdce913c73c 100644 --- a/test/std/containers/sequences/vector.bool/emplace.pass.cpp +++ b/test/std/containers/sequences/vector.bool/emplace.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11 // <vector> // vector<bool> @@ -18,11 +19,10 @@ int main() { -#if _LIBCPP_STD_VER > 11 { typedef std::vector<bool> C; C c; - + C::iterator i = c.emplace(c.cbegin()); assert(i == c.begin()); assert(c.size() == 1); @@ -64,5 +64,4 @@ int main() assert(c[1] == true); assert(c.back() == true); } -#endif } diff --git a/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp b/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp index 57aa47822f8a..2950ee3882f1 100644 --- a/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp +++ b/test/std/containers/sequences/vector.bool/emplace_back.pass.cpp @@ -7,6 +7,7 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03, c++11 // <vector> // vector.bool @@ -19,7 +20,6 @@ int main() { -#if _LIBCPP_STD_VER > 11 { typedef std::vector<bool> C; C c; @@ -39,7 +39,7 @@ int main() { typedef std::vector<bool, min_allocator<bool>> C; C c; - + c.emplace_back(); assert(c.size() == 1); assert(c.front() == false); @@ -53,5 +53,4 @@ int main() assert(c[1] == true); assert(c.back() == true); } -#endif } diff --git a/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp b/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp index cbf26dd570a5..04e3dd7c25f1 100644 --- a/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp +++ b/test/std/containers/sequences/vector.bool/erase_iter.pass.cpp @@ -40,7 +40,7 @@ int main() assert(l1.size() == 0); assert(distance(l1.begin(), l1.end()) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> l1(a1, a1+3); std::vector<bool, min_allocator<bool>>::const_iterator i = l1.begin(); diff --git a/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp b/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp index 2c2c4cc48616..2b9f0e31c2fa 100644 --- a/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp +++ b/test/std/containers/sequences/vector.bool/erase_iter_iter.pass.cpp @@ -50,7 +50,7 @@ int main() assert(distance(l1.cbegin(), l1.cend()) == 0); assert(i == l1.begin()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> l1(a1, a1+3); std::vector<bool, min_allocator<bool>>::iterator i = l1.erase(l1.cbegin(), l1.cbegin()); diff --git a/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp index b9b468654497..07bae0eb7089 100644 --- a/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector.bool/initializer_list.pass.cpp @@ -27,7 +27,7 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d = {true, false, false, true}; assert(d.size() == 4); diff --git a/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp index aea3ad763cde..5f7f5144f841 100644 --- a/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp +++ b/test/std/containers/sequences/vector.bool/initializer_list_alloc.pass.cpp @@ -29,7 +29,7 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d({true, false, false, true}, min_allocator<bool>()); assert(d.get_allocator() == min_allocator<bool>()); diff --git a/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp index c081cc81c592..3a176d94e860 100644 --- a/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector.bool/insert_iter_initializer_list.pass.cpp @@ -39,7 +39,7 @@ int main() assert(d[12] == true); assert(d[13] == true); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d(10, true); std::vector<bool, min_allocator<bool>>::iterator i = d.insert(d.cbegin() + 2, {false, true, true, false}); diff --git a/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp b/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp index e51f8b589c7f..89fe7a76d409 100644 --- a/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp +++ b/test/std/containers/sequences/vector.bool/insert_iter_iter_iter.pass.cpp @@ -89,7 +89,7 @@ int main() for (; j < v.size(); ++j) assert(v[j] == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> v(100); bool a[] = {1, 0, 0, 1, 1}; diff --git a/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp b/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp index 710ad4885f09..35c57cbd8e42 100644 --- a/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp +++ b/test/std/containers/sequences/vector.bool/insert_iter_size_value.pass.cpp @@ -63,7 +63,7 @@ int main() for (++j; j < v.size(); ++j) assert(v[j] == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> v(100); std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, 5, 1); diff --git a/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp b/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp index 51c4626de0d0..78ffe7ba73cd 100644 --- a/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp +++ b/test/std/containers/sequences/vector.bool/insert_iter_value.pass.cpp @@ -60,7 +60,7 @@ int main() for (++j; j < v.size(); ++j) assert(v[j] == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> v(100); std::vector<bool, min_allocator<bool>>::iterator i = v.insert(v.cbegin() + 10, 1); diff --git a/test/std/containers/sequences/vector.bool/iterators.pass.cpp b/test/std/containers/sequences/vector.bool/iterators.pass.cpp index c54fa4a80a95..882ac9be4a5d 100644 --- a/test/std/containers/sequences/vector.bool/iterators.pass.cpp +++ b/test/std/containers/sequences/vector.bool/iterators.pass.cpp @@ -58,7 +58,7 @@ int main() C::iterator i; C::const_iterator j; } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef bool T; typedef std::vector<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/vector.bool/move.pass.cpp b/test/std/containers/sequences/vector.bool/move.pass.cpp index e877292ced77..f3a11ec562c0 100644 --- a/test/std/containers/sequences/vector.bool/move.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move.pass.cpp @@ -45,7 +45,7 @@ int main() assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{}); std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{}); diff --git a/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp b/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp index deee93261971..7aaa7c55550b 100644 --- a/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move_alloc.pass.cpp @@ -58,7 +58,7 @@ int main() assert(!l.empty()); assert(l2.get_allocator() == other_allocator<bool>(4)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool> > l(min_allocator<bool>{}); std::vector<bool, min_allocator<bool> > lo(min_allocator<bool>{}); diff --git a/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp index 4dd871c9447e..fe53fbfc17e0 100644 --- a/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move_assign_noexcept.pass.cpp @@ -16,6 +16,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <vector> #include <cassert> @@ -32,7 +34,7 @@ template <class T> struct some_alloc2 { typedef T value_type; - + some_alloc2() {} some_alloc2(const some_alloc2&); void deallocate(void*, unsigned) {} @@ -45,7 +47,7 @@ template <class T> struct some_alloc3 { typedef T value_type; - + some_alloc3() {} some_alloc3(const some_alloc3&); void deallocate(void*, unsigned) {} @@ -56,7 +58,6 @@ struct some_alloc3 int main() { -#if __has_feature(cxx_noexcept) { typedef std::vector<bool> C; static_assert(std::is_nothrow_move_assignable<C>::value, ""); @@ -87,6 +88,4 @@ int main() static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } #endif - -#endif } diff --git a/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp index 132186b555f2..2153c7956bfc 100644 --- a/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/move_noexcept.pass.cpp @@ -14,6 +14,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <vector> #include <cassert> @@ -28,7 +30,6 @@ struct some_alloc int main() { -#if __has_feature(cxx_noexcept) { typedef std::vector<bool> C; static_assert(std::is_nothrow_move_constructible<C>::value, ""); @@ -50,5 +51,4 @@ int main() static_assert(!std::is_nothrow_move_constructible<C>::value, ""); #endif } -#endif } diff --git a/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp b/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp index ef3dc5d10796..4b959cf00ad3 100644 --- a/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector.bool/op_equal_initializer_list.pass.cpp @@ -28,7 +28,7 @@ int main() assert(d[2] == false); assert(d[3] == true); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> d; d = {true, false, false, true}; diff --git a/test/std/containers/sequences/vector.bool/push_back.pass.cpp b/test/std/containers/sequences/vector.bool/push_back.pass.cpp index c6b0fbf41853..3897a438b445 100644 --- a/test/std/containers/sequences/vector.bool/push_back.pass.cpp +++ b/test/std/containers/sequences/vector.bool/push_back.pass.cpp @@ -31,7 +31,7 @@ int main() assert(c[j] == a[j]); } } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { bool a[] = {0, 1, 1, 0, 1, 0, 0}; const unsigned N = sizeof(a)/sizeof(a[0]); diff --git a/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp b/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp new file mode 100644 index 000000000000..06351e418ac4 --- /dev/null +++ b/test/std/containers/sequences/vector.bool/reference.swap.pass.cpp @@ -0,0 +1,39 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <vector> +// vector<bool> + +// static void swap(reference x, reference y) noexcept; + +#include <vector> +#include <cassert> + +#include "test_macros.h" + +int main() +{ + + bool a[] = {false, true, false, true}; + bool* an = a + sizeof(a)/sizeof(a[0]); + + std::vector<bool> v(a, an); + std::vector<bool>::reference r1 = v[0]; + std::vector<bool>::reference r2 = v[3]; + +#if TEST_STD_VER >= 11 + static_assert((noexcept(v.swap(r1,r2))), ""); +#endif + + assert(!r1); + assert( r2); + v.swap(r1, r2); + assert( r1); + assert(!r2); +} diff --git a/test/std/containers/sequences/vector.bool/reserve.pass.cpp b/test/std/containers/sequences/vector.bool/reserve.pass.cpp index be717a3be8a8..489ca95ee789 100644 --- a/test/std/containers/sequences/vector.bool/reserve.pass.cpp +++ b/test/std/containers/sequences/vector.bool/reserve.pass.cpp @@ -34,7 +34,7 @@ int main() assert(v.size() == 100); assert(v.capacity() >= 150); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> v; v.reserve(10); diff --git a/test/std/containers/sequences/vector.bool/resize_size.pass.cpp b/test/std/containers/sequences/vector.bool/resize_size.pass.cpp index f75720c94ea3..bc51e0bbba27 100644 --- a/test/std/containers/sequences/vector.bool/resize_size.pass.cpp +++ b/test/std/containers/sequences/vector.bool/resize_size.pass.cpp @@ -32,7 +32,7 @@ int main() assert(v.size() == 300); assert(v.capacity() >= 400); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> v(100); v.resize(50); diff --git a/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp b/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp index 8cecf44d2fb0..919000732698 100644 --- a/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp +++ b/test/std/containers/sequences/vector.bool/resize_size_value.pass.cpp @@ -33,7 +33,7 @@ int main() for (unsigned i = 50; i < 200; ++i) assert(v[i] == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> v(100); v.resize(50, 1); diff --git a/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp b/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp index 1f9fcac3d9bf..03997cbec71e 100644 --- a/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp +++ b/test/std/containers/sequences/vector.bool/shrink_to_fit.pass.cpp @@ -26,7 +26,7 @@ int main() assert(v.capacity() >= 101); assert(v.size() >= 101); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> v(100); v.push_back(1); diff --git a/test/std/containers/sequences/vector.bool/swap.pass.cpp b/test/std/containers/sequences/vector.bool/swap.pass.cpp index a92c6a6c165f..81af528f2a9a 100644 --- a/test/std/containers/sequences/vector.bool/swap.pass.cpp +++ b/test/std/containers/sequences/vector.bool/swap.pass.cpp @@ -62,7 +62,7 @@ int main() assert(v[0] == false); assert(v[1] == true); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<bool, min_allocator<bool>> v1(100); std::vector<bool, min_allocator<bool>> v2(200); diff --git a/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp b/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp index 6f36473fa989..7ba44453b371 100644 --- a/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector.bool/swap_noexcept.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // void swap(vector& c) @@ -22,13 +24,14 @@ #include <vector> #include <cassert> +#include "test_macros.h" #include "test_allocator.h" template <class T> struct some_alloc { typedef T value_type; - + some_alloc() {} some_alloc(const some_alloc&); void deallocate(void*, unsigned) {} @@ -40,7 +43,7 @@ template <class T> struct some_alloc2 { typedef T value_type; - + some_alloc2() {} some_alloc2(const some_alloc2&); void deallocate(void*, unsigned) {} @@ -51,7 +54,6 @@ struct some_alloc2 int main() { -#if __has_feature(cxx_noexcept) { typedef std::vector<bool> C; C c1, c2; @@ -85,6 +87,4 @@ int main() static_assert( noexcept(swap(c1, c2)), ""); } #endif - -#endif } diff --git a/test/std/containers/sequences/vector.bool/types.pass.cpp b/test/std/containers/sequences/vector.bool/types.pass.cpp index b266b3bbb927..4e8edc8891bd 100644 --- a/test/std/containers/sequences/vector.bool/types.pass.cpp +++ b/test/std/containers/sequences/vector.bool/types.pass.cpp @@ -46,7 +46,15 @@ test() static_assert((std::is_same<typename C::allocator_type, Allocator>::value), ""); static_assert((std::is_same<typename C::size_type, typename std::allocator_traits<Allocator>::size_type>::value), ""); static_assert((std::is_same<typename C::difference_type, typename std::allocator_traits<Allocator>::difference_type>::value), ""); - static_assert((std::is_same< + + static_assert((std::is_signed<typename C::difference_type>::value), ""); + static_assert((std::is_unsigned<typename C::size_type>::value), ""); + static_assert((std::is_same<typename C::difference_type, + typename std::iterator_traits<typename C::iterator>::difference_type>::value), ""); + static_assert((std::is_same<typename C::difference_type, + typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), ""); + + static_assert((std::is_same< typename std::iterator_traits<typename C::iterator>::iterator_category, std::random_access_iterator_tag>::value), ""); static_assert((std::is_same< @@ -66,7 +74,7 @@ int main() test<std::allocator<bool> >(); static_assert((std::is_same<std::vector<bool>::allocator_type, std::allocator<bool> >::value), ""); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 test<min_allocator<bool> >(); #endif } diff --git a/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp b/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp index a78f4fd590be..4f82792fa1fd 100644 --- a/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp +++ b/test/std/containers/sequences/vector.bool/vector_bool.pass.cpp @@ -31,18 +31,18 @@ int main() typedef std::hash<T> H; static_assert((std::is_same<H::argument_type, T>::value), "" ); static_assert((std::is_same<H::result_type, std::size_t>::value), "" ); - + bool ba[] = {true, false, true, true, false}; T vb(std::begin(ba), std::end(ba)); H h; assert(h(vb) != 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::vector<bool, min_allocator<bool>> T; typedef std::hash<T> H; - static_assert((std::is_base_of<std::unary_function<T, std::size_t>, - H>::value), ""); + static_assert((std::is_same<H::argument_type, T>::value), "" ); + static_assert((std::is_same<H::result_type, std::size_t>::value), "" ); bool ba[] = {true, false, true, true, false}; T vb(std::begin(ba), std::end(ba)); H h; diff --git a/test/std/containers/sequences/vector/const_value_type.pass.cpp b/test/std/containers/sequences/vector/const_value_type.pass.cpp deleted file mode 100644 index e16e439dec4d..000000000000 --- a/test/std/containers/sequences/vector/const_value_type.pass.cpp +++ /dev/null @@ -1,22 +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. -// -//===----------------------------------------------------------------------===// - -// <vector> - -// vector<const int> v; // an extension - -#include <vector> -#include <type_traits> - -int main() -{ -#ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS - std::vector<const int> v = {1, 2, 3}; -#endif -} diff --git a/test/std/containers/sequences/vector/contiguous.pass.cpp b/test/std/containers/sequences/vector/contiguous.pass.cpp index 32f380778335..70084246eae9 100644 --- a/test/std/containers/sequences/vector/contiguous.pass.cpp +++ b/test/std/containers/sequences/vector/contiguous.pass.cpp @@ -40,7 +40,7 @@ int main() test_contiguous(C(A(3))); test_contiguous(C(7, 9.0, A(5))); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef double T; typedef min_allocator<T> A; diff --git a/test/std/containers/sequences/vector/db_back.pass.cpp b/test/std/containers/sequences/vector/db_back.pass.cpp deleted file mode 100644 index 05f3d07712eb..000000000000 --- a/test/std/containers/sequences/vector/db_back.pass.cpp +++ /dev/null @@ -1,56 +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. -// -//===----------------------------------------------------------------------===// - -// <vector> - -// Call back() on empty container. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <vector> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::vector<T> C; - C c(1); - assert(c.back() == 0); - c.clear(); - assert(c.back() == 0); - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::vector<T, min_allocator<T>> C; - C c(1); - assert(c.back() == 0); - c.clear(); - assert(c.back() == 0); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/vector/db_cback.pass.cpp b/test/std/containers/sequences/vector/db_cback.pass.cpp deleted file mode 100644 index 5eb1a353e8b0..000000000000 --- a/test/std/containers/sequences/vector/db_cback.pass.cpp +++ /dev/null @@ -1,52 +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. -// -//===----------------------------------------------------------------------===// - -// <vector> - -// Call back() on empty const container. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <vector> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::vector<T> C; - const C c; - assert(c.back() == 0); - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::vector<T, min_allocator<T>> C; - const C c; - assert(c.back() == 0); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/vector/db_cfront.pass.cpp b/test/std/containers/sequences/vector/db_cfront.pass.cpp deleted file mode 100644 index 5e54da1d444e..000000000000 --- a/test/std/containers/sequences/vector/db_cfront.pass.cpp +++ /dev/null @@ -1,52 +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. -// -//===----------------------------------------------------------------------===// - -// <vector> - -// Call front() on empty const container. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <vector> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::vector<T> C; - const C c; - assert(c.front() == 0); - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::vector<T, min_allocator<T>> C; - const C c; - assert(c.front() == 0); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/vector/db_cindex.pass.cpp b/test/std/containers/sequences/vector/db_cindex.pass.cpp deleted file mode 100644 index 133aa5652824..000000000000 --- a/test/std/containers/sequences/vector/db_cindex.pass.cpp +++ /dev/null @@ -1,54 +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. -// -//===----------------------------------------------------------------------===// - -// <vector> - -// Index const vector out of bounds. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <vector> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::vector<T> C; - const C c(1); - assert(c[0] == 0); - assert(c[1] == 0); - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::vector<T, min_allocator<T>> C; - const C c(1); - assert(c[0] == 0); - assert(c[1] == 0); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/vector/db_front.pass.cpp b/test/std/containers/sequences/vector/db_front.pass.cpp deleted file mode 100644 index 388058fb3159..000000000000 --- a/test/std/containers/sequences/vector/db_front.pass.cpp +++ /dev/null @@ -1,56 +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. -// -//===----------------------------------------------------------------------===// - -// <vector> - -// Call front() on empty container. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <vector> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::vector<T> C; - C c(1); - assert(c.front() == 0); - c.clear(); - assert(c.front() == 0); - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::vector<T, min_allocator<T>> C; - C c(1); - assert(c.front() == 0); - c.clear(); - assert(c.front() == 0); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/vector/db_index.pass.cpp b/test/std/containers/sequences/vector/db_index.pass.cpp deleted file mode 100644 index 1daf076da67c..000000000000 --- a/test/std/containers/sequences/vector/db_index.pass.cpp +++ /dev/null @@ -1,56 +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. -// -//===----------------------------------------------------------------------===// - -// <vector> - -// Index vector out of bounds. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <vector> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::vector<T> C; - C c(1); - assert(c[0] == 0); - c.clear(); - assert(c[0] == 0); - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::vector<T, min_allocator<T>> C; - C c(1); - assert(c[0] == 0); - c.clear(); - assert(c[0] == 0); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/vector/db_iterators_2.pass.cpp b/test/std/containers/sequences/vector/db_iterators_2.pass.cpp deleted file mode 100644 index 2d43843067b7..000000000000 --- a/test/std/containers/sequences/vector/db_iterators_2.pass.cpp +++ /dev/null @@ -1,54 +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. -// -//===----------------------------------------------------------------------===// - -// <vector> - -// Compare iterators from different containers with <. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <vector> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::vector<T> C; - C c1; - C c2; - bool b = c1.begin() < c2.begin(); - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::vector<T, min_allocator<T>> C; - C c1; - C c2; - bool b = c1.begin() < c2.begin(); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/vector/db_iterators_3.pass.cpp b/test/std/containers/sequences/vector/db_iterators_3.pass.cpp deleted file mode 100644 index 051d66c33394..000000000000 --- a/test/std/containers/sequences/vector/db_iterators_3.pass.cpp +++ /dev/null @@ -1,54 +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. -// -//===----------------------------------------------------------------------===// - -// <vector> - -// Subtract iterators from different containers. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <vector> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::vector<T> C; - C c1; - C c2; - int i = c1.begin() - c2.begin(); - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::vector<T, min_allocator<T>> C; - C c1; - C c2; - int i = c1.begin() - c2.begin(); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/vector/db_iterators_4.pass.cpp b/test/std/containers/sequences/vector/db_iterators_4.pass.cpp deleted file mode 100644 index 4c2aa628de14..000000000000 --- a/test/std/containers/sequences/vector/db_iterators_4.pass.cpp +++ /dev/null @@ -1,56 +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. -// -//===----------------------------------------------------------------------===// - -// <vector> - -// Index iterator out of bounds. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <vector> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::vector<T> C; - C c(1); - C::iterator i = c.begin(); - assert(i[0] == 0); - assert(i[1] == 0); - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::vector<T, min_allocator<T>> C; - C c(1); - C::iterator i = c.begin(); - assert(i[0] == 0); - assert(i[1] == 0); - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/vector/db_iterators_5.pass.cpp b/test/std/containers/sequences/vector/db_iterators_5.pass.cpp deleted file mode 100644 index 1b1090499c27..000000000000 --- a/test/std/containers/sequences/vector/db_iterators_5.pass.cpp +++ /dev/null @@ -1,60 +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. -// -//===----------------------------------------------------------------------===// - -// <vector> - -// Add to iterator out of bounds. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <vector> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::vector<T> C; - C c(1); - C::iterator i = c.begin(); - i += 1; - assert(i == c.end()); - i = c.begin(); - i += 2; - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::vector<T, min_allocator<T>> C; - C c(1); - C::iterator i = c.begin(); - i += 1; - assert(i == c.end()); - i = c.begin(); - i += 2; - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/vector/db_iterators_6.pass.cpp b/test/std/containers/sequences/vector/db_iterators_6.pass.cpp deleted file mode 100644 index 424bc939b136..000000000000 --- a/test/std/containers/sequences/vector/db_iterators_6.pass.cpp +++ /dev/null @@ -1,58 +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. -// -//===----------------------------------------------------------------------===// - -// <vector> - -// Decrement iterator prior to begin. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <vector> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::vector<T> C; - C c(1); - C::iterator i = c.end(); - --i; - assert(i == c.begin()); - --i; - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::vector<T, min_allocator<T>> C; - C c(1); - C::iterator i = c.end(); - --i; - assert(i == c.begin()); - --i; - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/vector/db_iterators_7.pass.cpp b/test/std/containers/sequences/vector/db_iterators_7.pass.cpp deleted file mode 100644 index 72cdb10cbc85..000000000000 --- a/test/std/containers/sequences/vector/db_iterators_7.pass.cpp +++ /dev/null @@ -1,58 +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. -// -//===----------------------------------------------------------------------===// - -// <vector> - -// Increment iterator past end. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <vector> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::vector<T> C; - C c(1); - C::iterator i = c.begin(); - ++i; - assert(i == c.end()); - ++i; - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::vector<T, min_allocator<T>> C; - C c(1); - C::iterator i = c.begin(); - ++i; - assert(i == c.end()); - ++i; - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/vector/db_iterators_8.pass.cpp b/test/std/containers/sequences/vector/db_iterators_8.pass.cpp deleted file mode 100644 index 7b898533197c..000000000000 --- a/test/std/containers/sequences/vector/db_iterators_8.pass.cpp +++ /dev/null @@ -1,54 +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. -// -//===----------------------------------------------------------------------===// - -// <vector> - -// Dereference non-dereferenceable iterator. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <vector> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef int T; - typedef std::vector<T> C; - C c(1); - C::iterator i = c.end(); - T j = *i; - assert(false); - } -#if __cplusplus >= 201103L - { - typedef int T; - typedef std::vector<T, min_allocator<T>> C; - C c(1); - C::iterator i = c.end(); - T j = *i; - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/sequences/vector/iterators.pass.cpp b/test/std/containers/sequences/vector/iterators.pass.cpp index 75a08287a863..8dc14977f282 100644 --- a/test/std/containers/sequences/vector/iterators.pass.cpp +++ b/test/std/containers/sequences/vector/iterators.pass.cpp @@ -77,7 +77,7 @@ int main() C::iterator i; C::const_iterator j; } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::vector<T, min_allocator<T>> C; diff --git a/test/std/containers/sequences/vector/types.pass.cpp b/test/std/containers/sequences/vector/types.pass.cpp index 0fbc7e38b1a2..2080ac09fc5a 100644 --- a/test/std/containers/sequences/vector/types.pass.cpp +++ b/test/std/containers/sequences/vector/types.pass.cpp @@ -45,6 +45,9 @@ test() { typedef std::vector<T, Allocator> C; +// TODO: These tests should use allocator_traits to get stuff, rather than +// blindly pulling typedefs out of the allocator. This is why we can't call +// test<int, min_allocator<int>>() below. static_assert((std::is_same<typename C::value_type, T>::value), ""); static_assert((std::is_same<typename C::value_type, typename Allocator::value_type>::value), ""); static_assert((std::is_same<typename C::allocator_type, Allocator>::value), ""); @@ -54,6 +57,14 @@ test() static_assert((std::is_same<typename C::const_reference, typename Allocator::const_reference>::value), ""); static_assert((std::is_same<typename C::pointer, typename Allocator::pointer>::value), ""); static_assert((std::is_same<typename C::const_pointer, typename Allocator::const_pointer>::value), ""); + + static_assert((std::is_signed<typename C::difference_type>::value), ""); + static_assert((std::is_unsigned<typename C::size_type>::value), ""); +// static_assert((std::is_same<typename C::difference_type, +// typename std::iterator_traits<typename C::iterator>::difference_type>::value), ""); +// static_assert((std::is_same<typename C::difference_type, +// typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), ""); + static_assert((std::is_same< typename std::iterator_traits<typename C::iterator>::iterator_category, std::random_access_iterator_tag>::value), ""); @@ -75,12 +86,23 @@ int main() test<Copyable, test_allocator<Copyable> >(); static_assert((std::is_same<std::vector<char>::allocator_type, std::allocator<char> >::value), ""); -#if __cplusplus >= 201103L - static_assert((std::is_same<std::vector<int, min_allocator<int>>::value_type, int>::value), ""); - static_assert((std::is_same<std::vector<int, min_allocator<int>>::allocator_type, min_allocator<int> >::value), ""); - static_assert((std::is_same<std::vector<int, min_allocator<int>>::reference, int&>::value), ""); - static_assert((std::is_same<std::vector<int, min_allocator<int>>::const_reference, const int&>::value), ""); - static_assert((std::is_same<std::vector<int, min_allocator<int>>::pointer, min_pointer<int>>::value), ""); - static_assert((std::is_same<std::vector<int, min_allocator<int>>::const_pointer, min_pointer<const int>>::value), ""); +#if TEST_STD_VER >= 11 + { + + typedef std::vector<int, min_allocator<int> > C; + static_assert((std::is_same<C::value_type, int>::value), ""); + static_assert((std::is_same<C::allocator_type, min_allocator<int> >::value), ""); + static_assert((std::is_same<C::reference, int&>::value), ""); + static_assert((std::is_same<C::const_reference, const int&>::value), ""); + static_assert((std::is_same<C::pointer, min_pointer<int>>::value), ""); + static_assert((std::is_same<C::const_pointer, min_pointer<const int>>::value), ""); + + static_assert((std::is_signed<typename C::difference_type>::value), ""); + static_assert((std::is_unsigned<typename C::size_type>::value), ""); +// static_assert((std::is_same<typename C::difference_type, +// typename std::iterator_traits<typename C::iterator>::difference_type>::value), ""); +// static_assert((std::is_same<typename C::difference_type, +// typename std::iterator_traits<typename C::const_iterator>::difference_type>::value), ""); + } #endif } diff --git a/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp b/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp index 21082c839f56..a87b84061030 100644 --- a/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp +++ b/test/std/containers/sequences/vector/vector.capacity/capacity.pass.cpp @@ -22,27 +22,27 @@ int main() { std::vector<int> v; assert(v.capacity() == 0); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } { std::vector<int> v(100); assert(v.capacity() == 100); v.push_back(0); assert(v.capacity() > 101); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> v; assert(v.capacity() == 0); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } { std::vector<int, min_allocator<int>> v(100); assert(v.capacity() == 100); v.push_back(0); assert(v.capacity() > 101); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } #endif } diff --git a/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp b/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp index 4df5702f2ad2..d04e43db508d 100644 --- a/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp +++ b/test/std/containers/sequences/vector/vector.capacity/reserve.pass.cpp @@ -23,7 +23,7 @@ int main() std::vector<int> v; v.reserve(10); assert(v.capacity() >= 10); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } { std::vector<int> v(100); @@ -34,7 +34,7 @@ int main() v.reserve(150); assert(v.size() == 100); assert(v.capacity() == 150); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } { std::vector<int, stack_allocator<int, 250> > v(100); @@ -45,14 +45,14 @@ int main() v.reserve(150); assert(v.size() == 100); assert(v.capacity() == 150); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> v; v.reserve(10); assert(v.capacity() >= 10); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } { std::vector<int, min_allocator<int>> v(100); @@ -63,7 +63,7 @@ int main() v.reserve(150); assert(v.size() == 100); assert(v.capacity() == 150); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } #endif } diff --git a/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp b/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp index c7988d62060a..ce74cf9b7c23 100644 --- a/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp +++ b/test/std/containers/sequences/vector/vector.capacity/resize_size.pass.cpp @@ -26,22 +26,22 @@ int main() v.resize(50); assert(v.size() == 50); assert(v.capacity() == 100); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); v.resize(200); assert(v.size() == 200); assert(v.capacity() >= 200); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } { std::vector<MoveOnly, stack_allocator<MoveOnly, 300> > v(100); v.resize(50); assert(v.size() == 50); assert(v.capacity() == 100); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); v.resize(200); assert(v.size() == 200); assert(v.capacity() >= 200); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } #else // _LIBCPP_HAS_NO_RVALUE_REFERENCES { @@ -49,35 +49,35 @@ int main() v.resize(50); assert(v.size() == 50); assert(v.capacity() == 100); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); v.resize(200); assert(v.size() == 200); assert(v.capacity() >= 200); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } { std::vector<int, stack_allocator<int, 300> > v(100); v.resize(50); assert(v.size() == 50); assert(v.capacity() == 100); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); v.resize(200); assert(v.size() == 200); assert(v.capacity() >= 200); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<MoveOnly, min_allocator<MoveOnly>> v(100); v.resize(50); assert(v.size() == 50); assert(v.capacity() == 100); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); v.resize(200); assert(v.size() == 200); assert(v.capacity() >= 200); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } #endif } diff --git a/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp b/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp index de5126b03d10..3e7df312731f 100644 --- a/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp +++ b/test/std/containers/sequences/vector/vector.capacity/resize_size_value.pass.cpp @@ -28,7 +28,7 @@ int main() v.resize(200, 1); assert(v.size() == 200); assert(v.capacity() >= 200); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); for (unsigned i = 0; i < 50; ++i) assert(v[i] == 0); for (unsigned i = 50; i < 200; ++i) @@ -42,20 +42,20 @@ int main() v.resize(200, 1); assert(v.size() == 200); assert(v.capacity() >= 200); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> v(100); v.resize(50, 1); assert(v.size() == 50); assert(v.capacity() == 100); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert((v == std::vector<int, min_allocator<int>>(50))); v.resize(200, 1); assert(v.size() == 200); assert(v.capacity() >= 200); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); for (unsigned i = 0; i < 50; ++i) assert(v[i] == 0); for (unsigned i = 50; i < 200; ++i) @@ -66,11 +66,11 @@ int main() v.resize(50, 1); assert(v.size() == 50); assert(v.capacity() == 100); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); v.resize(200, 1); assert(v.size() == 200); assert(v.capacity() >= 200); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } #endif } diff --git a/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp b/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp index 49ab9cc71deb..10ce33f43bd2 100644 --- a/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp +++ b/test/std/containers/sequences/vector/vector.capacity/shrink_to_fit.pass.cpp @@ -22,41 +22,41 @@ int main() { std::vector<int> v(100); v.push_back(1); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); v.shrink_to_fit(); assert(v.capacity() == 101); assert(v.size() == 101); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } { std::vector<int, stack_allocator<int, 401> > v(100); v.push_back(1); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); v.shrink_to_fit(); assert(v.capacity() == 101); assert(v.size() == 101); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } #ifndef _LIBCPP_NO_EXCEPTIONS { std::vector<int, stack_allocator<int, 400> > v(100); v.push_back(1); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); v.shrink_to_fit(); - assert(v.capacity() == 200); + LIBCPP_ASSERT(v.capacity() == 200); // assumes libc++'s 2x growth factor assert(v.size() == 101); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } #endif -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> v(100); v.push_back(1); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); v.shrink_to_fit(); assert(v.capacity() == 101); assert(v.size() == 101); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } #endif } diff --git a/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp b/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp index f3d9289c36eb..59529a6dfd36 100644 --- a/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp +++ b/test/std/containers/sequences/vector/vector.capacity/swap.pass.cpp @@ -22,29 +22,29 @@ int main() { std::vector<int> v1(100); std::vector<int> v2(200); - assert(is_contiguous_container_asan_correct(v1)); - assert(is_contiguous_container_asan_correct(v2)); + assert(is_contiguous_container_asan_correct(v1)); + assert(is_contiguous_container_asan_correct(v2)); v1.swap(v2); assert(v1.size() == 200); assert(v1.capacity() == 200); - assert(is_contiguous_container_asan_correct(v1)); + assert(is_contiguous_container_asan_correct(v1)); assert(v2.size() == 100); assert(v2.capacity() == 100); - assert(is_contiguous_container_asan_correct(v2)); + assert(is_contiguous_container_asan_correct(v2)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> v1(100); std::vector<int, min_allocator<int>> v2(200); - assert(is_contiguous_container_asan_correct(v1)); - assert(is_contiguous_container_asan_correct(v2)); + assert(is_contiguous_container_asan_correct(v1)); + assert(is_contiguous_container_asan_correct(v2)); v1.swap(v2); assert(v1.size() == 200); assert(v1.capacity() == 200); - assert(is_contiguous_container_asan_correct(v1)); + assert(is_contiguous_container_asan_correct(v1)); assert(v2.size() == 100); assert(v2.capacity() == 100); - assert(is_contiguous_container_asan_correct(v2)); + assert(is_contiguous_container_asan_correct(v2)); } #endif } diff --git a/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp b/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp index 6f02c3b7bc2b..d15d24dd969f 100644 --- a/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/assign_copy.pass.cpp @@ -32,7 +32,7 @@ int main() assert(l2 == l); assert(l2.get_allocator() == other_allocator<int>(5)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int> > l(3, 2, min_allocator<int>()); std::vector<int, min_allocator<int> > l2(l, min_allocator<int>()); diff --git a/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp b/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp index 3cb0b3b095f0..222fa9c78f92 100644 --- a/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/assign_initializer_list.pass.cpp @@ -23,7 +23,7 @@ void test ( Vec &v ) #ifndef _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS v.assign({3, 4, 5, 6}); assert(v.size() == 4); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(v[0] == 3); assert(v[1] == 4); assert(v[2] == 5); @@ -42,7 +42,7 @@ int main() test(d2); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::vector<int, min_allocator<int>> V; V d1; diff --git a/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp b/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp index 8c8b0a04715b..acbee97bcd1c 100644 --- a/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/assign_move.pass.cpp @@ -29,72 +29,72 @@ int main() l.push_back(i); lo.push_back(i); } - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); std::vector<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(5)); l2 = std::move(l); assert(l2 == lo); assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); - assert(is_contiguous_container_asan_correct(l2)); + assert(is_contiguous_container_asan_correct(l2)); } { std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5)); std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5)); - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); for (int i = 1; i <= 3; ++i) { l.push_back(i); lo.push_back(i); } - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); std::vector<MoveOnly, test_allocator<MoveOnly> > l2(test_allocator<MoveOnly>(6)); l2 = std::move(l); assert(l2 == lo); assert(!l.empty()); assert(l2.get_allocator() == test_allocator<MoveOnly>(6)); - assert(is_contiguous_container_asan_correct(l2)); + assert(is_contiguous_container_asan_correct(l2)); } { std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5)); std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5)); - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); for (int i = 1; i <= 3; ++i) { l.push_back(i); lo.push_back(i); } - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); std::vector<MoveOnly, other_allocator<MoveOnly> > l2(other_allocator<MoveOnly>(6)); l2 = std::move(l); assert(l2 == lo); assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); - assert(is_contiguous_container_asan_correct(l2)); + assert(is_contiguous_container_asan_correct(l2)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{}); std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{}); - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); for (int i = 1; i <= 3; ++i) { l.push_back(i); lo.push_back(i); } - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); std::vector<MoveOnly, min_allocator<MoveOnly> > l2(min_allocator<MoveOnly>{}); l2 = std::move(l); assert(l2 == lo); assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); - assert(is_contiguous_container_asan_correct(l2)); + assert(is_contiguous_container_asan_correct(l2)); } #endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES diff --git a/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp b/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp index e1b30bf11304..8e5d2766c775 100644 --- a/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/assign_size_value.pass.cpp @@ -26,7 +26,7 @@ void test ( Vec &v ) { v.assign(5, 6); assert(v.size() == 5); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(std::all_of(v.begin(), v.end(), is6)); } @@ -41,7 +41,7 @@ int main() test(d2); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::vector<int, min_allocator<int>> V; V d1; diff --git a/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp index 5e87c07ef70a..e0542e751f44 100644 --- a/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/construct_default.pass.cpp @@ -32,16 +32,16 @@ test0() static_assert((noexcept(C()) == noexcept(typename C::allocator_type())), "" ); #endif C c; - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(c.empty()); assert(c.get_allocator() == typename C::allocator_type()); - assert(is_contiguous_container_asan_correct(c)); + LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); #if TEST_STD_VER >= 11 C c1 = {}; - assert(c1.__invariants()); + LIBCPP_ASSERT(c1.__invariants()); assert(c1.empty()); assert(c1.get_allocator() == typename C::allocator_type()); - assert(is_contiguous_container_asan_correct(c1)); + LIBCPP_ASSERT(is_contiguous_container_asan_correct(c1)); #endif } @@ -55,10 +55,10 @@ test1(const typename C::allocator_type& a) static_assert((noexcept(C(typename C::allocator_type())) == std::is_nothrow_copy_constructible<typename C::allocator_type>::value), "" ); #endif C c(a); - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(c.empty()); assert(c.get_allocator() == a); - assert(is_contiguous_container_asan_correct(c)); + LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); } int main() diff --git a/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp index 36e231acce12..5542e91059d6 100644 --- a/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter.pass.cpp @@ -14,6 +14,7 @@ #include <vector> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" #include "../../../stack_allocator.h" #include "min_allocator.h" @@ -24,9 +25,9 @@ void test(Iterator first, Iterator last) { C c(first, last); - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(c.size() == std::distance(first, last)); - assert(is_contiguous_container_asan_correct(c)); + LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first) assert(*i == *first); } @@ -46,7 +47,7 @@ int main() test<std::vector<int, stack_allocator<int, 18> > >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an)); test<std::vector<int, stack_allocator<int, 18> > >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an)); test<std::vector<int, stack_allocator<int, 18> > >(a, an); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 test<std::vector<int, min_allocator<int>> >(input_iterator<const int*>(a), input_iterator<const int*>(an)); test<std::vector<int, min_allocator<int>> >(forward_iterator<const int*>(a), forward_iterator<const int*>(an)); test<std::vector<int, min_allocator<int>> >(bidirectional_iterator<const int*>(a), bidirectional_iterator<const int*>(an)); diff --git a/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp index 7fa748a90d71..f40088ea3e86 100644 --- a/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/construct_iter_iter_alloc.pass.cpp @@ -15,6 +15,7 @@ #include <vector> #include <cassert> +#include "test_macros.h" #include "test_iterators.h" #include "../../../stack_allocator.h" #include "min_allocator.h" @@ -25,19 +26,19 @@ void test(Iterator first, Iterator last, const A& a) { C c(first, last, a); - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(c.size() == std::distance(first, last)); - assert(is_contiguous_container_asan_correct(c)); + LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i, ++first) assert(*i == *first); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 template <class T> struct implicit_conv_allocator : min_allocator<T> { - implicit_conv_allocator(void* p) {} + implicit_conv_allocator(void*) {} implicit_conv_allocator(const implicit_conv_allocator&) = default; }; @@ -55,7 +56,7 @@ int main() test<std::vector<int> >(random_access_iterator<const int*>(a), random_access_iterator<const int*>(an), alloc); test<std::vector<int> >(a, an, alloc); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0}; int* an = a + sizeof(a)/sizeof(a[0]); diff --git a/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp index e03389593f16..46e5ecdc9a56 100644 --- a/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/construct_size.pass.cpp @@ -14,6 +14,7 @@ #include <vector> #include <cassert> +#include "test_macros.h" #include "DefaultOnly.h" #include "min_allocator.h" #include "test_allocator.h" @@ -23,16 +24,14 @@ template <class C> void test2(typename C::size_type n, typename C::allocator_type const& a = typename C::allocator_type ()) { -#if _LIBCPP_STD_VER > 11 +#if TEST_STD_VER >= 14 C c(n, a); - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(c.size() == n); assert(c.get_allocator() == a); - assert(is_contiguous_container_asan_correct(c)); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) assert(*i == typename C::value_type()); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES #endif } @@ -41,14 +40,14 @@ void test1(typename C::size_type n) { C c(n); - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(c.size() == n); assert(c.get_allocator() == typename C::allocator_type()); - assert(is_contiguous_container_asan_correct(c)); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); +#if TEST_STD_VER >= 11 for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) assert(*i == typename C::value_type()); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES +#endif } template <class C> @@ -64,7 +63,7 @@ int main() test<std::vector<int> >(50); test<std::vector<DefaultOnly> >(500); assert(DefaultOnly::count == 0); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 test<std::vector<int, min_allocator<int>> >(50); test<std::vector<DefaultOnly, min_allocator<DefaultOnly>> >(500); test2<std::vector<DefaultOnly, test_allocator<DefaultOnly>> >( 100, test_allocator<DefaultOnly>(23)); diff --git a/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp index 5b6c49857044..d3774d1a6595 100644 --- a/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/construct_size_value.pass.cpp @@ -14,6 +14,7 @@ #include <vector> #include <cassert> +#include "test_macros.h" #include "../../../stack_allocator.h" #include "min_allocator.h" #include "asan_testing.h" @@ -23,9 +24,9 @@ void test(typename C::size_type n, const typename C::value_type& x) { C c(n, x); - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(c.size() == n); - assert(is_contiguous_container_asan_correct(c)); + LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) assert(*i == x); } @@ -34,7 +35,7 @@ int main() { test<std::vector<int> >(50, 3); test<std::vector<int, stack_allocator<int, 50> > >(50, 5); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 test<std::vector<int, min_allocator<int>> >(50, 3); #endif } diff --git a/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp b/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp index c62b84104aba..4713aa157062 100644 --- a/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/construct_size_value_alloc.pass.cpp @@ -13,6 +13,8 @@ #include <vector> #include <cassert> + +#include "test_macros.h" #include "min_allocator.h" #include "asan_testing.h" @@ -22,10 +24,10 @@ test(typename C::size_type n, const typename C::value_type& x, const typename C::allocator_type& a) { C c(n, x, a); - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(a == c.get_allocator()); assert(c.size() == n); - assert(is_contiguous_container_asan_correct(c)); + LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); for (typename C::const_iterator i = c.cbegin(), e = c.cend(); i != e; ++i) assert(*i == x); } @@ -33,7 +35,7 @@ test(typename C::size_type n, const typename C::value_type& x, int main() { test<std::vector<int> >(50, 3, std::allocator<int>()); -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 test<std::vector<int, min_allocator<int>> >(50, 3, min_allocator<int>()); #endif } diff --git a/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp b/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp index 677963deeb84..105217bbf15c 100644 --- a/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/copy.pass.cpp @@ -13,6 +13,8 @@ #include <vector> #include <cassert> + +#include "test_macros.h" #include "test_allocator.h" #include "min_allocator.h" #include "asan_testing.h" @@ -23,10 +25,10 @@ test(const C& x) { unsigned s = x.size(); C c(x); - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(c.size() == s); assert(c == x); - assert(is_contiguous_container_asan_correct(c)); + LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); } int main() @@ -39,26 +41,24 @@ int main() { std::vector<int, test_allocator<int> > v(3, 2, test_allocator<int>(5)); std::vector<int, test_allocator<int> > v2 = v; - assert(is_contiguous_container_asan_correct(v)); - assert(is_contiguous_container_asan_correct(v2)); + assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v2)); assert(v2 == v); assert(v2.get_allocator() == v.get_allocator()); - assert(is_contiguous_container_asan_correct(v)); - assert(is_contiguous_container_asan_correct(v2)); + assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v2)); } -#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE +#if TEST_STD_VER >= 11 { std::vector<int, other_allocator<int> > v(3, 2, other_allocator<int>(5)); std::vector<int, other_allocator<int> > v2 = v; - assert(is_contiguous_container_asan_correct(v)); - assert(is_contiguous_container_asan_correct(v2)); + assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v2)); assert(v2 == v); assert(v2.get_allocator() == other_allocator<int>(-2)); - assert(is_contiguous_container_asan_correct(v)); - assert(is_contiguous_container_asan_correct(v2)); + assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v2)); } -#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE -#if __cplusplus >= 201103L { int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0}; int* an = a + sizeof(a)/sizeof(a[0]); @@ -67,12 +67,12 @@ int main() { std::vector<int, min_allocator<int> > v(3, 2, min_allocator<int>()); std::vector<int, min_allocator<int> > v2 = v; - assert(is_contiguous_container_asan_correct(v)); - assert(is_contiguous_container_asan_correct(v2)); + assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v2)); assert(v2 == v); assert(v2.get_allocator() == v.get_allocator()); - assert(is_contiguous_container_asan_correct(v)); - assert(is_contiguous_container_asan_correct(v2)); + assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v2)); } #endif } diff --git a/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp b/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp index 128328c2a7d2..47259c747332 100644 --- a/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/copy_alloc.pass.cpp @@ -13,6 +13,8 @@ #include <vector> #include <cassert> + +#include "test_macros.h" #include "test_allocator.h" #include "min_allocator.h" #include "asan_testing.h" @@ -23,10 +25,10 @@ test(const C& x, const typename C::allocator_type& a) { unsigned s = x.size(); C c(x, a); - assert(c.__invariants()); + LIBCPP_ASSERT(c.__invariants()); assert(c.size() == s); assert(c == x); - assert(is_contiguous_container_asan_correct(c)); + LIBCPP_ASSERT(is_contiguous_container_asan_correct(c)); } int main() @@ -48,7 +50,7 @@ int main() assert(l2 == l); assert(l2.get_allocator() == other_allocator<int>(3)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a[] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 8, 7, 6, 5, 4, 3, 1, 0}; int* an = a + sizeof(a)/sizeof(a[0]); diff --git a/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp b/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp index 60f7b72c9477..b244f75f21d4 100644 --- a/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/default_noexcept.pass.cpp @@ -14,6 +14,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <vector> #include <cassert> @@ -30,7 +32,6 @@ struct some_alloc int main() { -#if __has_feature(cxx_noexcept) { typedef std::vector<MoveOnly> C; static_assert(std::is_nothrow_default_constructible<C>::value, ""); @@ -47,5 +48,4 @@ int main() typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp b/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp index 0e2cae9ee935..bd538120442d 100644 --- a/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/dtor_noexcept.pass.cpp @@ -11,14 +11,14 @@ // ~vector() // implied noexcept; +// UNSUPPORTED: c++98, c++03 + #include <vector> #include <cassert> #include "MoveOnly.h" #include "test_allocator.h" -#if __has_feature(cxx_noexcept) - template <class T> struct some_alloc { @@ -27,11 +27,8 @@ struct some_alloc ~some_alloc() noexcept(false); }; -#endif - int main() { -#if __has_feature(cxx_noexcept) { typedef std::vector<MoveOnly> C; static_assert(std::is_nothrow_destructible<C>::value, ""); @@ -48,5 +45,4 @@ int main() typedef std::vector<MoveOnly, some_alloc<MoveOnly>> C; static_assert(!std::is_nothrow_destructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp b/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp index 7eb834ff3877..408bcc3b1499 100644 --- a/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/initializer_list.pass.cpp @@ -22,17 +22,17 @@ int main() { std::vector<int> d = {3, 4, 5, 6}; assert(d.size() == 4); - assert(is_contiguous_container_asan_correct(d)); + assert(is_contiguous_container_asan_correct(d)); assert(d[0] == 3); assert(d[1] == 4); assert(d[2] == 5); assert(d[3] == 6); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> d = {3, 4, 5, 6}; assert(d.size() == 4); - assert(is_contiguous_container_asan_correct(d)); + assert(is_contiguous_container_asan_correct(d)); assert(d[0] == 3); assert(d[1] == 4); assert(d[2] == 5); diff --git a/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp b/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp index 5d7ae884e382..f4c3b5c1e8e0 100644 --- a/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/initializer_list_alloc.pass.cpp @@ -25,18 +25,18 @@ int main() std::vector<int, test_allocator<int>> d({3, 4, 5, 6}, test_allocator<int>(3)); assert(d.get_allocator() == test_allocator<int>(3)); assert(d.size() == 4); - assert(is_contiguous_container_asan_correct(d)); + assert(is_contiguous_container_asan_correct(d)); assert(d[0] == 3); assert(d[1] == 4); assert(d[2] == 5); assert(d[3] == 6); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> d({3, 4, 5, 6}, min_allocator<int>()); assert(d.get_allocator() == min_allocator<int>()); assert(d.size() == 4); - assert(is_contiguous_container_asan_correct(d)); + assert(is_contiguous_container_asan_correct(d)); assert(d[0] == 3); assert(d[1] == 4); assert(d[2] == 5); diff --git a/test/std/containers/sequences/vector/vector.cons/move.pass.cpp b/test/std/containers/sequences/vector/vector.cons/move.pass.cpp index fb419d825d2b..d51b364f3ba0 100644 --- a/test/std/containers/sequences/vector/vector.cons/move.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/move.pass.cpp @@ -24,79 +24,79 @@ int main() { std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5)); std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5)); - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); for (int i = 1; i <= 3; ++i) { l.push_back(i); lo.push_back(i); } - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); std::vector<MoveOnly, test_allocator<MoveOnly> > l2 = std::move(l); assert(l2 == lo); assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); - assert(is_contiguous_container_asan_correct(l2)); + assert(is_contiguous_container_asan_correct(l2)); } { std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5)); std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5)); - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); for (int i = 1; i <= 3; ++i) { l.push_back(i); lo.push_back(i); } - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); std::vector<MoveOnly, other_allocator<MoveOnly> > l2 = std::move(l); assert(l2 == lo); assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); - assert(is_contiguous_container_asan_correct(l2)); + assert(is_contiguous_container_asan_correct(l2)); } { int a1[] = {1, 3, 7, 9, 10}; std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); - assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c1)); std::vector<int>::const_iterator i = c1.begin(); std::vector<int> c2 = std::move(c1); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c2)); std::vector<int>::iterator j = c2.erase(i); assert(*j == 3); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c2)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{}); std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{}); - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); for (int i = 1; i <= 3; ++i) { l.push_back(i); lo.push_back(i); } - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); std::vector<MoveOnly, min_allocator<MoveOnly> > l2 = std::move(l); assert(l2 == lo); assert(l.empty()); assert(l2.get_allocator() == lo.get_allocator()); - assert(is_contiguous_container_asan_correct(l2)); + assert(is_contiguous_container_asan_correct(l2)); } { int a1[] = {1, 3, 7, 9, 10}; std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); - assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c1)); std::vector<int, min_allocator<int>>::const_iterator i = c1.begin(); std::vector<int, min_allocator<int>> c2 = std::move(c1); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c2)); std::vector<int, min_allocator<int>>::iterator j = c2.erase(i); assert(*j == 3); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c2)); } #endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES diff --git a/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp b/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp index aef96917cb32..fcdd35ae1157 100644 --- a/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/move_alloc.pass.cpp @@ -24,75 +24,75 @@ int main() { std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5)); std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5)); - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); for (int i = 1; i <= 3; ++i) { l.push_back(i); lo.push_back(i); } - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); std::vector<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(6)); assert(l2 == lo); assert(!l.empty()); assert(l2.get_allocator() == test_allocator<MoveOnly>(6)); - assert(is_contiguous_container_asan_correct(l2)); + assert(is_contiguous_container_asan_correct(l2)); } { std::vector<MoveOnly, test_allocator<MoveOnly> > l(test_allocator<MoveOnly>(5)); std::vector<MoveOnly, test_allocator<MoveOnly> > lo(test_allocator<MoveOnly>(5)); - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); for (int i = 1; i <= 3; ++i) { l.push_back(i); lo.push_back(i); } - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); std::vector<MoveOnly, test_allocator<MoveOnly> > l2(std::move(l), test_allocator<MoveOnly>(5)); assert(l2 == lo); assert(l.empty()); assert(l2.get_allocator() == test_allocator<MoveOnly>(5)); - assert(is_contiguous_container_asan_correct(l2)); + assert(is_contiguous_container_asan_correct(l2)); } { std::vector<MoveOnly, other_allocator<MoveOnly> > l(other_allocator<MoveOnly>(5)); std::vector<MoveOnly, other_allocator<MoveOnly> > lo(other_allocator<MoveOnly>(5)); - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); for (int i = 1; i <= 3; ++i) { l.push_back(i); lo.push_back(i); } - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); std::vector<MoveOnly, other_allocator<MoveOnly> > l2(std::move(l), other_allocator<MoveOnly>(4)); assert(l2 == lo); assert(!l.empty()); assert(l2.get_allocator() == other_allocator<MoveOnly>(4)); - assert(is_contiguous_container_asan_correct(l2)); + assert(is_contiguous_container_asan_correct(l2)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<MoveOnly, min_allocator<MoveOnly> > l(min_allocator<MoveOnly>{}); std::vector<MoveOnly, min_allocator<MoveOnly> > lo(min_allocator<MoveOnly>{}); - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); for (int i = 1; i <= 3; ++i) { l.push_back(i); lo.push_back(i); } - assert(is_contiguous_container_asan_correct(l)); - assert(is_contiguous_container_asan_correct(lo)); + assert(is_contiguous_container_asan_correct(l)); + assert(is_contiguous_container_asan_correct(lo)); std::vector<MoveOnly, min_allocator<MoveOnly> > l2(std::move(l), min_allocator<MoveOnly>()); assert(l2 == lo); assert(l.empty()); assert(l2.get_allocator() == min_allocator<MoveOnly>()); - assert(is_contiguous_container_asan_correct(l2)); + assert(is_contiguous_container_asan_correct(l2)); } #endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES diff --git a/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp b/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp index c09224497966..14ca7155b5a1 100644 --- a/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/move_assign_noexcept.pass.cpp @@ -16,6 +16,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <vector> #include <cassert> @@ -33,7 +35,7 @@ template <class T> struct some_alloc2 { typedef T value_type; - + some_alloc2() {} some_alloc2(const some_alloc2&); void deallocate(void*, unsigned) {} @@ -46,7 +48,7 @@ template <class T> struct some_alloc3 { typedef T value_type; - + some_alloc3() {} some_alloc3(const some_alloc3&); void deallocate(void*, unsigned) {} @@ -58,7 +60,6 @@ struct some_alloc3 int main() { -#if __has_feature(cxx_noexcept) { typedef std::vector<MoveOnly> C; static_assert(std::is_nothrow_move_assignable<C>::value, ""); @@ -91,6 +92,4 @@ int main() static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } #endif - -#endif } diff --git a/test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp b/test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp index b7bbfaa421c4..a1e3a632f1f2 100644 --- a/test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/move_noexcept.pass.cpp @@ -14,6 +14,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <vector> #include <cassert> @@ -29,7 +31,6 @@ struct some_alloc int main() { -#if __has_feature(cxx_noexcept) { typedef std::vector<MoveOnly> C; static_assert(std::is_nothrow_move_constructible<C>::value, ""); @@ -51,5 +52,4 @@ int main() static_assert(!std::is_nothrow_move_constructible<C>::value, ""); #endif } -#endif } diff --git a/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp b/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp index 592b71462767..4e5a20413683 100644 --- a/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector/vector.cons/op_equal_initializer_list.pass.cpp @@ -24,18 +24,18 @@ int main() std::vector<int> d; d = {3, 4, 5, 6}; assert(d.size() == 4); - assert(is_contiguous_container_asan_correct(d)); + assert(is_contiguous_container_asan_correct(d)); assert(d[0] == 3); assert(d[1] == 4); assert(d[2] == 5); assert(d[3] == 6); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> d; d = {3, 4, 5, 6}; assert(d.size() == 4); - assert(is_contiguous_container_asan_correct(d)); + assert(is_contiguous_container_asan_correct(d)); assert(d[0] == 3); assert(d[1] == 4); assert(d[2] == 5); diff --git a/test/std/containers/sequences/vector/vector.data/data.pass.cpp b/test/std/containers/sequences/vector/vector.data/data.pass.cpp index aed56bc09310..f6c0575d958c 100644 --- a/test/std/containers/sequences/vector/vector.data/data.pass.cpp +++ b/test/std/containers/sequences/vector/vector.data/data.pass.cpp @@ -17,28 +17,47 @@ #include "min_allocator.h" #include "asan_testing.h" +struct Nasty { + Nasty() : i_(0) {} + Nasty(int i) : i_(i) {} + ~Nasty() {} + + Nasty * operator&() const { assert(false); return nullptr; } + int i_; + }; + int main() { { std::vector<int> v; assert(v.data() == 0); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } { std::vector<int> v(100); - assert(v.data() == &v.front()); - assert(is_contiguous_container_asan_correct(v)); + assert(v.data() == std::addressof(v.front())); + assert(is_contiguous_container_asan_correct(v)); + } + { + std::vector<Nasty> v(100); + assert(v.data() == std::addressof(v.front())); + assert(is_contiguous_container_asan_correct(v)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> v; assert(v.data() == 0); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } { std::vector<int, min_allocator<int>> v(100); - assert(v.data() == &v.front()); - assert(is_contiguous_container_asan_correct(v)); + assert(v.data() == std::addressof(v.front())); + assert(is_contiguous_container_asan_correct(v)); + } + { + std::vector<Nasty, min_allocator<Nasty>> v(100); + assert(v.data() == std::addressof(v.front())); + assert(is_contiguous_container_asan_correct(v)); } #endif } diff --git a/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp b/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp index cb6062694e40..c97ad29708b8 100644 --- a/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp +++ b/test/std/containers/sequences/vector/vector.data/data_const.pass.cpp @@ -17,28 +17,47 @@ #include "min_allocator.h" #include "asan_testing.h" +struct Nasty { + Nasty() : i_(0) {} + Nasty(int i) : i_(i) {} + ~Nasty() {} + + Nasty * operator&() const { assert(false); return nullptr; } + int i_; + }; + int main() { { const std::vector<int> v; assert(v.data() == 0); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } { const std::vector<int> v(100); - assert(v.data() == &v.front()); - assert(is_contiguous_container_asan_correct(v)); + assert(v.data() == std::addressof(v.front())); + assert(is_contiguous_container_asan_correct(v)); + } + { + std::vector<Nasty> v(100); + assert(v.data() == std::addressof(v.front())); + assert(is_contiguous_container_asan_correct(v)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { const std::vector<int, min_allocator<int>> v; assert(v.data() == 0); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } { const std::vector<int, min_allocator<int>> v(100); assert(v.data() == &v.front()); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); + } + { + std::vector<Nasty, min_allocator<Nasty>> v(100); + assert(v.data() == std::addressof(v.front())); + assert(is_contiguous_container_asan_correct(v)); } #endif } diff --git a/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp index 8af6bdacd0a8..8bcc23979668 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/emplace.pass.cpp @@ -67,7 +67,7 @@ int main() assert(c.size() == 1); assert(c.front().geti() == 2); assert(c.front().getd() == 3.5); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); i = c.emplace(c.cend(), 3, 4.5); assert(i == c.end()-1); assert(c.size() == 2); @@ -75,7 +75,7 @@ int main() assert(c.front().getd() == 3.5); assert(c.back().geti() == 3); assert(c.back().getd() == 4.5); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); i = c.emplace(c.cbegin()+1, 4, 6.5); assert(i == c.begin()+1); assert(c.size() == 3); @@ -85,7 +85,7 @@ int main() assert(c[1].getd() == 6.5); assert(c.back().geti() == 3); assert(c.back().getd() == 4.5); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); } { std::vector<A, stack_allocator<A, 7> > c; @@ -94,7 +94,7 @@ int main() assert(c.size() == 1); assert(c.front().geti() == 2); assert(c.front().getd() == 3.5); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); i = c.emplace(c.cend(), 3, 4.5); assert(i == c.end()-1); assert(c.size() == 2); @@ -102,7 +102,7 @@ int main() assert(c.front().getd() == 3.5); assert(c.back().geti() == 3); assert(c.back().getd() == 4.5); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); i = c.emplace(c.cbegin()+1, 4, 6.5); assert(i == c.begin()+1); assert(c.size() == 3); @@ -112,7 +112,7 @@ int main() assert(c[1].getd() == 6.5); assert(c.back().geti() == 3); assert(c.back().getd() == 4.5); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); } #if _LIBCPP_DEBUG >= 1 { @@ -122,7 +122,7 @@ int main() assert(false); } #endif -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<A, min_allocator<A>> c; std::vector<A, min_allocator<A>>::iterator i = c.emplace(c.cbegin(), 2, 3.5); diff --git a/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp index bbf91a4255d7..61ccade76b02 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/emplace_back.pass.cpp @@ -15,6 +15,7 @@ #include <cassert> #include "../../../stack_allocator.h" #include "min_allocator.h" +#include "test_allocator.h" #include "asan_testing.h" #ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES @@ -62,14 +63,14 @@ int main() assert(c.size() == 1); assert(c.front().geti() == 2); assert(c.front().getd() == 3.5); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); c.emplace_back(3, 4.5); assert(c.size() == 2); assert(c.front().geti() == 2); assert(c.front().getd() == 3.5); assert(c.back().geti() == 3); assert(c.back().getd() == 4.5); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); } { std::vector<A, stack_allocator<A, 4> > c; @@ -77,30 +78,38 @@ int main() assert(c.size() == 1); assert(c.front().geti() == 2); assert(c.front().getd() == 3.5); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); c.emplace_back(3, 4.5); assert(c.size() == 2); assert(c.front().geti() == 2); assert(c.front().getd() == 3.5); assert(c.back().geti() == 3); assert(c.back().getd() == 4.5); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<A, min_allocator<A>> c; c.emplace_back(2, 3.5); assert(c.size() == 1); assert(c.front().geti() == 2); assert(c.front().getd() == 3.5); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); c.emplace_back(3, 4.5); assert(c.size() == 2); assert(c.front().geti() == 2); assert(c.front().getd() == 3.5); assert(c.back().geti() == 3); assert(c.back().getd() == 4.5); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); + } + { + std::vector<Tag_X, TaggingAllocator<Tag_X>> c; + c.emplace_back(); + assert(c.size() == 1); + c.emplace_back(1, 2, 3); + assert(c.size() == 2); + assert(is_contiguous_container_asan_correct(c)); } #endif #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES diff --git a/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp index 85a47073bcb2..7e4aed8c1b5e 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/emplace_extra.pass.cpp @@ -23,39 +23,39 @@ int main() { std::vector<int> v; v.reserve(3); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); v = { 1, 2, 3 }; v.emplace(v.begin(), v.back()); assert(v[0] == 3); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } { std::vector<int> v; v.reserve(4); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); v = { 1, 2, 3 }; v.emplace(v.begin(), v.back()); assert(v[0] == 3); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> v; v.reserve(3); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); v = { 1, 2, 3 }; v.emplace(v.begin(), v.back()); assert(v[0] == 3); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } { std::vector<int, min_allocator<int>> v; v.reserve(4); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); v = { 1, 2, 3 }; v.emplace(v.begin(), v.back()); assert(v[0] == 3); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); } #endif #endif // _LIBCPP_HAS_NO_GENERALIZED_INITIALIZERS diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp index 4fa07b729a75..dbdccf13b72e 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/erase_iter.pass.cpp @@ -24,7 +24,7 @@ int main() int a1[] = {1, 2, 3}; std::vector<int> l1(a1, a1+3); std::vector<int>::const_iterator i = l1.begin(); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); ++i; std::vector<int>::iterator j = l1.erase(i); assert(l1.size() == 2); @@ -32,25 +32,25 @@ int main() assert(*j == 3); assert(*l1.begin() == 1); assert(*next(l1.begin()) == 3); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); j = l1.erase(j); assert(j == l1.end()); assert(l1.size() == 1); assert(distance(l1.begin(), l1.end()) == 1); assert(*l1.begin() == 1); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); j = l1.erase(l1.begin()); assert(j == l1.end()); assert(l1.size() == 0); assert(distance(l1.begin(), l1.end()) == 0); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {1, 2, 3}; std::vector<int, min_allocator<int>> l1(a1, a1+3); std::vector<int, min_allocator<int>>::const_iterator i = l1.begin(); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); ++i; std::vector<int, min_allocator<int>>::iterator j = l1.erase(i); assert(l1.size() == 2); @@ -58,18 +58,18 @@ int main() assert(*j == 3); assert(*l1.begin() == 1); assert(*next(l1.begin()) == 3); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); j = l1.erase(j); assert(j == l1.end()); assert(l1.size() == 1); assert(distance(l1.begin(), l1.end()) == 1); assert(*l1.begin() == 1); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); j = l1.erase(l1.begin()); assert(j == l1.end()); assert(l1.size() == 0); assert(distance(l1.begin(), l1.end()) == 0); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); } #endif } diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp index 0478d24c79f6..b2c22d6ae696 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db1.pass.cpp @@ -31,7 +31,7 @@ int main() l1.erase(i); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {1, 2, 3}; std::vector<int, min_allocator<int>> l1(a1, a1+3); diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp index c394f197402b..da0b6d4a059b 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_db2.pass.cpp @@ -32,7 +32,7 @@ int main() l1.erase(i); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {1, 2, 3}; std::vector<int, min_allocator<int>> l1(a1, a1+3); diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp index 2e81d133cde0..f7fa0dba27e8 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter.pass.cpp @@ -23,106 +23,106 @@ int main() int a1[] = {1, 2, 3}; { std::vector<int> l1(a1, a1+3); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); std::vector<int>::iterator i = l1.erase(l1.cbegin(), l1.cbegin()); assert(l1.size() == 3); assert(distance(l1.cbegin(), l1.cend()) == 3); assert(i == l1.begin()); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); } { std::vector<int> l1(a1, a1+3); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); std::vector<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin())); assert(l1.size() == 2); assert(distance(l1.cbegin(), l1.cend()) == 2); assert(i == l1.begin()); assert(l1 == std::vector<int>(a1+1, a1+3)); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); } { std::vector<int> l1(a1, a1+3); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); std::vector<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2)); assert(l1.size() == 1); assert(distance(l1.cbegin(), l1.cend()) == 1); assert(i == l1.begin()); assert(l1 == std::vector<int>(a1+2, a1+3)); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); } { std::vector<int> l1(a1, a1+3); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); std::vector<int>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3)); assert(l1.size() == 0); assert(distance(l1.cbegin(), l1.cend()) == 0); assert(i == l1.begin()); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); } { std::vector<std::vector<int> > outer(2, std::vector<int>(1)); - assert(is_contiguous_container_asan_correct(outer)); - assert(is_contiguous_container_asan_correct(outer[0])); - assert(is_contiguous_container_asan_correct(outer[1])); + assert(is_contiguous_container_asan_correct(outer)); + assert(is_contiguous_container_asan_correct(outer[0])); + assert(is_contiguous_container_asan_correct(outer[1])); outer.erase(outer.begin(), outer.begin()); assert(outer.size() == 2); assert(outer[0].size() == 1); assert(outer[1].size() == 1); - assert(is_contiguous_container_asan_correct(outer)); - assert(is_contiguous_container_asan_correct(outer[0])); - assert(is_contiguous_container_asan_correct(outer[1])); + assert(is_contiguous_container_asan_correct(outer)); + assert(is_contiguous_container_asan_correct(outer[0])); + assert(is_contiguous_container_asan_correct(outer[1])); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> l1(a1, a1+3); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), l1.cbegin()); assert(l1.size() == 3); assert(distance(l1.cbegin(), l1.cend()) == 3); assert(i == l1.begin()); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); } { std::vector<int, min_allocator<int>> l1(a1, a1+3); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin())); assert(l1.size() == 2); assert(distance(l1.cbegin(), l1.cend()) == 2); assert(i == l1.begin()); assert((l1 == std::vector<int, min_allocator<int>>(a1+1, a1+3))); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); } { std::vector<int, min_allocator<int>> l1(a1, a1+3); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 2)); assert(l1.size() == 1); assert(distance(l1.cbegin(), l1.cend()) == 1); assert(i == l1.begin()); assert((l1 == std::vector<int, min_allocator<int>>(a1+2, a1+3))); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); } { std::vector<int, min_allocator<int>> l1(a1, a1+3); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); std::vector<int, min_allocator<int>>::iterator i = l1.erase(l1.cbegin(), next(l1.cbegin(), 3)); assert(l1.size() == 0); assert(distance(l1.cbegin(), l1.cend()) == 0); assert(i == l1.begin()); - assert(is_contiguous_container_asan_correct(l1)); + assert(is_contiguous_container_asan_correct(l1)); } { std::vector<std::vector<int, min_allocator<int>>, min_allocator<std::vector<int, min_allocator<int>>>> outer(2, std::vector<int, min_allocator<int>>(1)); - assert(is_contiguous_container_asan_correct(outer)); - assert(is_contiguous_container_asan_correct(outer[0])); - assert(is_contiguous_container_asan_correct(outer[1])); + assert(is_contiguous_container_asan_correct(outer)); + assert(is_contiguous_container_asan_correct(outer[0])); + assert(is_contiguous_container_asan_correct(outer[1])); outer.erase(outer.begin(), outer.begin()); assert(outer.size() == 2); assert(outer[0].size() == 1); assert(outer[1].size() == 1); - assert(is_contiguous_container_asan_correct(outer)); - assert(is_contiguous_container_asan_correct(outer[0])); - assert(is_contiguous_container_asan_correct(outer[1])); + assert(is_contiguous_container_asan_correct(outer)); + assert(is_contiguous_container_asan_correct(outer[0])); + assert(is_contiguous_container_asan_correct(outer[1])); } #endif } diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp index af6d0f757892..14d3ca803ca3 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db1.pass.cpp @@ -31,7 +31,7 @@ int main() std::vector<int>::iterator i = l1.erase(l2.cbegin(), l1.cbegin()+1); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {1, 2, 3}; std::vector<int, min_allocator<int>> l1(a1, a1+3); diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp index eee2c66c5c8c..04c040a8f797 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db2.pass.cpp @@ -31,7 +31,7 @@ int main() std::vector<int>::iterator i = l1.erase(l1.cbegin(), l2.cbegin()+1); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {1, 2, 3}; std::vector<int, min_allocator<int>> l1(a1, a1+3); diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp index 505067d05a1a..ba183a83f0b1 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db3.pass.cpp @@ -31,7 +31,7 @@ int main() std::vector<int>::iterator i = l1.erase(l2.cbegin(), l2.cbegin()+1); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {1, 2, 3}; std::vector<int, min_allocator<int>> l1(a1, a1+3); diff --git a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp index c7e4131cb49c..0fb8071fc679 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/erase_iter_iter_db4.pass.cpp @@ -30,7 +30,7 @@ int main() std::vector<int>::iterator i = l1.erase(l1.cbegin()+1, l1.cbegin()); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {1, 2, 3}; std::vector<int, min_allocator<int>> l1(a1, a1+3); diff --git a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp index 30b801788013..b0fe123aac48 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_initializer_list.pass.cpp @@ -24,7 +24,7 @@ int main() std::vector<int> d(10, 1); std::vector<int>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6}); assert(d.size() == 14); - assert(is_contiguous_container_asan_correct(d)); + assert(is_contiguous_container_asan_correct(d)); assert(i == d.begin() + 2); assert(d[0] == 1); assert(d[1] == 1); @@ -41,12 +41,12 @@ int main() assert(d[12] == 1); assert(d[13] == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> d(10, 1); std::vector<int, min_allocator<int>>::iterator i = d.insert(d.cbegin() + 2, {3, 4, 5, 6}); assert(d.size() == 14); - assert(is_contiguous_container_asan_correct(d)); + assert(is_contiguous_container_asan_correct(d)); assert(i == d.begin() + 2); assert(d[0] == 1); assert(d[1] == 1); diff --git a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp index 782437be87f8..b8953021187f 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_iter_iter.pass.cpp @@ -32,7 +32,7 @@ int main() std::vector<int>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a), input_iterator<const int*>(a+N)); assert(v.size() == 100 + N); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) @@ -49,7 +49,7 @@ int main() std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a), forward_iterator<const int*>(a+N)); assert(v.size() == 100 + N); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) @@ -102,7 +102,7 @@ int main() std::vector<int>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a), input_iterator<const int*>(a+N)); assert(v.size() == 100 + N); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) @@ -119,7 +119,7 @@ int main() std::vector<int>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a), forward_iterator<const int*>(a+N)); assert(v.size() == 100 + N); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) @@ -140,7 +140,7 @@ int main() assert(false); } #endif -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> v(100); int a[] = {1, 2, 3, 4, 5}; @@ -148,7 +148,7 @@ int main() std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, input_iterator<const int*>(a), input_iterator<const int*>(a+N)); assert(v.size() == 100 + N); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) @@ -165,7 +165,7 @@ int main() std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, forward_iterator<const int*>(a), forward_iterator<const int*>(a+N)); assert(v.size() == 100 + N); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) diff --git a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp index e12ec45febfc..e1ad6be054e5 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_rvalue.pass.cpp @@ -29,7 +29,7 @@ int main() std::vector<MoveOnly> v(100); std::vector<MoveOnly>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3)); assert(v.size() == 101); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) @@ -42,7 +42,7 @@ int main() std::vector<MoveOnly, stack_allocator<MoveOnly, 300> > v(100); std::vector<MoveOnly, stack_allocator<MoveOnly, 300> >::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3)); assert(v.size() == 101); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) @@ -59,12 +59,12 @@ int main() assert(false); } #endif -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<MoveOnly, min_allocator<MoveOnly>> v(100); std::vector<MoveOnly, min_allocator<MoveOnly>>::iterator i = v.insert(v.cbegin() + 10, MoveOnly(3)); assert(v.size() == 101); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) diff --git a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp index 6997284f258c..ed4d6c976e9c 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_size_value.pass.cpp @@ -27,7 +27,7 @@ int main() std::vector<int> v(100); std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 5, 1); assert(v.size() == 105); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) @@ -43,7 +43,7 @@ int main() size_t sz = v.size(); std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 5, 1); assert(v.size() == sz + 5); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) @@ -59,7 +59,7 @@ int main() size_t sz = v.size(); std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 5, 1); assert(v.size() == sz + 5); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) @@ -73,7 +73,7 @@ int main() std::vector<int, stack_allocator<int, 300> > v(100); std::vector<int, stack_allocator<int, 300> >::iterator i = v.insert(v.cbegin() + 10, 5, 1); assert(v.size() == 105); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) @@ -91,12 +91,12 @@ int main() assert(false); } #endif -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> v(100); std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 5, 1); assert(v.size() == 105); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) @@ -110,7 +110,7 @@ int main() std::vector<int, min_allocator<int>> v(100); std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 5, 1); assert(v.size() == 105); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) diff --git a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp index 782e752157a7..ba030e9e3fb7 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/insert_iter_value.pass.cpp @@ -27,7 +27,7 @@ int main() std::vector<int> v(100); std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 1); assert(v.size() == 101); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) @@ -42,7 +42,7 @@ int main() size_t sz = v.size(); std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 1); assert(v.size() == sz + 1); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) @@ -58,7 +58,7 @@ int main() size_t sz = v.size(); std::vector<int>::iterator i = v.insert(v.cbegin() + 10, 1); assert(v.size() == sz + 1); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) @@ -71,7 +71,7 @@ int main() std::vector<int, stack_allocator<int, 300> > v(100); std::vector<int, stack_allocator<int, 300> >::iterator i = v.insert(v.cbegin() + 10, 1); assert(v.size() == 101); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) @@ -89,12 +89,12 @@ int main() assert(false); } #endif -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> v(100); std::vector<int, min_allocator<int>>::iterator i = v.insert(v.cbegin() + 10, 1); assert(v.size() == 101); - assert(is_contiguous_container_asan_correct(v)); + assert(is_contiguous_container_asan_correct(v)); assert(i == v.begin() + 10); int j; for (j = 0; j < 10; ++j) diff --git a/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp index 62fa60103baa..c81e41904fc8 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/pop_back.pass.cpp @@ -37,9 +37,9 @@ int main() #if _LIBCPP_DEBUG >= 1 c.pop_back(); assert(false); -#endif +#endif } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> c; c.push_back(1); @@ -49,7 +49,7 @@ int main() #if _LIBCPP_DEBUG >= 1 c.pop_back(); assert(false); -#endif +#endif } -#endif +#endif } diff --git a/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp index eeeba6242d93..bef3b9c8d17d 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/push_back.pass.cpp @@ -23,27 +23,27 @@ int main() std::vector<int> c; c.push_back(0); assert(c.size() == 1); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(1); assert(c.size() == 2); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(2); assert(c.size() == 3); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(3); assert(c.size() == 4); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(4); assert(c.size() == 5); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); } @@ -51,56 +51,56 @@ int main() std::vector<int, stack_allocator<int, 15> > c; c.push_back(0); assert(c.size() == 1); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(1); assert(c.size() == 2); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(2); assert(c.size() == 3); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(3); assert(c.size() == 4); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(4); assert(c.size() == 5); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<int, min_allocator<int>> c; c.push_back(0); assert(c.size() == 1); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(1); assert(c.size() == 2); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(2); assert(c.size() == 3); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(3); assert(c.size() == 4); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); c.push_back(4); assert(c.size() == 5); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == j); } diff --git a/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp index 785225357d4b..5fa93aab89c7 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/push_back_exception_safety.pass.cpp @@ -31,7 +31,7 @@ class CMyClass { private: int fMagicValue; int fTag; - + private: static int kStartedConstructionMagicValue; private: static int kFinishedConstructionMagicValue; }; @@ -73,8 +73,8 @@ int main() vec.push_back(instance); std::vector<CMyClass> vec2(vec); - assert(is_contiguous_container_asan_correct(vec)); - assert(is_contiguous_container_asan_correct(vec2)); + assert(is_contiguous_container_asan_correct(vec)); + assert(is_contiguous_container_asan_correct(vec2)); gCopyConstructorShouldThow = true; try { @@ -82,6 +82,6 @@ int main() } catch (...) { assert(vec==vec2); - assert(is_contiguous_container_asan_correct(vec)); + assert(is_contiguous_container_asan_correct(vec)); } } diff --git a/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp b/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp index b143cd773b42..64762eb374e8 100644 --- a/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp +++ b/test/std/containers/sequences/vector/vector.modifiers/push_back_rvalue.pass.cpp @@ -25,27 +25,27 @@ int main() std::vector<MoveOnly> c; c.push_back(MoveOnly(0)); assert(c.size() == 1); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(1)); assert(c.size() == 2); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(2)); assert(c.size() == 3); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(3)); assert(c.size() == 4); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(4)); assert(c.size() == 5); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); } @@ -53,56 +53,56 @@ int main() std::vector<MoveOnly, stack_allocator<MoveOnly, 15> > c; c.push_back(MoveOnly(0)); assert(c.size() == 1); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(1)); assert(c.size() == 2); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(2)); assert(c.size() == 3); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(3)); assert(c.size() == 4); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(4)); assert(c.size() == 5); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::vector<MoveOnly, min_allocator<MoveOnly>> c; c.push_back(MoveOnly(0)); assert(c.size() == 1); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(1)); assert(c.size() == 2); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(2)); assert(c.size() == 3); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(3)); assert(c.size() == 4); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); c.push_back(MoveOnly(4)); assert(c.size() == 5); - assert(is_contiguous_container_asan_correct(c)); + assert(is_contiguous_container_asan_correct(c)); for (int j = 0; j < c.size(); ++j) assert(c[j] == MoveOnly(j)); } diff --git a/test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp b/test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp index e7f6a0011e1a..1bb761181422 100644 --- a/test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp +++ b/test/std/containers/sequences/vector/vector.special/db_swap_1.pass.cpp @@ -37,7 +37,7 @@ int main() c1.erase(i1); assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; diff --git a/test/std/containers/sequences/vector/vector.special/swap.pass.cpp b/test/std/containers/sequences/vector/vector.special/swap.pass.cpp index 96aaf7131f53..3d01129fa008 100644 --- a/test/std/containers/sequences/vector/vector.special/swap.pass.cpp +++ b/test/std/containers/sequences/vector/vector.special/swap.pass.cpp @@ -26,56 +26,56 @@ int main() int a2[] = {0, 2, 4, 5, 6, 8, 11}; std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0])); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); swap(c1, c2); assert(c1 == std::vector<int>(a2, a2+sizeof(a2)/sizeof(a2[0]))); assert(c2 == std::vector<int>(a1, a1+sizeof(a1)/sizeof(a1[0]))); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); } { int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; std::vector<int> c1(a1, a1); std::vector<int> c2(a2, a2+sizeof(a2)/sizeof(a2[0])); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); swap(c1, c2); assert(c1 == std::vector<int>(a2, a2+sizeof(a2)/sizeof(a2[0]))); assert(c2.empty()); assert(distance(c2.begin(), c2.end()) == 0); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); } { int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; std::vector<int> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); std::vector<int> c2(a2, a2); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); swap(c1, c2); assert(c1.empty()); assert(distance(c1.begin(), c1.end()) == 0); assert(c2 == std::vector<int>(a1, a1+sizeof(a1)/sizeof(a1[0]))); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); } { int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; std::vector<int> c1(a1, a1); std::vector<int> c2(a2, a2); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); swap(c1, c2); assert(c1.empty()); assert(distance(c1.begin(), c1.end()) == 0); assert(c2.empty()); assert(distance(c2.begin(), c2.end()) == 0); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); } #ifndef _LIBCPP_DEBUG_LEVEL // This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1 @@ -98,72 +98,72 @@ int main() typedef other_allocator<int> A; std::vector<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A(1)); std::vector<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A(2)); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); swap(c1, c2); assert((c1 == std::vector<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0])))); assert(c1.get_allocator() == A(2)); assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0])))); assert(c2.get_allocator() == A(1)); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0])); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); swap(c1, c2); assert((c1 == std::vector<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0])))); assert((c2 == std::vector<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0])))); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); } { int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; std::vector<int, min_allocator<int>> c1(a1, a1); std::vector<int, min_allocator<int>> c2(a2, a2+sizeof(a2)/sizeof(a2[0])); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); swap(c1, c2); assert((c1 == std::vector<int, min_allocator<int>>(a2, a2+sizeof(a2)/sizeof(a2[0])))); assert(c2.empty()); assert(distance(c2.begin(), c2.end()) == 0); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); } { int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; std::vector<int, min_allocator<int>> c1(a1, a1+sizeof(a1)/sizeof(a1[0])); std::vector<int, min_allocator<int>> c2(a2, a2); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); swap(c1, c2); assert(c1.empty()); assert(distance(c1.begin(), c1.end()) == 0); assert((c2 == std::vector<int, min_allocator<int>>(a1, a1+sizeof(a1)/sizeof(a1[0])))); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); } { int a1[] = {1, 3, 7, 9, 10}; int a2[] = {0, 2, 4, 5, 6, 8, 11}; std::vector<int, min_allocator<int>> c1(a1, a1); std::vector<int, min_allocator<int>> c2(a2, a2); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); swap(c1, c2); assert(c1.empty()); assert(distance(c1.begin(), c1.end()) == 0); assert(c2.empty()); assert(distance(c2.begin(), c2.end()) == 0); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); } #ifndef _LIBCPP_DEBUG_LEVEL // This test known to result in undefined behavior detected by _LIBCPP_DEBUG_LEVEL >= 1 @@ -173,15 +173,15 @@ int main() typedef min_allocator<int> A; std::vector<int, A> c1(a1, a1+sizeof(a1)/sizeof(a1[0]), A()); std::vector<int, A> c2(a2, a2+sizeof(a2)/sizeof(a2[0]), A()); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); swap(c1, c2); assert((c1 == std::vector<int, A>(a2, a2+sizeof(a2)/sizeof(a2[0])))); assert(c1.get_allocator() == A()); assert((c2 == std::vector<int, A>(a1, a1+sizeof(a1)/sizeof(a1[0])))); assert(c2.get_allocator() == A()); - assert(is_contiguous_container_asan_correct(c1)); - assert(is_contiguous_container_asan_correct(c2)); + assert(is_contiguous_container_asan_correct(c1)); + assert(is_contiguous_container_asan_correct(c2)); } #endif #endif diff --git a/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp b/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp index 1d00ff387480..89fa301ad9bd 100644 --- a/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp +++ b/test/std/containers/sequences/vector/vector.special/swap_noexcept.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <vector> // void swap(vector& c) @@ -22,6 +24,7 @@ #include <vector> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -29,7 +32,7 @@ template <class T> struct some_alloc { typedef T value_type; - + some_alloc() {} some_alloc(const some_alloc&); void deallocate(void*, unsigned) {} @@ -41,7 +44,7 @@ template <class T> struct some_alloc2 { typedef T value_type; - + some_alloc2() {} some_alloc2(const some_alloc2&); void deallocate(void*, unsigned) {} @@ -52,7 +55,6 @@ struct some_alloc2 int main() { -#if __has_feature(cxx_noexcept) { typedef std::vector<MoveOnly> C; C c1, c2; @@ -86,6 +88,4 @@ int main() static_assert( noexcept(swap(c1, c2)), ""); } #endif - -#endif } diff --git a/test/std/containers/sequences/vector/version.pass.cpp b/test/std/containers/sequences/vector/version.pass.cpp deleted file mode 100644 index 2c4fa1263de3..000000000000 --- a/test/std/containers/sequences/vector/version.pass.cpp +++ /dev/null @@ -1,20 +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. -// -//===----------------------------------------------------------------------===// - -// <vector> - -#include <vector> - -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif - -int main() -{ -} diff --git a/test/std/containers/set_allocator_requirement_test_templates.h b/test/std/containers/set_allocator_requirement_test_templates.h new file mode 100644 index 000000000000..2e3346f47e2d --- /dev/null +++ b/test/std/containers/set_allocator_requirement_test_templates.h @@ -0,0 +1,354 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// +#ifndef SET_ALLOCATOR_REQUIREMENT_TEST_TEMPLATES_H +#define SET_ALLOCATOR_REQUIREMENT_TEST_TEMPLATES_H + +// <set> +// <unordered_set> + +// class set +// class unordered_set + +// insert(...); +// emplace(...); +// emplace_hint(...); + + +#include <cassert> + +#include "test_macros.h" +#include "count_new.hpp" +#include "container_test_types.h" +#include "assert_checkpoint.h" + + +template <class Container> +void testSetInsert() +{ + typedef typename Container::value_type ValueTp; + typedef Container C; + typedef std::pair<typename C::iterator, bool> R; + ConstructController* cc = getConstructController(); + cc->reset(); + { + CHECKPOINT("Testing C::insert(const value_type&)"); + Container c; + const ValueTp v(42); + cc->expect<const ValueTp&>(); + assert(c.insert(v).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const ValueTp v2(42); + assert(c.insert(v2).second == false); + } + } + { + CHECKPOINT("Testing C::insert(value_type&)"); + Container c; + ValueTp v(42); + cc->expect<const ValueTp&>(); + assert(c.insert(v).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + ValueTp v2(42); + assert(c.insert(v2).second == false); + } + } + { + CHECKPOINT("Testing C::insert(value_type&&)"); + Container c; + ValueTp v(42); + cc->expect<ValueTp&&>(); + assert(c.insert(std::move(v)).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + ValueTp v2(42); + assert(c.insert(std::move(v2)).second == false); + } + } + { + CHECKPOINT("Testing C::insert(const value_type&&)"); + Container c; + const ValueTp v(42); + cc->expect<const ValueTp&>(); + assert(c.insert(std::move(v)).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const ValueTp v2(42); + assert(c.insert(std::move(v2)).second == false); + } + } + { + CHECKPOINT("Testing C::insert(std::initializer_list<ValueTp>)"); + Container c; + std::initializer_list<ValueTp> il = { ValueTp(1), ValueTp(2) }; + cc->expect<ValueTp const&>(2); + c.insert(il); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + c.insert(il); + } + } + { + CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type const&"); + Container c; + const ValueTp ValueList[] = { ValueTp(1), ValueTp(2), ValueTp(3) }; + cc->expect<ValueTp const&>(3); + c.insert(std::begin(ValueList), std::end(ValueList)); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + c.insert(std::begin(ValueList), std::end(ValueList)); + } + } + { + CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&&"); + Container c; + ValueTp ValueList[] = { ValueTp(1), ValueTp(2) , ValueTp(3) }; + cc->expect<ValueTp&&>(3); + c.insert(std::move_iterator<ValueTp*>(std::begin(ValueList)), + std::move_iterator<ValueTp*>(std::end(ValueList))); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + ValueTp ValueList2[] = { ValueTp(1), ValueTp(2) , ValueTp(3) }; + c.insert(std::move_iterator<ValueTp*>(std::begin(ValueList2)), + std::move_iterator<ValueTp*>(std::end(ValueList2))); + } + } + { + CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&"); + Container c; + ValueTp ValueList[] = { ValueTp(1), ValueTp(2) , ValueTp(3) }; + cc->expect<ValueTp const&>(3); + c.insert(std::begin(ValueList), std::end(ValueList)); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + c.insert(std::begin(ValueList), std::end(ValueList)); + } + } +} + + +template <class Container> +void testSetEmplace() +{ + typedef typename Container::value_type ValueTp; + typedef Container C; + typedef std::pair<typename C::iterator, bool> R; + ConstructController* cc = getConstructController(); + cc->reset(); + { + CHECKPOINT("Testing C::emplace(const value_type&)"); + Container c; + const ValueTp v(42); + cc->expect<const ValueTp&>(); + assert(c.emplace(v).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const ValueTp v2(42); + assert(c.emplace(v2).second == false); + } + } + { + CHECKPOINT("Testing C::emplace(value_type&)"); + Container c; + ValueTp v(42); + cc->expect<ValueTp&>(); + assert(c.emplace(v).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + ValueTp v2(42); + assert(c.emplace(v2).second == false); + } + } + { + CHECKPOINT("Testing C::emplace(value_type&&)"); + Container c; + ValueTp v(42); + cc->expect<ValueTp&&>(); + assert(c.emplace(std::move(v)).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + ValueTp v2(42); + assert(c.emplace(std::move(v2)).second == false); + } + } + { + CHECKPOINT("Testing C::emplace(const value_type&&)"); + Container c; + const ValueTp v(42); + cc->expect<const ValueTp&&>(); + assert(c.emplace(std::move(v)).second); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const ValueTp v2(42); + assert(c.emplace(std::move(v2)).second == false); + } + } +} + + +template <class Container> +void testSetEmplaceHint() +{ + typedef typename Container::value_type ValueTp; + + typedef Container C; + typedef typename C::iterator It; + ConstructController* cc = getConstructController(); + cc->reset(); + { + CHECKPOINT("Testing C::emplace_hint(p, const value_type&)"); + Container c; + const ValueTp v(42); + cc->expect<const ValueTp&>(); + It ret = c.emplace_hint(c.end(), v); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const ValueTp v2(42); + It ret2 = c.emplace_hint(c.begin(), v2); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::emplace_hint(p, value_type&)"); + Container c; + ValueTp v(42); + cc->expect<ValueTp&>(); + It ret = c.emplace_hint(c.end(), v); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + ValueTp v2(42); + It ret2 = c.emplace_hint(c.begin(), v2); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::emplace_hint(p, value_type&&)"); + Container c; + ValueTp v(42); + cc->expect<ValueTp&&>(); + It ret = c.emplace_hint(c.end(), std::move(v)); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + ValueTp v2(42); + It ret2 = c.emplace_hint(c.begin(), std::move(v2)); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } + { + CHECKPOINT("Testing C::emplace_hint(p, const value_type&&)"); + Container c; + const ValueTp v(42); + cc->expect<const ValueTp&&>(); + It ret = c.emplace_hint(c.end(), std::move(v)); + assert(ret != c.end()); + assert(c.size() == 1); + assert(!cc->unchecked()); + { + DisableAllocationGuard g; + const ValueTp v2(42); + It ret2 = c.emplace_hint(c.begin(), std::move(v2)); + assert(&(*ret2) == &(*ret)); + assert(c.size() == 1); + } + } +} + + +template <class Container> +void testMultisetInsert() +{ + typedef typename Container::value_type ValueTp; + typedef Container C; + ConstructController* cc = getConstructController(); + cc->reset(); + { + CHECKPOINT("Testing C::insert(const value_type&)"); + Container c; + const ValueTp v(42); + cc->expect<const ValueTp&>(); + c.insert(v); + assert(!cc->unchecked()); + } + { + CHECKPOINT("Testing C::insert(value_type&)"); + Container c; + ValueTp v(42); + cc->expect<const ValueTp&>(); + c.insert(v); + assert(!cc->unchecked()); + } + { + CHECKPOINT("Testing C::insert(value_type&&)"); + Container c; + ValueTp v(42); + cc->expect<ValueTp&&>(); + c.insert(std::move(v)); + assert(!cc->unchecked()); + } + { + CHECKPOINT("Testing C::insert(std::initializer_list<ValueTp>)"); + Container c; + std::initializer_list<ValueTp> il = { ValueTp(1), ValueTp(2) }; + cc->expect<ValueTp const&>(2); + c.insert(il); + assert(!cc->unchecked()); + } + { + CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type const&"); + Container c; + const ValueTp ValueList[] = { ValueTp(1), ValueTp(2), ValueTp(3) }; + cc->expect<ValueTp const&>(3); + c.insert(std::begin(ValueList), std::end(ValueList)); + assert(!cc->unchecked()); + } + { + CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&&"); + Container c; + ValueTp ValueList[] = { ValueTp(1), ValueTp(2) , ValueTp(3) }; + cc->expect<ValueTp&&>(3); + c.insert(std::move_iterator<ValueTp*>(std::begin(ValueList)), + std::move_iterator<ValueTp*>(std::end(ValueList))); + assert(!cc->unchecked()); + } + { + CHECKPOINT("Testing C::insert(Iter, Iter) for *Iter = value_type&"); + Container c; + ValueTp ValueList[] = { ValueTp(1), ValueTp(2) , ValueTp(3) }; + cc->expect<ValueTp&>(3); + c.insert(std::begin(ValueList), std::end(ValueList)); + assert(!cc->unchecked()); + } +} + +#endif diff --git a/test/std/containers/unord/iterator_difference_type.pass.cpp b/test/std/containers/unord/iterator_difference_type.pass.cpp new file mode 100644 index 000000000000..35bcc27944db --- /dev/null +++ b/test/std/containers/unord/iterator_difference_type.pass.cpp @@ -0,0 +1,154 @@ +//===----------------------------------------------------------------------===// +// +// 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 <unordered_map> +#include <unordered_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 testUnorderedMap() { + 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), ""); + } + { + typedef typename Map::local_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_local_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 testUnorderedSet() { + static_assert((std::is_same<typename Set::iterator, + typename Set::const_iterator>::value), ""); + static_assert((std::is_same<typename Set::local_iterator, + typename Set::const_local_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), ""); + + } + { + typedef typename Set::local_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::unordered_map<int, int> Map; + typedef std::pair<const int, int> ValueTp; + testUnorderedMap<Map, ValueTp, ValueTp*, ValueTp const*>(); + } + { + typedef std::pair<const int, int> ValueTp; + typedef test_allocator<ValueTp> Alloc; + typedef std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, Alloc> Map; + testUnorderedMap<Map, ValueTp, ValueTp*, ValueTp const*>(); + } +#if TEST_STD_VER >= 11 + { + typedef std::pair<const int, int> ValueTp; + typedef min_allocator<ValueTp> Alloc; + typedef std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, Alloc> Map; + testUnorderedMap<Map, ValueTp, min_pointer<ValueTp>, min_pointer<const ValueTp>>(); + } +#endif + { + typedef std::unordered_multimap<int, int> Map; + typedef std::pair<const int, int> ValueTp; + testUnorderedMap<Map, ValueTp, ValueTp*, ValueTp const*>(); + } + { + typedef std::pair<const int, int> ValueTp; + typedef test_allocator<ValueTp> Alloc; + typedef std::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>, Alloc> Map; + testUnorderedMap<Map, ValueTp, ValueTp*, ValueTp const*>(); + } +#if TEST_STD_VER >= 11 + { + typedef std::pair<const int, int> ValueTp; + typedef min_allocator<ValueTp> Alloc; + typedef std::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>, Alloc> Map; + testUnorderedMap<Map, ValueTp, min_pointer<ValueTp>, min_pointer<const ValueTp>>(); + } +#endif + { + typedef int ValueTp; + typedef std::unordered_set<ValueTp> Set; + testUnorderedSet<Set, ValueTp, ValueTp const*>(); + } + { + typedef int ValueTp; + typedef test_allocator<ValueTp> Alloc; + typedef std::unordered_set<ValueTp, std::hash<ValueTp>, std::equal_to<ValueTp>, Alloc> Set; + testUnorderedSet<Set, ValueTp, ValueTp const*>(); + } +#if TEST_STD_VER >= 11 + { + typedef int ValueTp; + typedef min_allocator<ValueTp> Alloc; + typedef std::unordered_set<ValueTp, std::hash<ValueTp>, std::equal_to<ValueTp>, Alloc> Set; + testUnorderedSet<Set, ValueTp, min_pointer<const ValueTp>>(); + } +#endif + { + typedef int ValueTp; + typedef std::unordered_multiset<ValueTp> Set; + testUnorderedSet<Set, ValueTp, ValueTp const*>(); + } + { + typedef int ValueTp; + typedef test_allocator<ValueTp> Alloc; + typedef std::unordered_multiset<ValueTp, std::hash<ValueTp>, std::equal_to<ValueTp>, Alloc> Set; + testUnorderedSet<Set, ValueTp, ValueTp const*>(); + } +#if TEST_STD_VER >= 11 + { + typedef int ValueTp; + typedef min_allocator<ValueTp> Alloc; + typedef std::unordered_multiset<ValueTp, std::hash<ValueTp>, std::equal_to<ValueTp>, Alloc> Set; + testUnorderedSet<Set, ValueTp, min_pointer<const ValueTp>>(); + } +#endif +} diff --git a/test/std/containers/unord/next_prime.pass.cpp b/test/std/containers/unord/next_prime.pass.cpp deleted file mode 100644 index 266d7f1f9d1e..000000000000 --- a/test/std/containers/unord/next_prime.pass.cpp +++ /dev/null @@ -1,51 +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. -// -//===----------------------------------------------------------------------===// -// -// REQUIRES: long_tests - -// Not a portable test - -// <__hash_table> - -// size_t __next_prime(size_t n); - -// If n == 0, return 0, else return the lowest prime greater than or equal to n - -#include <__hash_table> -#include <cassert> - -bool -is_prime(size_t n) -{ - switch (n) - { - case 0: - case 1: - return false; - } - for (size_t i = 2; i*i <= n; ++i) - { - if (n % i == 0) - return false; - } - return true; -} - -int main() -{ - assert(std::__next_prime(0) == 0); - for (std::size_t n = 1; n <= 100000; ++n) - { - std::size_t p = std::__next_prime(n); - assert(p >= n); - for (std::size_t i = n; i < p; ++i) - assert(!is_prime(i)); - assert(is_prime(p)); - } -} diff --git a/test/std/containers/unord/unord.map/bucket.pass.cpp b/test/std/containers/unord/unord.map/bucket.pass.cpp index 6837294e35bc..1abb58070afd 100644 --- a/test/std/containers/unord/unord.map/bucket.pass.cpp +++ b/test/std/containers/unord/unord.map/bucket.pass.cpp @@ -45,7 +45,7 @@ int main() for (size_t i = 0; i < 13; ++i) assert(c.bucket(i) == i % bc); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.map/bucket_size.pass.cpp b/test/std/containers/unord/unord.map/bucket_size.pass.cpp index f3ab8fff4e43..4344508b7334 100644 --- a/test/std/containers/unord/unord.map/bucket_size.pass.cpp +++ b/test/std/containers/unord/unord.map/bucket_size.pass.cpp @@ -47,7 +47,7 @@ int main() assert(c.bucket_size(3) == 1); assert(c.bucket_size(4) == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.map/count.pass.cpp b/test/std/containers/unord/unord.map/count.pass.cpp index 50abb53464ec..68661b56de1c 100644 --- a/test/std/containers/unord/unord.map/count.pass.cpp +++ b/test/std/containers/unord/unord.map/count.pass.cpp @@ -41,7 +41,7 @@ int main() assert(c.count(30) == 1); assert(c.count(5) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.map/db_iterators_7.pass.cpp b/test/std/containers/unord/unord.map/db_iterators_7.pass.cpp deleted file mode 100644 index b8db0a35ffc3..000000000000 --- a/test/std/containers/unord/unord.map/db_iterators_7.pass.cpp +++ /dev/null @@ -1,60 +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. -// -//===----------------------------------------------------------------------===// - -// <unordered_map> - -// Increment iterator past end. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <unordered_map> -#include <string> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef std::unordered_map<int, std::string> C; - C c; - c.insert(std::make_pair(1, "one")); - C::iterator i = c.begin(); - ++i; - assert(i == c.end()); - ++i; - assert(false); - } -#if __cplusplus >= 201103L - { - typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, - min_allocator<std::pair<const int, std::string>>> C; - C c; - c.insert(std::make_pair(1, "one")); - C::iterator i = c.begin(); - ++i; - assert(i == c.end()); - ++i; - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/unord/unord.map/db_iterators_8.pass.cpp b/test/std/containers/unord/unord.map/db_iterators_8.pass.cpp deleted file mode 100644 index c923dd77862e..000000000000 --- a/test/std/containers/unord/unord.map/db_iterators_8.pass.cpp +++ /dev/null @@ -1,56 +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. -// -//===----------------------------------------------------------------------===// - -// <unordered_map> - -// Dereference non-dereferenceable iterator. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <unordered_map> -#include <string> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef std::unordered_map<int, std::string> C; - C c; - c.insert(std::make_pair(1, "one")); - C::iterator i = c.end(); - C::value_type j = *i; - assert(false); - } -#if __cplusplus >= 201103L - { - typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, - min_allocator<std::pair<const int, std::string>>> C; - C c; - c.insert(std::make_pair(1, "one")); - C::iterator i = c.end(); - C::value_type j = *i; - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/unord/unord.map/db_local_iterators_7.pass.cpp b/test/std/containers/unord/unord.map/db_local_iterators_7.pass.cpp deleted file mode 100644 index fa1886bfff18..000000000000 --- a/test/std/containers/unord/unord.map/db_local_iterators_7.pass.cpp +++ /dev/null @@ -1,57 +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. -// -//===----------------------------------------------------------------------===// - -// <unordered_map> - -// Increment local_iterator past end. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <unordered_map> -#include <string> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef std::unordered_map<int, std::string> C; - C c(1); - C::local_iterator i = c.begin(0); - ++i; - ++i; - assert(false); - } -#if __cplusplus >= 201103L - { - typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, - min_allocator<std::pair<const int, std::string>>> C; - C c(1); - C::local_iterator i = c.begin(0); - ++i; - ++i; - assert(false); - } -#endif - -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/unord/unord.map/db_local_iterators_8.pass.cpp b/test/std/containers/unord/unord.map/db_local_iterators_8.pass.cpp deleted file mode 100644 index 4b071cad7b47..000000000000 --- a/test/std/containers/unord/unord.map/db_local_iterators_8.pass.cpp +++ /dev/null @@ -1,54 +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. -// -//===----------------------------------------------------------------------===// - -// <unordered_map> - -// Dereference non-dereferenceable iterator. - -#if _LIBCPP_DEBUG >= 1 - -#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) - -#include <unordered_map> -#include <string> -#include <cassert> -#include <iterator> -#include <exception> -#include <cstdlib> - -#include "min_allocator.h" - -int main() -{ - { - typedef std::unordered_map<int, std::string> C; - C c(1); - C::local_iterator i = c.end(0); - C::value_type j = *i; - assert(false); - } -#if __cplusplus >= 201103L - { - typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, - min_allocator<std::pair<const int, std::string>>> C; - C c(1); - C::local_iterator i = c.end(0); - C::value_type j = *i; - assert(false); - } -#endif -} - -#else - -int main() -{ -} - -#endif diff --git a/test/std/containers/unord/unord.map/eq.pass.cpp b/test/std/containers/unord/unord.map/eq.pass.cpp index 9258378eb09a..5dcea6a73f28 100644 --- a/test/std/containers/unord/unord.map/eq.pass.cpp +++ b/test/std/containers/unord/unord.map/eq.pass.cpp @@ -91,7 +91,7 @@ int main() assert( (c1 == c2)); assert(!(c1 != c2)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.map/equal_range_const.pass.cpp b/test/std/containers/unord/unord.map/equal_range_const.pass.cpp index fe166c965b16..46e04fde2b32 100644 --- a/test/std/containers/unord/unord.map/equal_range_const.pass.cpp +++ b/test/std/containers/unord/unord.map/equal_range_const.pass.cpp @@ -46,7 +46,7 @@ int main() r = c.equal_range(5); assert(std::distance(r.first, r.second) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.map/equal_range_non_const.pass.cpp b/test/std/containers/unord/unord.map/equal_range_non_const.pass.cpp index 9e8d1a9644c5..8d7f34a0b1f2 100644 --- a/test/std/containers/unord/unord.map/equal_range_non_const.pass.cpp +++ b/test/std/containers/unord/unord.map/equal_range_non_const.pass.cpp @@ -46,7 +46,7 @@ int main() r = c.equal_range(5); assert(std::distance(r.first, r.second) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.map/find_const.pass.cpp b/test/std/containers/unord/unord.map/find_const.pass.cpp index 120efa3061b1..0f0ea68bd720 100644 --- a/test/std/containers/unord/unord.map/find_const.pass.cpp +++ b/test/std/containers/unord/unord.map/find_const.pass.cpp @@ -44,7 +44,7 @@ int main() i = c.find(5); assert(i == c.cend()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.map/find_non_const.pass.cpp b/test/std/containers/unord/unord.map/find_non_const.pass.cpp index 7582a796dd7c..cbce62daba16 100644 --- a/test/std/containers/unord/unord.map/find_non_const.pass.cpp +++ b/test/std/containers/unord/unord.map/find_non_const.pass.cpp @@ -44,7 +44,7 @@ int main() i = c.find(5); assert(i == c.end()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.map/incomplete_type.pass.cpp b/test/std/containers/unord/unord.map/incomplete_type.pass.cpp new file mode 100644 index 000000000000..d51b1d8d181f --- /dev/null +++ b/test/std/containers/unord/unord.map/incomplete_type.pass.cpp @@ -0,0 +1,37 @@ + +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <unordered_map> + +// Check that std::unordered_map and it's iterators can be instantiated with an incomplete +// type. + +#include <unordered_map> + +template <class Tp> +struct MyHash { + MyHash() {} + std::size_t operator()(Tp const&) const {return 42;} +}; + +struct A { + typedef std::unordered_map<A, A, MyHash<A> > Map; + Map m; + Map::iterator it; + Map::const_iterator cit; + Map::local_iterator lit; + Map::const_local_iterator clit; +}; + +inline bool operator==(A const& L, A const& R) { return &L == &R; } + +int main() { + A a; +} diff --git a/test/std/containers/unord/unord.map/iterators.pass.cpp b/test/std/containers/unord/unord.map/iterators.pass.cpp index 47b1d7386684..31f4254ea3f8 100644 --- a/test/std/containers/unord/unord.map/iterators.pass.cpp +++ b/test/std/containers/unord/unord.map/iterators.pass.cpp @@ -66,7 +66,7 @@ int main() assert(std::distance(c.cbegin(), c.cend()) == c.size()); C::const_iterator i; } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; @@ -116,7 +116,7 @@ int main() C::const_iterator cii{}; assert ( ii1 == ii2 ); assert ( ii1 == ii4 ); - + assert (!(ii1 != ii2 )); assert ( (ii1 == cii )); diff --git a/test/std/containers/unord/unord.map/local_iterators.pass.cpp b/test/std/containers/unord/unord.map/local_iterators.pass.cpp index 770b1ace7a3e..33a428a4f654 100644 --- a/test/std/containers/unord/unord.map/local_iterators.pass.cpp +++ b/test/std/containers/unord/unord.map/local_iterators.pass.cpp @@ -220,7 +220,7 @@ int main() assert(i->first == 4); assert(i->second == "four"); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.map/max_load_factor.pass.cpp b/test/std/containers/unord/unord.map/max_load_factor.pass.cpp index b19a6e6cfa08..d9e1d057af03 100644 --- a/test/std/containers/unord/unord.map/max_load_factor.pass.cpp +++ b/test/std/containers/unord/unord.map/max_load_factor.pass.cpp @@ -16,6 +16,11 @@ // float max_load_factor() const; // void max_load_factor(float mlf); + +#ifdef _LIBCPP_DEBUG +#define _LIBCPP_ASSERT(x, m) ((x) ? (void)0 : std::exit(0)) +#endif + #include <unordered_map> #include <string> #include <cassert> diff --git a/test/std/containers/unord/unord.map/max_size.pass.cpp b/test/std/containers/unord/unord.map/max_size.pass.cpp index 7d5ae3a8e46d..9c1ca18c3054 100644 --- a/test/std/containers/unord/unord.map/max_size.pass.cpp +++ b/test/std/containers/unord/unord.map/max_size.pass.cpp @@ -26,7 +26,7 @@ int main() std::unordered_map<int, int> u; assert(u.max_size() > 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::unordered_map<int, int, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, int>>> u; diff --git a/test/std/containers/unord/unord.map/rehash.pass.cpp b/test/std/containers/unord/unord.map/rehash.pass.cpp index e1a882c69ffd..fce751593a5e 100644 --- a/test/std/containers/unord/unord.map/rehash.pass.cpp +++ b/test/std/containers/unord/unord.map/rehash.pass.cpp @@ -68,7 +68,7 @@ int main() assert(c.bucket_count() == 31); test(c); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.map/reserve.pass.cpp b/test/std/containers/unord/unord.map/reserve.pass.cpp index bef237f960af..5999801a3923 100644 --- a/test/std/containers/unord/unord.map/reserve.pass.cpp +++ b/test/std/containers/unord/unord.map/reserve.pass.cpp @@ -74,7 +74,7 @@ int main() assert(c.bucket_count() >= 16); test(c); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.map/types.pass.cpp b/test/std/containers/unord/unord.map/types.pass.cpp index b53ff8e1540a..ecdc53c542cd 100644 --- a/test/std/containers/unord/unord.map/types.pass.cpp +++ b/test/std/containers/unord/unord.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::unordered_map<char, short, std::hash<char>, std::equal_to<char>, min_allocator<std::pair<const char, short>>> C; diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp index 0fc76db0fb2f..3c3ec058ead7 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/allocator.pass.cpp @@ -45,7 +45,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<NotConstructible, NotConstructible, test_hash<std::hash<NotConstructible> >, @@ -72,7 +72,7 @@ int main() typedef test_hash<std::hash<T>> HF; typedef test_compare<std::equal_to<T>> Comp; typedef std::unordered_map<T, T, HF, Comp, A> C; - + A a(10); C c(2, a); assert(c.bucket_count() == 2); diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp index fa0105604f15..ee85750f5c36 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/assign_copy.pass.cpp @@ -135,7 +135,7 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef min_allocator<std::pair<const int, std::string> > A; typedef std::unordered_map<int, std::string, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp index 3a854e106543..e4da30bb4efd 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/assign_init.pass.cpp @@ -59,7 +59,7 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef min_allocator<std::pair<const int, std::string> > A; typedef std::unordered_map<int, std::string, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp index dd57c58214fa..fe3eaee4642b 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/assign_move.pass.cpp @@ -165,7 +165,7 @@ int main() assert(c.max_load_factor() == 1); assert(c0.size() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef min_allocator<std::pair<const int, std::string> > A; typedef std::unordered_map<int, std::string, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/compare_copy_constructible.fail.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/compare_copy_constructible.fail.cpp new file mode 100644 index 000000000000..417120b9eb0e --- /dev/null +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/compare_copy_constructible.fail.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 +// The test requires access control SFINAE. + +// <unordered_map> + +// Check that std::unordered_map fails to instantiate if the comparison predicate is +// not copy-constructible. This is LWG issue 2436 + +#include <unordered_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::unordered_map<int, int, std::hash<int>, Comp<int> > m; +} diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp index 447bcab12e6a..0590d12818b3 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/copy.pass.cpp @@ -108,7 +108,7 @@ int main() assert(c.max_load_factor() == 1); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp index 7e9125381cab..cb60807cc0e7 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/copy_alloc.pass.cpp @@ -67,7 +67,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp index a0825db1ecd2..537343a59f7c 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/default.pass.cpp @@ -45,7 +45,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<NotConstructible, NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp index 30e0dc1705a3..939e0bcd4e69 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/default_noexcept.pass.cpp @@ -17,9 +17,12 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <unordered_map> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" #include "../../../test_hash.h" @@ -30,6 +33,7 @@ struct some_comp typedef T value_type; some_comp(); some_comp(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; template <class T> @@ -42,15 +46,14 @@ struct some_hash int main() { -#if __has_feature(cxx_noexcept) { typedef std::unordered_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::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, @@ -66,5 +69,4 @@ int main() some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp index 7fb4200605cf..3585fe7b881a 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/dtor_noexcept.pass.cpp @@ -11,19 +11,20 @@ // ~unordered_map() // implied noexcept; +// UNSUPPORTED: c++98, c++03 + #include <unordered_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; } }; template <class T> @@ -35,11 +36,8 @@ struct some_hash ~some_hash() noexcept(false); }; -#endif - int main() { -#if __has_feature(cxx_noexcept) { typedef std::unordered_map<MoveOnly, MoveOnly> C; static_assert(std::is_nothrow_destructible<C>::value, ""); @@ -63,5 +61,4 @@ int main() some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_destructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/hash_copy_constructible.fail.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/hash_copy_constructible.fail.cpp new file mode 100644 index 000000000000..709b56de2453 --- /dev/null +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/hash_copy_constructible.fail.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 +// The test requires access control SFINAE. + +// <unordered_map> + +// Check that std::unordered_map fails to instantiate if the hash function is +// not copy-constructible. This is mentioned in LWG issue 2436 + +#include <unordered_map> + +template <class T> +struct Hash { + std::size_t operator () (const T& lhs) const { return 0; } + + Hash () {} +private: + Hash (const Hash &); // declared but not defined +}; + + +int main() { + std::unordered_map<int, int, Hash<int> > m; +} diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp index dbc48f816c8b..e980b68b57c1 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/init.pass.cpp @@ -59,7 +59,7 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp index b60fb2cad90c..07e77e33504f 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size.pass.cpp @@ -62,7 +62,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp index f3c086f78876..01aca134a604 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash.pass.cpp @@ -63,7 +63,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp index f71c48a70136..08efdbd3591f 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal.pass.cpp @@ -65,7 +65,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp index c02831676715..02cf5e12eb01 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/init_size_hash_equal_allocator.pass.cpp @@ -66,7 +66,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp index 72a634f0a93d..ea204373890d 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/move_alloc.pass.cpp @@ -111,7 +111,7 @@ int main() assert(c0.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<int, std::string> P; typedef min_allocator<std::pair<const int, std::string>> A; diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp index fc3fc6f05f8a..61c2969d9337 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/move_assign_noexcept.pass.cpp @@ -17,6 +17,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <unordered_map> #include <cassert> @@ -28,6 +30,7 @@ struct some_comp { typedef T value_type; some_comp& operator=(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; template <class T> @@ -41,7 +44,6 @@ struct some_hash int main() { -#if __has_feature(cxx_noexcept) { typedef std::unordered_map<MoveOnly, MoveOnly> C; static_assert(std::is_nothrow_move_assignable<C>::value, ""); @@ -65,5 +67,4 @@ int main() some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } -#endif } diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp index f292011cd7b6..16dc3dc6d4fa 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/move_noexcept.pass.cpp @@ -15,6 +15,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <unordered_map> #include <cassert> @@ -26,6 +28,7 @@ struct some_comp { typedef T value_type; some_comp(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; template <class T> @@ -38,7 +41,6 @@ struct some_hash int main() { -#if __has_feature(cxx_noexcept) { typedef std::unordered_map<MoveOnly, MoveOnly> C; static_assert(std::is_nothrow_move_constructible<C>::value, ""); @@ -62,5 +64,4 @@ int main() some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp index c1784d63b293..d2a18fa45f11 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/range.pass.cpp @@ -63,7 +63,7 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp index b63c47a57dfa..9af18ab61f41 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size.pass.cpp @@ -66,7 +66,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp index 675949e9d9be..e23208dba991 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash.pass.cpp @@ -68,7 +68,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp index d55359f7aa06..d296bab32741 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal.pass.cpp @@ -69,7 +69,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp index 61f9f21ad25b..638efcfebb77 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/range_size_hash_equal_allocator.pass.cpp @@ -71,7 +71,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp index 0a3ae3a117f1..d2551861ec89 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/size.fail.cpp @@ -45,7 +45,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<NotConstructible, NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp index 708dc2362739..465dea21bce1 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/size.pass.cpp @@ -45,7 +45,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<NotConstructible, NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp index 6c975ec72030..f70ad7a1e5bc 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash.pass.cpp @@ -47,7 +47,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<NotConstructible, NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp index 8b2bb317987e..184d77d69d5f 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal.pass.cpp @@ -48,7 +48,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<NotConstructible, NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp index bcf7b91503ad..56eb59ddba9b 100644 --- a/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.cnstr/size_hash_equal_allocator.pass.cpp @@ -49,7 +49,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<NotConstructible, NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp b/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp index 04ce91f69917..5504d33f299b 100644 --- a/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.elem/at.pass.cpp @@ -77,7 +77,7 @@ int main() } assert(c.size() == 4); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.map/unord.map.elem/index.pass.cpp b/test/std/containers/unord/unord.map/unord.map.elem/index.pass.cpp index c072248f866a..7bc59447a5e6 100644 --- a/test/std/containers/unord/unord.map/unord.map.elem/index.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.elem/index.pass.cpp @@ -14,13 +14,20 @@ // class unordered_map // mapped_type& operator[](const key_type& k); +// mapped_type& operator[](key_type&& k); #include <unordered_map> #include <string> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "min_allocator.h" +#include "count_new.hpp" + +#if TEST_STD_VER >= 11 +#include "container_test_types.h" +#endif int main() { @@ -44,7 +51,7 @@ int main() assert(c.size() == 5); assert(c.at(11) == "eleven"); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES +#if TEST_STD_VER >= 11 { typedef std::unordered_map<MoveOnly, std::string> C; typedef std::pair<int, std::string> P; @@ -65,8 +72,6 @@ int main() assert(c.size() == 5); assert(c.at(11) == "eleven"); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; @@ -88,7 +93,7 @@ int main() assert(c.size() == 5); assert(c.at(11) == "eleven"); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES + { typedef std::unordered_map<MoveOnly, std::string, std::hash<MoveOnly>, std::equal_to<MoveOnly>, min_allocator<std::pair<const MoveOnly, std::string>>> C; @@ -110,6 +115,50 @@ int main() assert(c.size() == 5); assert(c.at(11) == "eleven"); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + using Container = TCT::unordered_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); + } + } + { + 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); + } + } + } #endif } diff --git a/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp b/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp index c319b5c30b2c..f2c694e86f74 100644 --- a/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.elem/index_tuple.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <unordered_map> // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, @@ -18,9 +20,6 @@ // http://llvm.org/bugs/show_bug.cgi?id=16542 #include <unordered_map> - -#ifndef _LIBCPP_HAS_NO_VARIADICS - #include <tuple> using namespace std; @@ -30,12 +29,8 @@ struct my_hash size_t operator()(const tuple<int,int>&) const {return 0;} }; -#endif - int main() { -#ifndef _LIBCPP_HAS_NO_VARIADICS unordered_map<tuple<int,int>, size_t, my_hash> m; m[make_tuple(2,3)]=7; -#endif } diff --git a/test/std/containers/unord/unord.map/unord.map.modifiers/clear.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/clear.pass.cpp index 9f320e949479..106423ebfbe9 100644 --- a/test/std/containers/unord/unord.map/unord.map.modifiers/clear.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.modifiers/clear.pass.cpp @@ -39,7 +39,7 @@ int main() c.clear(); assert(c.size() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.map/unord.map.modifiers/emplace.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/emplace.pass.cpp index 5de74d2e6c92..26f716166464 100644 --- a/test/std/containers/unord/unord.map/unord.map.modifiers/emplace.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.modifiers/emplace.pass.cpp @@ -49,7 +49,7 @@ int main() assert(r.first->first == 5); assert(r.first->second == Emplaceable(6, 7)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, Emplaceable, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, Emplaceable>>> C; diff --git a/test/std/containers/unord/unord.map/unord.map.modifiers/emplace_hint.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/emplace_hint.pass.cpp index 21a4689658ae..477f2cf02e76 100644 --- a/test/std/containers/unord/unord.map/unord.map.modifiers/emplace_hint.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.modifiers/emplace_hint.pass.cpp @@ -51,7 +51,7 @@ int main() assert(r->first == 5); assert(r->second == Emplaceable(6, 7)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, Emplaceable, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, Emplaceable>>> C; diff --git a/test/std/containers/unord/unord.map/unord.map.modifiers/erase_range.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/erase_range.pass.cpp index f0664c3c3ffc..820b12a9bf8b 100644 --- a/test/std/containers/unord/unord.map/unord.map.modifiers/erase_range.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.modifiers/erase_range.pass.cpp @@ -58,7 +58,7 @@ int main() assert(c.size() == 0); assert(k == c.end()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.map/unord.map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_and_emplace_allocator_requirements.pass.cpp new file mode 100644 index 000000000000..00c47182c925 --- /dev/null +++ b/test/std/containers/unord/unord.map/unord.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. +// +//===----------------------------------------------------------------------===// + +// <unordered_map> + +// class unordered_map + +// insert(...); +// emplace(...); + +// UNSUPPORTED: c++98, c++03 + + +#include <unordered_map> + +#include "container_test_types.h" +#include "../../../map_allocator_requirement_test_templates.h" + +int main() +{ + testMapInsert<TCT::unordered_map<> >(); + testMapInsertHint<TCT::unordered_map<> >(); + testMapEmplace<TCT::unordered_map<> >(); + testMapEmplaceHint<TCT::unordered_map<> >(); +} diff --git a/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp index a16f097b4c01..fe2b24707fb3 100644 --- a/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_const_lvalue.pass.cpp @@ -18,69 +18,64 @@ #include <unordered_map> #include <cassert> +#include "test_macros.h" #include "min_allocator.h" -int main() + +template <class Container> +void do_insert_cv_test() { - { - typedef std::unordered_map<double, int> C; - typedef std::pair<C::iterator, bool> R; - typedef C::value_type P; - C c; - R r = c.insert(P(3.5, 3)); - assert(r.second); - assert(c.size() == 1); - assert(r.first->first == 3.5); - assert(r.first->second == 3); + typedef Container M; + typedef std::pair<typename M::iterator, bool> R; + typedef typename M::value_type VT; + M m; - r = c.insert(P(3.5, 4)); - assert(!r.second); - assert(c.size() == 1); - assert(r.first->first == 3.5); - assert(r.first->second == 3); + const VT v1(2.5, 2); + R r = m.insert(v1); + assert(r.second); + assert(m.size() == 1); + assert(r.first->first == 2.5); + assert(r.first->second == 2); - r = c.insert(P(4.5, 4)); - assert(r.second); - assert(c.size() == 2); - assert(r.first->first == 4.5); - assert(r.first->second == 4); + r = m.insert(VT(2.5, 3)); // test rvalue insertion works in C++03 + assert(!r.second); + assert(m.size() == 1); + assert(r.first->first == 2.5); + assert(r.first->second == 2); - r = c.insert(P(5.5, 4)); - assert(r.second); - assert(c.size() == 3); - assert(r.first->first == 5.5); - assert(r.first->second == 4); - } -#if __cplusplus >= 201103L - { - typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>, - min_allocator<std::pair<const double, int>>> C; - typedef std::pair<C::iterator, bool> R; - typedef C::value_type P; - C c; - R r = c.insert(P(3.5, 3)); - assert(r.second); - assert(c.size() == 1); - assert(r.first->first == 3.5); - assert(r.first->second == 3); + const VT v2(1.5, 1); + r = m.insert(v2); + assert(r.second); + assert(m.size() == 2); + assert(r.first->first == 1.5); + assert(r.first->second == 1); - r = c.insert(P(3.5, 4)); - assert(!r.second); - assert(c.size() == 1); - assert(r.first->first == 3.5); - assert(r.first->second == 3); + const VT v3(3.5, 3); + r = m.insert(v3); + assert(r.second); + assert(m.size() == 3); + assert(r.first->first == 3.5); + assert(r.first->second == 3); - r = c.insert(P(4.5, 4)); - assert(r.second); - assert(c.size() == 2); - assert(r.first->first == 4.5); - assert(r.first->second == 4); + const VT v4(3.5, 4); + r = m.insert(v4); + assert(!r.second); + assert(m.size() == 3); + assert(r.first->first == 3.5); + assert(r.first->second == 3); +} - r = c.insert(P(5.5, 4)); - assert(r.second); - assert(c.size() == 3); - assert(r.first->first == 5.5); - assert(r.first->second == 4); +int main() +{ + { + typedef std::unordered_map<double, int> M; + do_insert_cv_test<M>(); + } +#if TEST_STD_VER >= 11 + { + typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>, + min_allocator<std::pair<const double, int>>> M; + do_insert_cv_test<M>(); } #endif } diff --git a/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp index 981b8fb18a0a..d40a8a61a3d4 100644 --- a/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_const_lvalue.pass.cpp @@ -52,7 +52,7 @@ int main() assert(r->first == 5.5); assert(r->second == 4); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>, min_allocator<std::pair<const double, int>>> C; diff --git a/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp index 1618c1019e1c..04d01eb466e7 100644 --- a/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_hint_rvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <unordered_map> // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, @@ -55,7 +57,6 @@ int main() assert(r->first == 5.5); assert(r->second == 4); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unordered_map<MoveOnly, MoveOnly> C; typedef C::iterator R; @@ -82,8 +83,6 @@ int main() assert(r->first == 5); assert(r->second == 4); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L { typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>, min_allocator<std::pair<const double, int>>> C; @@ -111,7 +110,6 @@ int main() assert(r->first == 5.5); assert(r->second == 4); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, min_allocator<std::pair<const MoveOnly, MoveOnly>>> C; @@ -139,7 +137,31 @@ int main() assert(r->first == 5); assert(r->second == 4); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_map<double, MoveOnly> C; + typedef C::iterator R; + C c; + C::const_iterator e = c.end(); + R r = c.insert(e, {3.5, 3}); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + r = c.insert(c.end(), {3.5, 4}); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + r = c.insert(c.end(), {4.5, 4}); + assert(c.size() == 2); + assert(r->first == 4.5); + assert(r->second == 4); + + r = c.insert(c.end(), {5.5, 4}); + assert(c.size() == 3); + assert(r->first == 5.5); + assert(r->second == 4); + } #if _LIBCPP_DEBUG >= 1 { typedef std::unordered_map<double, int> C; @@ -152,5 +174,4 @@ int main() assert(false); } #endif -#endif } diff --git a/test/std/containers/unord/unord.map/unord.map.modifiers/insert_init.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_init.pass.cpp index 81e8a468d83f..a4d8b5d410b4 100644 --- a/test/std/containers/unord/unord.map/unord.map.modifiers/insert_init.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_init.pass.cpp @@ -45,7 +45,7 @@ int main() assert(c.at(3) == "three"); assert(c.at(4) == "four"); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.map/unord.map.modifiers/insert_range.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_range.pass.cpp index fc44e7828ffa..b722b4a5ba02 100644 --- a/test/std/containers/unord/unord.map/unord.map.modifiers/insert_range.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_range.pass.cpp @@ -45,7 +45,7 @@ int main() assert(c.at(3) == "three"); assert(c.at(4) == "four"); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_map<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp index f53dc6c7e97a..faf5b046b5d8 100644 --- a/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.modifiers/insert_rvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <unordered_map> // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, @@ -54,7 +56,6 @@ int main() assert(r.first->first == 5.5); assert(r.first->second == 4); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unordered_map<MoveOnly, MoveOnly> C; typedef std::pair<C::iterator, bool> R; @@ -84,8 +85,6 @@ int main() assert(r.first->first == 5); assert(r.first->second == 4); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L { typedef std::unordered_map<double, int, std::hash<double>, std::equal_to<double>, min_allocator<std::pair<const double, int>>> C; @@ -116,7 +115,6 @@ int main() assert(r.first->first == 5.5); assert(r.first->second == 4); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unordered_map<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, min_allocator<std::pair<const MoveOnly, MoveOnly>>> C; @@ -147,6 +145,32 @@ int main() assert(r.first->first == 5); assert(r.first->second == 4); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#endif + { + typedef std::unordered_map<double, MoveOnly> C; + typedef std::pair<C::iterator, bool> R; + C c; + R r = c.insert({3.5, 3}); + assert(r.second); + assert(c.size() == 1); + assert(r.first->first == 3.5); + assert(r.first->second == 3); + + r = c.insert({3.5, 4}); + assert(!r.second); + assert(c.size() == 1); + assert(r.first->first == 3.5); + assert(r.first->second == 3); + + r = c.insert({4.5, 4}); + assert(r.second); + assert(c.size() == 2); + assert(r.first->first == 4.5); + assert(r.first->second == 4); + + r = c.insert({5.5, 4}); + assert(r.second); + assert(c.size() == 3); + assert(r.first->first == 5.5); + assert(r.first->second == 4); + } } diff --git a/test/std/containers/unord/unord.map/unord.map.modifiers/try.emplace.pass.cpp b/test/std/containers/unord/unord.map/unord.map.modifiers/try.emplace.pass.cpp index eabcf2e85db2..adc4d6944ecb 100644 --- a/test/std/containers/unord/unord.map/unord.map.modifiers/try.emplace.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.modifiers/try.emplace.pass.cpp @@ -22,7 +22,6 @@ // template <class... Args> // iterator try_emplace(const_iterator hint, key_type&& k, Args&&... args); // C++17 -#include <__config> #include <unordered_map> #include <cassert> #include <tuple> diff --git a/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp b/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp index 1056c231f0db..f8f17ffec57a 100644 --- a/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.map/unord.map.swap/swap_noexcept.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <unordered_map> // void swap(unordered_map& c) @@ -26,6 +28,7 @@ #include <unordered_map> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -33,20 +36,20 @@ template <class T> struct some_comp { typedef T value_type; - + some_comp() {} some_comp(const some_comp&) {} + 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 @@ -79,7 +82,7 @@ template <class T> struct some_alloc { typedef T value_type; - + some_alloc() {} some_alloc(const some_alloc&); void deallocate(void*, unsigned) {} @@ -91,7 +94,7 @@ template <class T> struct some_alloc2 { typedef T value_type; - + some_alloc2() {} some_alloc2(const some_alloc2&); void deallocate(void*, unsigned) {} @@ -104,7 +107,7 @@ template <class T> struct some_alloc3 { typedef T value_type; - + some_alloc3() {} some_alloc3(const some_alloc3&); void deallocate(void*, unsigned) {} @@ -116,7 +119,6 @@ struct some_alloc3 int main() { -#if __has_feature(cxx_noexcept) typedef std::pair<const MoveOnly, MoveOnly> MapType; { typedef std::unordered_map<MoveOnly, MoveOnly> C; @@ -195,5 +197,4 @@ int main() static_assert( noexcept(swap(c1, c2)), ""); } #endif -#endif } diff --git a/test/std/containers/unord/unord.multimap/bucket.pass.cpp b/test/std/containers/unord/unord.multimap/bucket.pass.cpp index be5acc196308..415dce11c128 100644 --- a/test/std/containers/unord/unord.multimap/bucket.pass.cpp +++ b/test/std/containers/unord/unord.multimap/bucket.pass.cpp @@ -45,7 +45,7 @@ int main() for (size_t i = 0; i < 13; ++i) assert(c.bucket(i) == i % bc); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/bucket_size.pass.cpp b/test/std/containers/unord/unord.multimap/bucket_size.pass.cpp index a02f72efc6c2..3bc3f5876fe6 100644 --- a/test/std/containers/unord/unord.multimap/bucket_size.pass.cpp +++ b/test/std/containers/unord/unord.multimap/bucket_size.pass.cpp @@ -49,7 +49,7 @@ int main() assert(c.bucket_size(5) == 0); assert(c.bucket_size(6) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/count.pass.cpp b/test/std/containers/unord/unord.multimap/count.pass.cpp index efaf02e3a572..c93a2237c480 100644 --- a/test/std/containers/unord/unord.multimap/count.pass.cpp +++ b/test/std/containers/unord/unord.multimap/count.pass.cpp @@ -44,7 +44,7 @@ int main() assert(c.count(50) == 3); assert(c.count(5) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/db_iterators_7.pass.cpp b/test/std/containers/unord/unord.multimap/db_iterators_7.pass.cpp index b6ba8d6194a4..8a23edd174b0 100644 --- a/test/std/containers/unord/unord.multimap/db_iterators_7.pass.cpp +++ b/test/std/containers/unord/unord.multimap/db_iterators_7.pass.cpp @@ -36,7 +36,7 @@ int main() ++i; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/db_iterators_8.pass.cpp b/test/std/containers/unord/unord.multimap/db_iterators_8.pass.cpp index f5ea5089349b..e5a9ce961530 100644 --- a/test/std/containers/unord/unord.multimap/db_iterators_8.pass.cpp +++ b/test/std/containers/unord/unord.multimap/db_iterators_8.pass.cpp @@ -34,7 +34,7 @@ int main() C::value_type j = *i; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp b/test/std/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp index 93cbd5433f47..2bd161f75072 100644 --- a/test/std/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp +++ b/test/std/containers/unord/unord.multimap/db_local_iterators_7.pass.cpp @@ -34,7 +34,7 @@ int main() ++i; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp b/test/std/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp index 159ae4963532..78b40e14e7a1 100644 --- a/test/std/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp +++ b/test/std/containers/unord/unord.multimap/db_local_iterators_8.pass.cpp @@ -33,7 +33,7 @@ int main() C::value_type j = *i; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/eq.pass.cpp b/test/std/containers/unord/unord.multimap/eq.pass.cpp index 3604e7792c13..f95bea3daef3 100644 --- a/test/std/containers/unord/unord.multimap/eq.pass.cpp +++ b/test/std/containers/unord/unord.multimap/eq.pass.cpp @@ -100,7 +100,7 @@ int main() assert( (c1 == c2)); assert(!(c1 != c2)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp b/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp index 67613b094bfc..382ed7c9831d 100644 --- a/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp +++ b/test/std/containers/unord/unord.multimap/equal_range_const.pass.cpp @@ -57,7 +57,7 @@ int main() assert(r.first->first == 50); assert(r.first->second == "fiftyB"); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp b/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp index eb4c019af951..17eb14e44262 100644 --- a/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp +++ b/test/std/containers/unord/unord.multimap/equal_range_non_const.pass.cpp @@ -57,7 +57,7 @@ int main() assert(r.first->first == 50); assert(r.first->second == "fiftyB"); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/find_const.pass.cpp b/test/std/containers/unord/unord.multimap/find_const.pass.cpp index bc2650d111f3..70c2b45efbd4 100644 --- a/test/std/containers/unord/unord.multimap/find_const.pass.cpp +++ b/test/std/containers/unord/unord.multimap/find_const.pass.cpp @@ -44,7 +44,7 @@ int main() i = c.find(5); assert(i == c.cend()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/find_non_const.pass.cpp b/test/std/containers/unord/unord.multimap/find_non_const.pass.cpp index 5a128c0f37e1..0510d14419d5 100644 --- a/test/std/containers/unord/unord.multimap/find_non_const.pass.cpp +++ b/test/std/containers/unord/unord.multimap/find_non_const.pass.cpp @@ -44,7 +44,7 @@ int main() i = c.find(5); assert(i == c.end()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/incomplete.pass.cpp b/test/std/containers/unord/unord.multimap/incomplete.pass.cpp new file mode 100644 index 000000000000..7822224e7366 --- /dev/null +++ b/test/std/containers/unord/unord.multimap/incomplete.pass.cpp @@ -0,0 +1,37 @@ + +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <unordered_map> + +// Check that std::unordered_multimap and it's iterators can be instantiated with an incomplete +// type. + +#include <unordered_map> + +template <class Tp> +struct MyHash { + MyHash() {} + std::size_t operator()(Tp const&) const {return 42;} +}; + +struct A { + typedef std::unordered_multimap<A, A, MyHash<A> > Map; + Map m; + Map::iterator it; + Map::const_iterator cit; + Map::local_iterator lit; + Map::const_local_iterator clit; +}; + +inline bool operator==(A const& L, A const& R) { return &L == &R; } + +int main() { + A a; +} diff --git a/test/std/containers/unord/unord.multimap/iterators.pass.cpp b/test/std/containers/unord/unord.multimap/iterators.pass.cpp index 1831cf1149b1..cc75bb10a811 100644 --- a/test/std/containers/unord/unord.multimap/iterators.pass.cpp +++ b/test/std/containers/unord/unord.multimap/iterators.pass.cpp @@ -69,7 +69,7 @@ int main() assert(std::distance(c.cbegin(), c.cend()) == c.size()); C::const_iterator i; } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/load_factor.pass.cpp b/test/std/containers/unord/unord.multimap/load_factor.pass.cpp index 52b3f03d88a1..9c42435946ff 100644 --- a/test/std/containers/unord/unord.multimap/load_factor.pass.cpp +++ b/test/std/containers/unord/unord.multimap/load_factor.pass.cpp @@ -48,7 +48,7 @@ int main() const C c; assert(c.load_factor() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp b/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp index 35e4c772fd33..504fe54de830 100644 --- a/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp +++ b/test/std/containers/unord/unord.multimap/local_iterators.pass.cpp @@ -284,7 +284,7 @@ int main() j = c.cend(b); assert(std::distance(i, j) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp b/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp index 23b90579ec41..a2ab399d3469 100644 --- a/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp +++ b/test/std/containers/unord/unord.multimap/max_bucket_count.pass.cpp @@ -30,7 +30,7 @@ int main() const C c; assert(c.max_bucket_count() > 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp b/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp index 39b7feeba4e5..b0b2b664f098 100644 --- a/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp +++ b/test/std/containers/unord/unord.multimap/max_load_factor.pass.cpp @@ -42,7 +42,7 @@ int main() c.max_load_factor(2.5); assert(c.max_load_factor() == 2.5); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/max_size.pass.cpp b/test/std/containers/unord/unord.multimap/max_size.pass.cpp index caba5932b23c..3bf1f1496f68 100644 --- a/test/std/containers/unord/unord.multimap/max_size.pass.cpp +++ b/test/std/containers/unord/unord.multimap/max_size.pass.cpp @@ -26,7 +26,7 @@ int main() std::unordered_multimap<int, int> u; assert(u.max_size() > 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::unordered_multimap<int, int, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, int>>> u; diff --git a/test/std/containers/unord/unord.multimap/rehash.pass.cpp b/test/std/containers/unord/unord.multimap/rehash.pass.cpp index 5ef21d3bc4ce..c099abe2ac05 100644 --- a/test/std/containers/unord/unord.multimap/rehash.pass.cpp +++ b/test/std/containers/unord/unord.multimap/rehash.pass.cpp @@ -97,7 +97,7 @@ int main() assert(c.bucket_count() == 31); test(c); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/reserve.pass.cpp b/test/std/containers/unord/unord.multimap/reserve.pass.cpp index 388b1f67e450..3f76da11e3d9 100644 --- a/test/std/containers/unord/unord.multimap/reserve.pass.cpp +++ b/test/std/containers/unord/unord.multimap/reserve.pass.cpp @@ -76,7 +76,7 @@ int main() assert(c.bucket_count() >= 16); test(c); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/swap_member.pass.cpp b/test/std/containers/unord/unord.multimap/swap_member.pass.cpp index 225eccd4793f..4653cc32ef36 100644 --- a/test/std/containers/unord/unord.multimap/swap_member.pass.cpp +++ b/test/std/containers/unord/unord.multimap/swap_member.pass.cpp @@ -396,7 +396,7 @@ int main() assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); assert(c2.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef test_hash<std::hash<int> > Hash; typedef test_compare<std::equal_to<int> > Compare; diff --git a/test/std/containers/unord/unord.multimap/types.pass.cpp b/test/std/containers/unord/unord.multimap/types.pass.cpp index 55ae749746c1..e141234904e4 100644 --- a/test/std/containers/unord/unord.multimap/types.pass.cpp +++ b/test/std/containers/unord/unord.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::unordered_multimap<char, short, std::hash<char>, std::equal_to<char>, min_allocator<std::pair<const char, short>>> C; diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp index dc41fad29af8..6eb258db4960 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/allocator.pass.cpp @@ -45,7 +45,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<NotConstructible, NotConstructible, test_hash<std::hash<NotConstructible> >, @@ -72,7 +72,7 @@ int main() typedef test_hash<std::hash<T>> HF; typedef test_compare<std::equal_to<T>> Comp; typedef std::unordered_multimap<T, T, HF, Comp, A> C; - + A a(10); C c(2, a); assert(c.bucket_count() == 2); diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp index df566b396f99..5634a79eff33 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_copy.pass.cpp @@ -163,7 +163,7 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef min_allocator<std::pair<const int, std::string> > A; typedef std::unordered_multimap<int, std::string, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp index 2d3c1434d69f..0d3b4453dd44 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_init.pass.cpp @@ -84,7 +84,7 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef min_allocator<std::pair<const int, std::string> > A; typedef std::unordered_multimap<int, std::string, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp index 0c43fa8f06ed..ed8d792e8178 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/assign_move.pass.cpp @@ -223,7 +223,7 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef min_allocator<std::pair<const int, std::string> > A; typedef std::unordered_multimap<int, std::string, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/compare_copy_constructible.fail.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/compare_copy_constructible.fail.cpp new file mode 100644 index 000000000000..d3e31484c8b7 --- /dev/null +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/compare_copy_constructible.fail.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 +// The test requires access control SFINAE. + +// <unordered_map> + +// Check that std::unordered_multimap fails to instantiate if the comparison predicate is +// not copy-constructible. This is LWG issue 2436 + +#include <unordered_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::unordered_multimap<int, int, std::hash<int>, Comp<int> > m; +} diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp index 06adfd7cfe05..7b0adda182cb 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy.pass.cpp @@ -136,7 +136,7 @@ int main() assert(c.max_load_factor() == 1); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp index 0fb508f1f124..e759267b45b1 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/copy_alloc.pass.cpp @@ -81,7 +81,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp index 1884065ce0c8..f361b2c3dfdd 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default.pass.cpp @@ -45,7 +45,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<NotConstructible, NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp index fac3cec63d70..e404612a754e 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/default_noexcept.pass.cpp @@ -17,9 +17,12 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <unordered_map> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" #include "../../../test_hash.h" @@ -30,6 +33,7 @@ struct some_comp typedef T value_type; some_comp(); some_comp(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; template <class T> @@ -42,15 +46,14 @@ struct some_hash int main() { -#if __has_feature(cxx_noexcept) { typedef std::unordered_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::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, test_allocator<std::pair<const MoveOnly, MoveOnly>>> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, @@ -66,5 +69,4 @@ int main() some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp index 220785196791..2797f8dcfb04 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/dtor_noexcept.pass.cpp @@ -11,19 +11,20 @@ // ~unordered_multimap() // implied noexcept; +// UNSUPPORTED: c++98, c++03 + #include <unordered_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; } }; template <class T> @@ -35,11 +36,8 @@ struct some_hash ~some_hash() noexcept(false); }; -#endif - int main() { -#if __has_feature(cxx_noexcept) { typedef std::unordered_multimap<MoveOnly, MoveOnly> C; static_assert(std::is_nothrow_destructible<C>::value, ""); @@ -63,5 +61,4 @@ int main() some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_destructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/hash_copy_constructible.fail.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/hash_copy_constructible.fail.cpp new file mode 100644 index 000000000000..4214f694a20f --- /dev/null +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/hash_copy_constructible.fail.cpp @@ -0,0 +1,32 @@ +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++98, c++03 +// The test requires access control SFINAE. + +// <unordered_map> + +// Check that std::unordered_multimap fails to instantiate if the hash function is +// not copy-constructible. This is mentioned in LWG issue 2436 + +#include <unordered_map> + +template <class T> +struct Hash { + std::size_t operator () (const T& lhs) const { return 0; } + + Hash () {} +private: + Hash (const Hash &); // declared but not defined + }; + + +int main() { + std::unordered_multimap<int, int, Hash<int> > m; +} diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp index cc5532adbe08..f6bc3a08cae9 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init.pass.cpp @@ -81,7 +81,7 @@ int main() assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >())); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp index 8f6710a93317..5dc4323493e4 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size.pass.cpp @@ -84,7 +84,7 @@ int main() assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >())); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp index 0962e9b29f83..8bcbd0bdc352 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash.pass.cpp @@ -85,7 +85,7 @@ int main() assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >())); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp index 324b0a7c1a5e..8dda376db3f9 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal.pass.cpp @@ -87,7 +87,7 @@ int main() assert(c.key_eq() == test_compare<std::equal_to<int> >(9)); assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >())); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp index 23ae7d19f9c2..6843613b0481 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/init_size_hash_equal_allocator.pass.cpp @@ -88,7 +88,7 @@ int main() assert(c.key_eq() == test_compare<std::equal_to<int> >(9)); assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10))); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp index b61735eb0256..58d1424d8b1e 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move.pass.cpp @@ -128,7 +128,7 @@ int main() assert(c0.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp index 106c29cda8d0..a66e41e8e35c 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_alloc.pass.cpp @@ -159,7 +159,7 @@ int main() assert(c0.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::pair<int, std::string> P; typedef min_allocator<std::pair<const int, std::string>> A; diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp index 47e61ab70b83..eeda7b39e958 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_assign_noexcept.pass.cpp @@ -17,6 +17,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <unordered_map> #include <cassert> @@ -28,6 +30,7 @@ struct some_comp { typedef T value_type; some_comp& operator=(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; template <class T> @@ -41,7 +44,6 @@ struct some_hash int main() { -#if __has_feature(cxx_noexcept) { typedef std::unordered_multimap<MoveOnly, MoveOnly> C; static_assert(std::is_nothrow_move_assignable<C>::value, ""); @@ -65,5 +67,4 @@ int main() some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } -#endif } diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp index 37f17876973a..965c46499a16 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/move_noexcept.pass.cpp @@ -15,6 +15,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <unordered_map> #include <cassert> @@ -26,6 +28,7 @@ struct some_comp { typedef T value_type; some_comp(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; template <class T> @@ -38,7 +41,6 @@ struct some_hash int main() { -#if __has_feature(cxx_noexcept) { typedef std::unordered_multimap<MoveOnly, MoveOnly> C; static_assert(std::is_nothrow_move_constructible<C>::value, ""); @@ -62,5 +64,4 @@ int main() some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp index bb700ec565dc..96ad70a56e0f 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range.pass.cpp @@ -85,7 +85,7 @@ int main() assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >())); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp index ad33b13054c7..15b31b519b74 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size.pass.cpp @@ -88,7 +88,7 @@ int main() assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >())); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp index 98644c75e33b..f565f10c89b5 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash.pass.cpp @@ -90,7 +90,7 @@ int main() assert(c.key_eq() == test_compare<std::equal_to<int> >()); assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >())); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp index 9a79c3056358..8f86befbe37f 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal.pass.cpp @@ -91,7 +91,7 @@ int main() assert(c.key_eq() == test_compare<std::equal_to<int> >(9)); assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >())); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp index a5aafb96c7b0..e8040d88de2a 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/range_size_hash_equal_allocator.pass.cpp @@ -93,7 +93,7 @@ int main() assert(c.key_eq() == test_compare<std::equal_to<int> >(9)); assert((c.get_allocator() == test_allocator<std::pair<const int, std::string> >(10))); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp index 44cf84ff323c..38e6c60df52d 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.fail.cpp @@ -45,7 +45,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<NotConstructible, NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp index bd56a41fd71f..8aad662610ab 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size.pass.cpp @@ -45,7 +45,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<NotConstructible, NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp index 33460612ce3f..2cc6c0176e5e 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash.pass.cpp @@ -47,7 +47,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<NotConstructible, NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp index c2420ce9e6f5..ebfce9fec564 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal.pass.cpp @@ -48,7 +48,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<NotConstructible, NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp index 33886670b3b4..56e3808984c5 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.cnstr/size_hash_equal_allocator.pass.cpp @@ -49,7 +49,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<NotConstructible, NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp index 4efcfaa6ce53..891d44911eb0 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/clear.pass.cpp @@ -39,7 +39,7 @@ int main() c.clear(); assert(c.size() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp index 4f2e8ef061fa..96678cf33fa5 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace.pass.cpp @@ -46,7 +46,7 @@ int main() assert(r->first == 5); assert(r->second == Emplaceable(6, 7)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, Emplaceable, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, Emplaceable>>> C; diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp index 4d141ad137c8..8bccd4013a29 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/emplace_hint.pass.cpp @@ -59,7 +59,7 @@ int main() assert(r->first == 3); assert(r->second == Emplaceable(5, 6)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, Emplaceable, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, Emplaceable>>> C; diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp index b31a4e56b31e..9da1e71cba06 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_const_iter.pass.cpp @@ -76,7 +76,7 @@ int main() assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; @@ -123,7 +123,7 @@ int main() assert(std::distance(c.cbegin(), c.cend()) == c.size()); } #endif -#if __cplusplus >= 201402L +#if TEST_STD_VER >= 14 { // This is LWG #2059 typedef TemplateConstructor T; diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp index 892f8a247502..f061d858e3f7 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_key.pass.cpp @@ -21,12 +21,12 @@ #include "min_allocator.h" -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 template <typename Unordered> bool only_deletions ( const Unordered &whole, const Unordered &part ) { typename Unordered::const_iterator w = whole.begin(); typename Unordered::const_iterator p = part.begin(); - + while ( w != whole.end () && p != part.end()) { if ( *w == *p ) p++; @@ -200,7 +200,7 @@ int main() assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; @@ -372,7 +372,7 @@ int main() m2.insert(std::make_pair(i,j)); } } - + C::iterator i = m2.begin(); int ctr = 0; while (i != m2.end()) { diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp index f60ec071ff70..110cc4542b42 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/erase_range.pass.cpp @@ -98,7 +98,7 @@ int main() assert(c.size() == 0); assert(k == c.end()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.map/version.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_allocator_requirements.pass.cpp index fc47a326c571..30f78936ff92 100644 --- a/test/std/containers/unord/unord.map/version.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_allocator_requirements.pass.cpp @@ -9,12 +9,19 @@ // <unordered_map> +// class unordered_multimap + +// insert(...) + +// UNSUPPORTED: c++98, c++03 + #include <unordered_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::unordered_multimap<> >(); + testMultimapInsertHint<TCT::unordered_multimap<> >(); } diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp index e7e7cb03b6d0..320fbc8fe2ea 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_const_lvalue.pass.cpp @@ -47,7 +47,7 @@ int main() assert(r->first == 5.5); assert(r->second == 4); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<double, int, std::hash<double>, std::equal_to<double>, min_allocator<std::pair<const double, int>>> C; diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp index c7cb1f4c014b..c920ae93553f 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_const_lvalue.pass.cpp @@ -52,7 +52,7 @@ int main() assert(r->first == 5.5); assert(r->second == 4); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<double, int, std::hash<double>, std::equal_to<double>, min_allocator<std::pair<const double, int>>> C; diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp index 7116fa02b6f5..d6c0dbdbed07 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_hint_rvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <unordered_map> // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, @@ -55,7 +57,6 @@ int main() assert(r->first == 5.5); assert(r->second == 4); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unordered_multimap<MoveOnly, MoveOnly> C; typedef C::iterator R; @@ -82,8 +83,6 @@ int main() assert(r->first == 5); assert(r->second == 4); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L { typedef std::unordered_multimap<double, int, std::hash<double>, std::equal_to<double>, min_allocator<std::pair<const double, int>>> C; @@ -111,7 +110,6 @@ int main() assert(r->first == 5.5); assert(r->second == 4); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, min_allocator<std::pair<const MoveOnly, MoveOnly>>> C; @@ -139,7 +137,31 @@ int main() assert(r->first == 5); assert(r->second == 4); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES + { + typedef std::unordered_multimap<double, int> C; + typedef C::iterator R; + C c; + C::const_iterator e = c.end(); + R r = c.insert(e, {3.5, 3}); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + r = c.insert(r, {3.5, 4}); + assert(c.size() == 2); + assert(r->first == 3.5); + assert(r->second == 4); + + r = c.insert(c.end(), {4.5, 4}); + assert(c.size() == 3); + assert(r->first == 4.5); + assert(r->second == 4); + + r = c.insert(c.end(), {5.5, 4}); + assert(c.size() == 4); + assert(r->first == 5.5); + assert(r->second == 4); + } #if _LIBCPP_DEBUG >= 1 { typedef std::unordered_multimap<double, int> C; @@ -152,5 +174,4 @@ int main() assert(false); } #endif -#endif } diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp index 23dbe84a3c51..851b36e51ca4 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_init.pass.cpp @@ -70,7 +70,7 @@ int main() assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp index 2820639b4ea0..967ad369da3f 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_range.pass.cpp @@ -70,7 +70,7 @@ int main() assert(std::distance(c.begin(), c.end()) == c.size()); assert(std::distance(c.cbegin(), c.cend()) == c.size()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multimap<int, std::string, std::hash<int>, std::equal_to<int>, min_allocator<std::pair<const int, std::string>>> C; diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp index 5a98467e9d0f..6735b8af5a0a 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.modifiers/insert_rvalue.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <unordered_map> // template <class Key, class T, class Hash = hash<Key>, class Pred = equal_to<Key>, @@ -50,7 +52,6 @@ int main() assert(r->first == 5.5); assert(r->second == 4); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unordered_multimap<MoveOnly, MoveOnly> C; typedef C::iterator R; @@ -76,8 +77,6 @@ int main() assert(r->first == 5); assert(r->second == 4); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L { typedef std::unordered_multimap<double, int, std::hash<double>, std::equal_to<double>, min_allocator<std::pair<const double, int>>> C; @@ -104,7 +103,6 @@ int main() assert(r->first == 5.5); assert(r->second == 4); } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES { typedef std::unordered_multimap<MoveOnly, MoveOnly, std::hash<MoveOnly>, std::equal_to<MoveOnly>, min_allocator<std::pair<const MoveOnly, MoveOnly>>> C; @@ -131,6 +129,28 @@ int main() assert(r->first == 5); assert(r->second == 4); } -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#endif + { + typedef std::unordered_multimap<double, MoveOnly> C; + typedef C::iterator R; + C c; + R r = c.insert({3.5, 3}); + assert(c.size() == 1); + assert(r->first == 3.5); + assert(r->second == 3); + + r = c.insert({3.5, 4}); + assert(c.size() == 2); + assert(r->first == 3.5); + assert(r->second == 4); + + r = c.insert({4.5, 4}); + assert(c.size() == 3); + assert(r->first == 4.5); + assert(r->second == 4); + + r = c.insert({5.5, 4}); + assert(c.size() == 4); + assert(r->first == 5.5); + assert(r->second == 4); + } } diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp index 7c912e01d572..553131182315 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_noexcept.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <unordered_map> // void swap(unordered_multimap& c) @@ -26,6 +28,7 @@ #include <unordered_map> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -33,20 +36,20 @@ template <class T> struct some_comp { typedef T value_type; - + some_comp() {} some_comp(const some_comp&) {} + 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 @@ -79,7 +82,7 @@ template <class T> struct some_alloc { typedef T value_type; - + some_alloc() {} some_alloc(const some_alloc&); void deallocate(void*, unsigned) {} @@ -91,7 +94,7 @@ template <class T> struct some_alloc2 { typedef T value_type; - + some_alloc2() {} some_alloc2(const some_alloc2&); void deallocate(void*, unsigned) {} @@ -104,7 +107,7 @@ template <class T> struct some_alloc3 { typedef T value_type; - + some_alloc3() {} some_alloc3(const some_alloc3&); void deallocate(void*, unsigned) {} @@ -115,7 +118,6 @@ struct some_alloc3 int main() { -#if __has_feature(cxx_noexcept) typedef std::pair<const MoveOnly, MoveOnly> V; { typedef std::unordered_multimap<MoveOnly, MoveOnly> C; @@ -193,6 +195,4 @@ int main() static_assert( noexcept(swap(c1, c2)), ""); } #endif - -#endif } diff --git a/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp index 0f579e091683..84911ba01ffb 100644 --- a/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp +++ b/test/std/containers/unord/unord.multimap/unord.multimap.swap/swap_non_member.pass.cpp @@ -395,7 +395,7 @@ int main() assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); assert(c2.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef test_hash<std::hash<int> > Hash; typedef test_compare<std::equal_to<int> > Compare; diff --git a/test/std/containers/unord/unord.multiset/bucket.pass.cpp b/test/std/containers/unord/unord.multiset/bucket.pass.cpp index 0293133d494a..30858c79a048 100644 --- a/test/std/containers/unord/unord.multiset/bucket.pass.cpp +++ b/test/std/containers/unord/unord.multiset/bucket.pass.cpp @@ -44,7 +44,7 @@ int main() for (size_t i = 0; i < 13; ++i) assert(c.bucket(i) == i % bc); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp b/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp index c7842e5c1977..adde647cb246 100644 --- a/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp +++ b/test/std/containers/unord/unord.multiset/bucket_count.pass.cpp @@ -47,7 +47,7 @@ int main() const C c(std::begin(a), std::end(a)); assert(c.bucket_count() >= 11); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/bucket_size.pass.cpp b/test/std/containers/unord/unord.multiset/bucket_size.pass.cpp index 639d7ac37965..7ca480556349 100644 --- a/test/std/containers/unord/unord.multiset/bucket_size.pass.cpp +++ b/test/std/containers/unord/unord.multiset/bucket_size.pass.cpp @@ -48,7 +48,7 @@ int main() assert(c.bucket_size(5) == 0); assert(c.bucket_size(6) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/clear.pass.cpp b/test/std/containers/unord/unord.multiset/clear.pass.cpp index 61ca847e7c4a..57dbb8b1faaa 100644 --- a/test/std/containers/unord/unord.multiset/clear.pass.cpp +++ b/test/std/containers/unord/unord.multiset/clear.pass.cpp @@ -38,7 +38,7 @@ int main() c.clear(); assert(c.size() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/count.pass.cpp b/test/std/containers/unord/unord.multiset/count.pass.cpp index e548324d9545..9f61845fa69c 100644 --- a/test/std/containers/unord/unord.multiset/count.pass.cpp +++ b/test/std/containers/unord/unord.multiset/count.pass.cpp @@ -43,7 +43,7 @@ int main() assert(c.count(50) == 3); assert(c.count(5) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/db_iterators_7.pass.cpp b/test/std/containers/unord/unord.multiset/db_iterators_7.pass.cpp index c8ef2fbca163..91f083b241d6 100644 --- a/test/std/containers/unord/unord.multiset/db_iterators_7.pass.cpp +++ b/test/std/containers/unord/unord.multiset/db_iterators_7.pass.cpp @@ -35,7 +35,7 @@ int main() ++i; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::unordered_multiset<T, min_allocator<T>> C; diff --git a/test/std/containers/unord/unord.multiset/db_iterators_8.pass.cpp b/test/std/containers/unord/unord.multiset/db_iterators_8.pass.cpp index eef799787947..3d78ed4c022f 100644 --- a/test/std/containers/unord/unord.multiset/db_iterators_8.pass.cpp +++ b/test/std/containers/unord/unord.multiset/db_iterators_8.pass.cpp @@ -33,7 +33,7 @@ int main() T j = *i; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::unordered_multiset<T, min_allocator<T>> C; diff --git a/test/std/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp b/test/std/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp index c1de95cace71..cf8874803cb7 100644 --- a/test/std/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp +++ b/test/std/containers/unord/unord.multiset/db_local_iterators_7.pass.cpp @@ -34,7 +34,7 @@ int main() ++i; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::unordered_multiset<T, min_allocator<T>> C; diff --git a/test/std/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp b/test/std/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp index 962b85298ae1..46e5ba7d5f84 100644 --- a/test/std/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp +++ b/test/std/containers/unord/unord.multiset/db_local_iterators_8.pass.cpp @@ -33,7 +33,7 @@ int main() T j = *i; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::unordered_multiset<T, min_allocator<T>> C; diff --git a/test/std/containers/unord/unord.multiset/emplace.pass.cpp b/test/std/containers/unord/unord.multiset/emplace.pass.cpp index 13787d9b4037..d8d9e9bc5695 100644 --- a/test/std/containers/unord/unord.multiset/emplace.pass.cpp +++ b/test/std/containers/unord/unord.multiset/emplace.pass.cpp @@ -41,7 +41,7 @@ int main() assert(c.size() == 3); assert(*r == Emplaceable(5, 6)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<Emplaceable, std::hash<Emplaceable>, std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C; diff --git a/test/std/containers/unord/unord.multiset/emplace_hint.pass.cpp b/test/std/containers/unord/unord.multiset/emplace_hint.pass.cpp index 8885cc03cf03..3756476dc8fc 100644 --- a/test/std/containers/unord/unord.multiset/emplace_hint.pass.cpp +++ b/test/std/containers/unord/unord.multiset/emplace_hint.pass.cpp @@ -46,7 +46,7 @@ int main() assert(c.size() == 3); assert(*r == Emplaceable(5, 6)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<Emplaceable, std::hash<Emplaceable>, std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C; diff --git a/test/std/containers/unord/unord.multiset/eq.pass.cpp b/test/std/containers/unord/unord.multiset/eq.pass.cpp index bbedbc905a4b..9c59d0cf5e9f 100644 --- a/test/std/containers/unord/unord.multiset/eq.pass.cpp +++ b/test/std/containers/unord/unord.multiset/eq.pass.cpp @@ -99,7 +99,7 @@ int main() assert( (c1 == c2)); assert(!(c1 != c2)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/equal_range_const.pass.cpp b/test/std/containers/unord/unord.multiset/equal_range_const.pass.cpp index a0aaac2bd868..e89410e61633 100644 --- a/test/std/containers/unord/unord.multiset/equal_range_const.pass.cpp +++ b/test/std/containers/unord/unord.multiset/equal_range_const.pass.cpp @@ -53,7 +53,7 @@ int main() ++r.first; assert(*r.first == 50); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/equal_range_non_const.pass.cpp b/test/std/containers/unord/unord.multiset/equal_range_non_const.pass.cpp index 73d44f7a56b7..a9373cec6517 100644 --- a/test/std/containers/unord/unord.multiset/equal_range_non_const.pass.cpp +++ b/test/std/containers/unord/unord.multiset/equal_range_non_const.pass.cpp @@ -53,7 +53,7 @@ int main() ++r.first; assert(*r.first == 50); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/erase_const_iter.pass.cpp b/test/std/containers/unord/unord.multiset/erase_const_iter.pass.cpp index d3be2b6d6365..117e8e68efab 100644 --- a/test/std/containers/unord/unord.multiset/erase_const_iter.pass.cpp +++ b/test/std/containers/unord/unord.multiset/erase_const_iter.pass.cpp @@ -52,7 +52,7 @@ int main() assert(c.count(3) == 1); assert(c.count(4) == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; @@ -76,7 +76,7 @@ int main() assert(c.count(4) == 1); } #endif -#if __cplusplus >= 201402L +#if TEST_STD_VER >= 14 { // This is LWG #2059 typedef TemplateConstructor T; diff --git a/test/std/containers/unord/unord.multiset/erase_key.pass.cpp b/test/std/containers/unord/unord.multiset/erase_key.pass.cpp index 7c243973f163..e8ff71d0316b 100644 --- a/test/std/containers/unord/unord.multiset/erase_key.pass.cpp +++ b/test/std/containers/unord/unord.multiset/erase_key.pass.cpp @@ -21,12 +21,12 @@ #include "min_allocator.h" -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 template <typename Unordered> bool only_deletions ( const Unordered &whole, const Unordered &part ) { typename Unordered::const_iterator w = whole.begin(); typename Unordered::const_iterator p = part.begin(); - + while ( w != whole.end () && p != part.end()) { if ( *w == *p ) p++; @@ -95,7 +95,7 @@ int main() assert(c.erase(3) == 0); assert(c.size() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; @@ -160,7 +160,7 @@ int main() m.insert(i); m.insert(i); m2.insert(i); m2.insert(i); } - + C::iterator i = m2.begin(); int ctr = 0; while (i != m2.end()) { diff --git a/test/std/containers/unord/unord.multiset/erase_range.pass.cpp b/test/std/containers/unord/unord.multiset/erase_range.pass.cpp index baac08eddc1e..a4f703df8506 100644 --- a/test/std/containers/unord/unord.multiset/erase_range.pass.cpp +++ b/test/std/containers/unord/unord.multiset/erase_range.pass.cpp @@ -55,7 +55,7 @@ int main() assert(c.size() == 0); assert(k == c.end()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/find_const.pass.cpp b/test/std/containers/unord/unord.multiset/find_const.pass.cpp index 5caaf207aaf2..505266b1f022 100644 --- a/test/std/containers/unord/unord.multiset/find_const.pass.cpp +++ b/test/std/containers/unord/unord.multiset/find_const.pass.cpp @@ -42,7 +42,7 @@ int main() i = c.find(5); assert(i == c.cend()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/find_non_const.pass.cpp b/test/std/containers/unord/unord.multiset/find_non_const.pass.cpp index 030487863f98..32ee79aa7554 100644 --- a/test/std/containers/unord/unord.multiset/find_non_const.pass.cpp +++ b/test/std/containers/unord/unord.multiset/find_non_const.pass.cpp @@ -42,7 +42,7 @@ int main() i = c.find(5); assert(i == c.cend()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/incomplete.pass.cpp b/test/std/containers/unord/unord.multiset/incomplete.pass.cpp new file mode 100644 index 000000000000..f6d8dc17c5a2 --- /dev/null +++ b/test/std/containers/unord/unord.multiset/incomplete.pass.cpp @@ -0,0 +1,38 @@ + + +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <unordered_set> + +// Check that std::unordered_multiset and it's iterators can be instantiated with an incomplete +// type. + +#include <unordered_set> + +template <class Tp> +struct MyHash { + MyHash() {} + std::size_t operator()(Tp const&) const {return 42;} +}; + +struct A { + typedef std::unordered_multiset<A, MyHash<A> > Map; + Map m; + Map::iterator it; + Map::const_iterator cit; + Map::local_iterator lit; + Map::const_local_iterator clit; +}; + +inline bool operator==(A const& L, A const& R) { return &L == &R; } + +int main() { + A a; +} diff --git a/test/std/containers/unord/unord.set/version.pass.cpp b/test/std/containers/unord/unord.multiset/insert_allocator_requirements.pass.cpp index d651ebdfc456..ad7bc043a5b3 100644 --- a/test/std/containers/unord/unord.set/version.pass.cpp +++ b/test/std/containers/unord/unord.multiset/insert_allocator_requirements.pass.cpp @@ -9,12 +9,17 @@ // <unordered_set> -#include <unordered_set> +// class unordered_multiset + +// insert(...) -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif +// UNSUPPORTED: c++98, c++03 + +#include <unordered_set> +#include "container_test_types.h" +#include "../../set_allocator_requirement_test_templates.h" int main() { + testMultisetInsert<TCT::unordered_multiset<> >(); } diff --git a/test/std/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp b/test/std/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp index 0051e497fd7a..946858ea53dc 100644 --- a/test/std/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp +++ b/test/std/containers/unord/unord.multiset/insert_const_lvalue.pass.cpp @@ -43,7 +43,7 @@ int main() assert(c.size() == 4); assert(*r == 5.5); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<double, std::hash<double>, std::equal_to<double>, min_allocator<double>> C; diff --git a/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp b/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp index 25b4bc1aa04a..a6ab26659b55 100644 --- a/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp +++ b/test/std/containers/unord/unord.multiset/insert_hint_const_lvalue.pass.cpp @@ -48,7 +48,7 @@ int main() assert(c.size() == 4); assert(*r == 5.5); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<double, std::hash<double>, std::equal_to<double>, min_allocator<double>> C; diff --git a/test/std/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp b/test/std/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp index 481ec80231c9..f5026e102c42 100644 --- a/test/std/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp +++ b/test/std/containers/unord/unord.multiset/insert_hint_rvalue.pass.cpp @@ -73,7 +73,7 @@ int main() assert(*r == 5); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<double, std::hash<double>, std::equal_to<double>, min_allocator<double>> C; diff --git a/test/std/containers/unord/unord.multiset/insert_init.pass.cpp b/test/std/containers/unord/unord.multiset/insert_init.pass.cpp index 6941d86f6197..9010cac99caf 100644 --- a/test/std/containers/unord/unord.multiset/insert_init.pass.cpp +++ b/test/std/containers/unord/unord.multiset/insert_init.pass.cpp @@ -44,7 +44,7 @@ int main() assert(c.count(3) == 1); assert(c.count(4) == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/insert_range.pass.cpp b/test/std/containers/unord/unord.multiset/insert_range.pass.cpp index 41c9d8136feb..3d36ff9d4ce1 100644 --- a/test/std/containers/unord/unord.multiset/insert_range.pass.cpp +++ b/test/std/containers/unord/unord.multiset/insert_range.pass.cpp @@ -44,7 +44,7 @@ int main() assert(c.count(3) == 1); assert(c.count(4) == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/insert_rvalue.pass.cpp b/test/std/containers/unord/unord.multiset/insert_rvalue.pass.cpp index 2718324b4d08..04f9e34164ab 100644 --- a/test/std/containers/unord/unord.multiset/insert_rvalue.pass.cpp +++ b/test/std/containers/unord/unord.multiset/insert_rvalue.pass.cpp @@ -67,7 +67,7 @@ int main() assert(*r == 5); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<double, std::hash<double>, std::equal_to<double>, min_allocator<double>> C; diff --git a/test/std/containers/unord/unord.multiset/iterators.pass.cpp b/test/std/containers/unord/unord.multiset/iterators.pass.cpp index be95b44517fe..bf42740c23fb 100644 --- a/test/std/containers/unord/unord.multiset/iterators.pass.cpp +++ b/test/std/containers/unord/unord.multiset/iterators.pass.cpp @@ -65,7 +65,7 @@ int main() assert(std::distance(c.cbegin(), c.cend()) == c.size()); C::const_iterator i; } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/load_factor.pass.cpp b/test/std/containers/unord/unord.multiset/load_factor.pass.cpp index 2a5724b3d270..fad1c182e6b7 100644 --- a/test/std/containers/unord/unord.multiset/load_factor.pass.cpp +++ b/test/std/containers/unord/unord.multiset/load_factor.pass.cpp @@ -47,7 +47,7 @@ int main() const C c; assert(c.load_factor() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/local_iterators.pass.cpp b/test/std/containers/unord/unord.multiset/local_iterators.pass.cpp index 3471707e42a1..8ba9f0f9579d 100644 --- a/test/std/containers/unord/unord.multiset/local_iterators.pass.cpp +++ b/test/std/containers/unord/unord.multiset/local_iterators.pass.cpp @@ -259,7 +259,7 @@ int main() j = c.cend(b); assert(std::distance(i, j) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/max_bucket_count.pass.cpp b/test/std/containers/unord/unord.multiset/max_bucket_count.pass.cpp index 619a8cf1266f..510ba5fe4da0 100644 --- a/test/std/containers/unord/unord.multiset/max_bucket_count.pass.cpp +++ b/test/std/containers/unord/unord.multiset/max_bucket_count.pass.cpp @@ -27,7 +27,7 @@ int main() const C c; assert(c.max_bucket_count() > 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp b/test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp index 08f52bb70840..00fe962327f8 100644 --- a/test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp +++ b/test/std/containers/unord/unord.multiset/max_load_factor.pass.cpp @@ -41,7 +41,7 @@ int main() c.max_load_factor(2.5); assert(c.max_load_factor() == 2.5); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/max_size.pass.cpp b/test/std/containers/unord/unord.multiset/max_size.pass.cpp index a5d0b5538bce..b26ad73fed2b 100644 --- a/test/std/containers/unord/unord.multiset/max_size.pass.cpp +++ b/test/std/containers/unord/unord.multiset/max_size.pass.cpp @@ -26,7 +26,7 @@ int main() std::unordered_multiset<int> u; assert(u.max_size() > 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> u; diff --git a/test/std/containers/unord/unord.multiset/rehash.pass.cpp b/test/std/containers/unord/unord.multiset/rehash.pass.cpp index 5c7c6aa8aad3..3ad16a6bcbfe 100644 --- a/test/std/containers/unord/unord.multiset/rehash.pass.cpp +++ b/test/std/containers/unord/unord.multiset/rehash.pass.cpp @@ -67,7 +67,7 @@ int main() assert(c.bucket_count() == 31); test(c); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/reserve.pass.cpp b/test/std/containers/unord/unord.multiset/reserve.pass.cpp index 1d393a09cde2..52d51011fe36 100644 --- a/test/std/containers/unord/unord.multiset/reserve.pass.cpp +++ b/test/std/containers/unord/unord.multiset/reserve.pass.cpp @@ -73,7 +73,7 @@ int main() assert(c.bucket_count() >= 16); test(c); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.multiset/swap_member.pass.cpp b/test/std/containers/unord/unord.multiset/swap_member.pass.cpp index 275ff4094e81..bc3314c867eb 100644 --- a/test/std/containers/unord/unord.multiset/swap_member.pass.cpp +++ b/test/std/containers/unord/unord.multiset/swap_member.pass.cpp @@ -386,7 +386,7 @@ int main() assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); assert(c2.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef test_hash<std::hash<int> > Hash; typedef test_compare<std::equal_to<int> > Compare; diff --git a/test/std/containers/unord/unord.multiset/types.pass.cpp b/test/std/containers/unord/unord.multiset/types.pass.cpp index 5222222d8197..ee5c2c38ac0c 100644 --- a/test/std/containers/unord/unord.multiset/types.pass.cpp +++ b/test/std/containers/unord/unord.multiset/types.pass.cpp @@ -48,7 +48,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::unordered_multiset<short, std::hash<short>, std::equal_to<short>, min_allocator<short>> C; diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp index ccd21a58b22c..8d020a52ac04 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/allocator.pass.cpp @@ -43,7 +43,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp index 2042f69fd772..f219073cffcb 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_copy.pass.cpp @@ -151,7 +151,7 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef min_allocator<int> A; typedef std::unordered_multiset<int, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp index 4eaf2c5779f3..2835cd444c30 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_init.pass.cpp @@ -59,7 +59,7 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef min_allocator<int> A; typedef std::unordered_multiset<int, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp index 4b0e52c5930c..52d08f3e2293 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/assign_move.pass.cpp @@ -170,7 +170,7 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef test_allocator<int> A; typedef std::unordered_multiset<int, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/compare_copy_constructible.fail.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/compare_copy_constructible.fail.cpp new file mode 100644 index 000000000000..b38316c37689 --- /dev/null +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/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. +// +//===----------------------------------------------------------------------===// + +// <unordered_set> + +// Check that std::unordered_set fails to instantiate if the comparison predicate is +// not copy-constructible. This is LWG issue 2436 + +#include <unordered_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::unordered_multiset<int, std::hash<int>, Comp<int> > m; +} diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp index a91ee1dae071..e6042b0d9123 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy.pass.cpp @@ -121,7 +121,7 @@ int main() assert(c.max_load_factor() == 1); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp index 32c876d32878..5e24f7257252 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/copy_alloc.pass.cpp @@ -73,7 +73,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp index 737ae2dae793..e741f3208dac 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default.pass.cpp @@ -43,7 +43,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp index 391609fd144a..fba024aed00e 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/default_noexcept.pass.cpp @@ -17,9 +17,12 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <unordered_set> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" #include "../../../test_hash.h" @@ -30,6 +33,7 @@ struct some_comp typedef T value_type; some_comp(); some_comp(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; template <class T> @@ -42,15 +46,14 @@ struct some_hash int main() { -#if __has_feature(cxx_noexcept) { typedef std::unordered_multiset<MoveOnly> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::unordered_multiset<MoveOnly, std::hash<MoveOnly>, std::equal_to<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::unordered_multiset<MoveOnly, std::hash<MoveOnly>, @@ -66,5 +69,4 @@ int main() some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp index a549288afc14..733484510ef1 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/dtor_noexcept.pass.cpp @@ -11,19 +11,20 @@ // ~unordered_multiset() // implied noexcept; +// UNSUPPORTED: c++98, c++03 + #include <unordered_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; } }; template <class T> @@ -35,11 +36,8 @@ struct some_hash ~some_hash() noexcept(false); }; -#endif - int main() { -#if __has_feature(cxx_noexcept) { typedef std::unordered_multiset<MoveOnly> C; static_assert(std::is_nothrow_destructible<C>::value, ""); @@ -63,5 +61,4 @@ int main() some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_destructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/hash_copy_constructible.fail.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/hash_copy_constructible.fail.cpp new file mode 100644 index 000000000000..a43f94ca2af3 --- /dev/null +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/hash_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. +// +//===----------------------------------------------------------------------===// + +// <unordered_set> + +// Check that std::unordered_multiset fails to instantiate if the hash function is +// not copy-constructible. This is mentioned in LWG issue 2436 + +#include <unordered_set> + +template <class T> +struct Hash { + std::size_t operator () (const T& lhs) const { return 0; } + + Hash () {} +private: + Hash (const Hash &); // declared but not defined + }; + + +int main() { + std::unordered_multiset<int, Hash<int> > m; +} diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp index 416c28cf83db..53a9003b0173 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init.pass.cpp @@ -57,7 +57,7 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp index ad42d76db9ee..e5934acc8e7c 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size.pass.cpp @@ -60,7 +60,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp index 7cc50fa30067..86253214af9c 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash.pass.cpp @@ -62,7 +62,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp index 18d3c8288cd2..47469c0c5b9b 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal.pass.cpp @@ -63,7 +63,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp index 92d9d86040bb..d72ee6f33f50 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/init_size_hash_equal_allocator.pass.cpp @@ -64,7 +64,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp index 687f2654f86c..defd90f408b0 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move.pass.cpp @@ -103,7 +103,7 @@ int main() assert(c0.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp index c03c605f40ce..45b4c8b4f5d5 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_alloc.pass.cpp @@ -118,7 +118,7 @@ int main() assert(c0.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int P; typedef min_allocator<int> A; diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp index 2f86f018d9fe..fbd6df14c052 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_assign_noexcept.pass.cpp @@ -17,6 +17,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <unordered_set> #include <cassert> @@ -28,6 +30,7 @@ struct some_comp { typedef T value_type; some_comp& operator=(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; template <class T> @@ -41,7 +44,6 @@ struct some_hash int main() { -#if __has_feature(cxx_noexcept) { typedef std::unordered_multiset<MoveOnly> C; static_assert(std::is_nothrow_move_assignable<C>::value, ""); @@ -65,5 +67,4 @@ int main() some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } -#endif } diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp index 8a4c3c945364..e84ffb7b2fde 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/move_noexcept.pass.cpp @@ -15,6 +15,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <unordered_set> #include <cassert> @@ -26,6 +28,7 @@ struct some_comp { typedef T value_type; some_comp(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; template <class T> @@ -38,7 +41,6 @@ struct some_hash int main() { -#if __has_feature(cxx_noexcept) { typedef std::unordered_multiset<MoveOnly> C; static_assert(std::is_nothrow_move_constructible<C>::value, ""); @@ -62,5 +64,4 @@ int main() some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp index cd2bb1e7bbcd..12679ef3e13e 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range.pass.cpp @@ -60,7 +60,7 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp index f2d0db932bd7..c9454cf630db 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size.pass.cpp @@ -63,7 +63,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp index dc40b361d1f3..5ff61575d994 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash.pass.cpp @@ -65,7 +65,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp index c316b7809d53..ecf3176e90a4 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal.pass.cpp @@ -66,7 +66,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp index ab76248c326c..18a092c83f6a 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/range_size_hash_equal_allocator.pass.cpp @@ -68,7 +68,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp index e55db7ca2aaf..215b31fef65f 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.fail.cpp @@ -43,7 +43,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp index 35bfbe331b41..38211f958c43 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size.pass.cpp @@ -43,7 +43,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp index 0171ea64ebb1..baeabd1b2d08 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash.pass.cpp @@ -45,7 +45,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp index 785cdf246368..380f36df7bf2 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal.pass.cpp @@ -46,7 +46,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp index 50dd3c95ee52..149d045e07a9 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.cnstr/size_hash_equal_allocator.pass.cpp @@ -47,7 +47,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_multiset<NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp index 63642fcd7cca..df9f18b147e3 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_noexcept.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <unordered_set> // void swap(unordered_multiset& c) @@ -26,6 +28,7 @@ #include <unordered_set> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -33,20 +36,20 @@ template <class T> struct some_comp { typedef T value_type; - + some_comp() {} some_comp(const some_comp&) {} + 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 @@ -60,6 +63,7 @@ struct some_hash typedef T value_type; some_hash() {} some_hash(const some_hash&); + std::size_t operator()(const T&) const { return 0; } }; template <class T> @@ -68,6 +72,7 @@ struct some_hash2 typedef T value_type; some_hash2() {} some_hash2(const some_hash2&); + std::size_t operator()(const T&) const { return 0; } }; #if TEST_STD_VER >= 14 @@ -79,7 +84,7 @@ template <class T> struct some_alloc { typedef T value_type; - + some_alloc() {} some_alloc(const some_alloc&); void deallocate(void*, unsigned) {} @@ -91,7 +96,7 @@ template <class T> struct some_alloc2 { typedef T value_type; - + some_alloc2() {} some_alloc2(const some_alloc2&); void deallocate(void*, unsigned) {} @@ -104,7 +109,7 @@ template <class T> struct some_alloc3 { typedef T value_type; - + some_alloc3() {} some_alloc3(const some_alloc3&); void deallocate(void*, unsigned) {} @@ -115,7 +120,6 @@ struct some_alloc3 int main() { -#if __has_feature(cxx_noexcept) { typedef std::unordered_multiset<MoveOnly> C; C c1, c2; @@ -193,6 +197,4 @@ int main() static_assert( noexcept(swap(c1, c2)), ""); } #endif - -#endif } diff --git a/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp b/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp index 624b81c5eb3e..4b1c129508e1 100644 --- a/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp +++ b/test/std/containers/unord/unord.multiset/unord.multiset.swap/swap_non_member.pass.cpp @@ -386,7 +386,7 @@ int main() assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); assert(c2.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef test_hash<std::hash<int> > Hash; typedef test_compare<std::equal_to<int> > Compare; diff --git a/test/std/containers/unord/unord.set/bucket.pass.cpp b/test/std/containers/unord/unord.set/bucket.pass.cpp index 0dae664e0b23..9b704ccee0c0 100644 --- a/test/std/containers/unord/unord.set/bucket.pass.cpp +++ b/test/std/containers/unord/unord.set/bucket.pass.cpp @@ -44,7 +44,7 @@ int main() for (size_t i = 0; i < 13; ++i) assert(c.bucket(i) == i % bc); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; typedef int P; diff --git a/test/std/containers/unord/unord.set/bucket_count.pass.cpp b/test/std/containers/unord/unord.set/bucket_count.pass.cpp index caaa5a6011a9..e35e43615dd3 100644 --- a/test/std/containers/unord/unord.set/bucket_count.pass.cpp +++ b/test/std/containers/unord/unord.set/bucket_count.pass.cpp @@ -47,7 +47,7 @@ int main() const C c(std::begin(a), std::end(a)); assert(c.bucket_count() >= 11); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; typedef C::const_iterator I; diff --git a/test/std/containers/unord/unord.set/bucket_size.pass.cpp b/test/std/containers/unord/unord.set/bucket_size.pass.cpp index 628d55737a82..2ae618c85e5b 100644 --- a/test/std/containers/unord/unord.set/bucket_size.pass.cpp +++ b/test/std/containers/unord/unord.set/bucket_size.pass.cpp @@ -46,7 +46,7 @@ int main() assert(c.bucket_size(3) == 1); assert(c.bucket_size(4) == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; typedef int P; diff --git a/test/std/containers/unord/unord.set/clear.pass.cpp b/test/std/containers/unord/unord.set/clear.pass.cpp index 6da15308508c..8ebf748eb8da 100644 --- a/test/std/containers/unord/unord.set/clear.pass.cpp +++ b/test/std/containers/unord/unord.set/clear.pass.cpp @@ -38,7 +38,7 @@ int main() c.clear(); assert(c.size() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; typedef int P; diff --git a/test/std/containers/unord/unord.set/count.pass.cpp b/test/std/containers/unord/unord.set/count.pass.cpp index 83bb8aaa2be0..18cac7cf9b0d 100644 --- a/test/std/containers/unord/unord.set/count.pass.cpp +++ b/test/std/containers/unord/unord.set/count.pass.cpp @@ -43,7 +43,7 @@ int main() assert(c.count(50) == 1); assert(c.count(5) == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; typedef int P; diff --git a/test/std/containers/unord/unord.set/db_iterators_7.pass.cpp b/test/std/containers/unord/unord.set/db_iterators_7.pass.cpp index 80b1a49c5758..647e30b8089c 100644 --- a/test/std/containers/unord/unord.set/db_iterators_7.pass.cpp +++ b/test/std/containers/unord/unord.set/db_iterators_7.pass.cpp @@ -35,7 +35,7 @@ int main() ++i; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::unordered_set<T, min_allocator<T>> C; diff --git a/test/std/containers/unord/unord.set/db_iterators_8.pass.cpp b/test/std/containers/unord/unord.set/db_iterators_8.pass.cpp index 8b266bbf664f..4c303194c20e 100644 --- a/test/std/containers/unord/unord.set/db_iterators_8.pass.cpp +++ b/test/std/containers/unord/unord.set/db_iterators_8.pass.cpp @@ -33,7 +33,7 @@ int main() T j = *i; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::unordered_set<T, min_allocator<T>> C; diff --git a/test/std/containers/unord/unord.set/db_local_iterators_7.pass.cpp b/test/std/containers/unord/unord.set/db_local_iterators_7.pass.cpp index b9fcb8c4ae0c..9dbd43d2f7a8 100644 --- a/test/std/containers/unord/unord.set/db_local_iterators_7.pass.cpp +++ b/test/std/containers/unord/unord.set/db_local_iterators_7.pass.cpp @@ -34,7 +34,7 @@ int main() ++i; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::unordered_set<T, min_allocator<T>> C; diff --git a/test/std/containers/unord/unord.set/db_local_iterators_8.pass.cpp b/test/std/containers/unord/unord.set/db_local_iterators_8.pass.cpp index 74d131b19abe..1212321fe1d1 100644 --- a/test/std/containers/unord/unord.set/db_local_iterators_8.pass.cpp +++ b/test/std/containers/unord/unord.set/db_local_iterators_8.pass.cpp @@ -33,7 +33,7 @@ int main() T j = *i; assert(false); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int T; typedef std::unordered_set<T, min_allocator<T>> C; diff --git a/test/std/containers/unord/unord.set/emplace.pass.cpp b/test/std/containers/unord/unord.set/emplace.pass.cpp index d105e7ac0f4e..19af8065819c 100644 --- a/test/std/containers/unord/unord.set/emplace.pass.cpp +++ b/test/std/containers/unord/unord.set/emplace.pass.cpp @@ -44,7 +44,7 @@ int main() assert(*r.first == Emplaceable(5, 6)); assert(!r.second); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<Emplaceable, std::hash<Emplaceable>, std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C; diff --git a/test/std/containers/unord/unord.set/emplace_hint.pass.cpp b/test/std/containers/unord/unord.set/emplace_hint.pass.cpp index 50b0035165d2..97f3591d012b 100644 --- a/test/std/containers/unord/unord.set/emplace_hint.pass.cpp +++ b/test/std/containers/unord/unord.set/emplace_hint.pass.cpp @@ -46,7 +46,7 @@ int main() assert(c.size() == 2); assert(*r == Emplaceable(5, 6)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<Emplaceable, std::hash<Emplaceable>, std::equal_to<Emplaceable>, min_allocator<Emplaceable>> C; diff --git a/test/std/containers/unord/unord.set/eq.pass.cpp b/test/std/containers/unord/unord.set/eq.pass.cpp index 54a9c2eced34..8ff4ac5df37f 100644 --- a/test/std/containers/unord/unord.set/eq.pass.cpp +++ b/test/std/containers/unord/unord.set/eq.pass.cpp @@ -90,7 +90,7 @@ int main() assert( (c1 == c2)); assert(!(c1 != c2)); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; typedef int P; diff --git a/test/std/containers/unord/unord.set/equal_range_const.pass.cpp b/test/std/containers/unord/unord.set/equal_range_const.pass.cpp index 4168903e0200..9fa4129c330a 100644 --- a/test/std/containers/unord/unord.set/equal_range_const.pass.cpp +++ b/test/std/containers/unord/unord.set/equal_range_const.pass.cpp @@ -49,7 +49,7 @@ int main() assert(std::distance(r.first, r.second) == 1); assert(*r.first == 50); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; typedef C::const_iterator I; diff --git a/test/std/containers/unord/unord.set/equal_range_non_const.pass.cpp b/test/std/containers/unord/unord.set/equal_range_non_const.pass.cpp index 5a55083ba8ab..c6a42aceaaf2 100644 --- a/test/std/containers/unord/unord.set/equal_range_non_const.pass.cpp +++ b/test/std/containers/unord/unord.set/equal_range_non_const.pass.cpp @@ -49,7 +49,7 @@ int main() assert(std::distance(r.first, r.second) == 1); assert(*r.first == 50); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; typedef C::iterator I; diff --git a/test/std/containers/unord/unord.set/erase_const_iter.pass.cpp b/test/std/containers/unord/unord.set/erase_const_iter.pass.cpp index 4110953badb6..c78eb138fd90 100644 --- a/test/std/containers/unord/unord.set/erase_const_iter.pass.cpp +++ b/test/std/containers/unord/unord.set/erase_const_iter.pass.cpp @@ -51,7 +51,7 @@ int main() assert(c.count(3) == 1); assert(c.count(4) == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; typedef int P; @@ -73,7 +73,7 @@ int main() assert(c.count(4) == 1); } #endif -#if __cplusplus >= 201402L +#if TEST_STD_VER >= 14 { // This is LWG #2059 typedef TemplateConstructor T; diff --git a/test/std/containers/unord/unord.set/erase_key.pass.cpp b/test/std/containers/unord/unord.set/erase_key.pass.cpp index ca165083b023..ea0323ba2dac 100644 --- a/test/std/containers/unord/unord.set/erase_key.pass.cpp +++ b/test/std/containers/unord/unord.set/erase_key.pass.cpp @@ -21,12 +21,12 @@ #include "min_allocator.h" -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 template <typename Unordered> bool only_deletions ( const Unordered &whole, const Unordered &part ) { typename Unordered::const_iterator w = whole.begin(); typename Unordered::const_iterator p = part.begin(); - + while ( w != whole.end () && p != part.end()) { if ( *w == *p ) p++; @@ -95,7 +95,7 @@ int main() assert(c.erase(3) == 0); assert(c.size() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; typedef int P; @@ -159,7 +159,7 @@ int main() m.insert(i); m2.insert(i); } - + C::iterator i = m2.begin(); int ctr = 0; while (i != m2.end()) { diff --git a/test/std/containers/unord/unord.set/erase_range.pass.cpp b/test/std/containers/unord/unord.set/erase_range.pass.cpp index a8a900551c7b..4e49a86ef836 100644 --- a/test/std/containers/unord/unord.set/erase_range.pass.cpp +++ b/test/std/containers/unord/unord.set/erase_range.pass.cpp @@ -55,7 +55,7 @@ int main() assert(c.size() == 0); assert(k == c.end()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; typedef int P; diff --git a/test/std/containers/unord/unord.set/find_const.pass.cpp b/test/std/containers/unord/unord.set/find_const.pass.cpp index e2238e5665f9..bd4542c876bf 100644 --- a/test/std/containers/unord/unord.set/find_const.pass.cpp +++ b/test/std/containers/unord/unord.set/find_const.pass.cpp @@ -42,7 +42,7 @@ int main() i = c.find(5); assert(i == c.cend()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; typedef int P; diff --git a/test/std/containers/unord/unord.set/find_non_const.pass.cpp b/test/std/containers/unord/unord.set/find_non_const.pass.cpp index 8afe32abd72f..4c81fc60a393 100644 --- a/test/std/containers/unord/unord.set/find_non_const.pass.cpp +++ b/test/std/containers/unord/unord.set/find_non_const.pass.cpp @@ -42,7 +42,7 @@ int main() i = c.find(5); assert(i == c.cend()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; typedef int P; diff --git a/test/std/containers/unord/unord.set/incomplete.pass.cpp b/test/std/containers/unord/unord.set/incomplete.pass.cpp new file mode 100644 index 000000000000..c970c1de5531 --- /dev/null +++ b/test/std/containers/unord/unord.set/incomplete.pass.cpp @@ -0,0 +1,38 @@ + + +//===----------------------------------------------------------------------===// +// +// 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. +// +//===----------------------------------------------------------------------===// + +// <unordered_set> + +// Check that std::unordered_set and it's iterators can be instantiated with an incomplete +// type. + +#include <unordered_set> + +template <class Tp> +struct MyHash { + MyHash() {} + std::size_t operator()(Tp const&) const {return 42;} +}; + +struct A { + typedef std::unordered_set<A, MyHash<A> > Map; + Map m; + Map::iterator it; + Map::const_iterator cit; + Map::local_iterator lit; + Map::const_local_iterator clit; +}; + +inline bool operator==(A const& L, A const& R) { return &L == &R; } + +int main() { + A a; +} diff --git a/test/std/containers/container.adaptors/stack/version.pass.cpp b/test/std/containers/unord/unord.set/insert_and_emplace_allocator_requirements.pass.cpp index 339d0f4dda8f..e85e94538e74 100644 --- a/test/std/containers/container.adaptors/stack/version.pass.cpp +++ b/test/std/containers/unord/unord.set/insert_and_emplace_allocator_requirements.pass.cpp @@ -7,14 +7,23 @@ // //===----------------------------------------------------------------------===// -// <stack> +// <unordered_set> -#include <stack> +// class unordered_set + +// insert(...) +// emplace(...) + +// UNSUPPORTED: c++98, c++03 + +#include <unordered_set> + +#include "container_test_types.h" +#include "../../set_allocator_requirement_test_templates.h" -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif int main() { + testSetInsert<TCT::unordered_set<> >(); + testSetEmplace<TCT::unordered_set<> >(); } diff --git a/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp b/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp index 321e9054af6c..fe45b98a33a6 100644 --- a/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp +++ b/test/std/containers/unord/unord.set/insert_const_lvalue.pass.cpp @@ -47,7 +47,7 @@ int main() assert(*r.first == 5.5); assert(r.second); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<double, std::hash<double>, std::equal_to<double>, min_allocator<double>> C; diff --git a/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp b/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp index 1393f5420111..d3bbecc95ad7 100644 --- a/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp +++ b/test/std/containers/unord/unord.set/insert_hint_const_lvalue.pass.cpp @@ -48,7 +48,7 @@ int main() assert(c.size() == 3); assert(*r == 5.5); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<double, std::hash<double>, std::equal_to<double>, min_allocator<double>> C; diff --git a/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp b/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp index 3f04dbb89984..da94bc55382f 100644 --- a/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp +++ b/test/std/containers/unord/unord.set/insert_hint_rvalue.pass.cpp @@ -73,7 +73,7 @@ int main() assert(*r == 5); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<double, std::hash<double>, std::equal_to<double>, min_allocator<double>> C; diff --git a/test/std/containers/unord/unord.set/insert_init.pass.cpp b/test/std/containers/unord/unord.set/insert_init.pass.cpp index 2d8eafba4891..27b7290eb341 100644 --- a/test/std/containers/unord/unord.set/insert_init.pass.cpp +++ b/test/std/containers/unord/unord.set/insert_init.pass.cpp @@ -44,7 +44,7 @@ int main() assert(c.count(3) == 1); assert(c.count(4) == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.set/insert_range.pass.cpp b/test/std/containers/unord/unord.set/insert_range.pass.cpp index 72a83abf74e9..41b2c0e1431b 100644 --- a/test/std/containers/unord/unord.set/insert_range.pass.cpp +++ b/test/std/containers/unord/unord.set/insert_range.pass.cpp @@ -44,7 +44,7 @@ int main() assert(c.count(3) == 1); assert(c.count(4) == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.set/insert_rvalue.pass.cpp b/test/std/containers/unord/unord.set/insert_rvalue.pass.cpp index e043579bf971..5d12f225cc6a 100644 --- a/test/std/containers/unord/unord.set/insert_rvalue.pass.cpp +++ b/test/std/containers/unord/unord.set/insert_rvalue.pass.cpp @@ -75,7 +75,7 @@ int main() assert(r.second); } #endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<double, std::hash<double>, std::equal_to<double>, min_allocator<double>> C; diff --git a/test/std/containers/unord/unord.set/iterators.pass.cpp b/test/std/containers/unord/unord.set/iterators.pass.cpp index d3a45801f162..494411854977 100644 --- a/test/std/containers/unord/unord.set/iterators.pass.cpp +++ b/test/std/containers/unord/unord.set/iterators.pass.cpp @@ -65,7 +65,7 @@ int main() assert(std::distance(c.cbegin(), c.cend()) == c.size()); C::const_iterator i; } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.set/load_factor.pass.cpp b/test/std/containers/unord/unord.set/load_factor.pass.cpp index 3e56442d384c..a342d472a3d5 100644 --- a/test/std/containers/unord/unord.set/load_factor.pass.cpp +++ b/test/std/containers/unord/unord.set/load_factor.pass.cpp @@ -47,7 +47,7 @@ int main() const C c; assert(c.load_factor() == 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.set/local_iterators.pass.cpp b/test/std/containers/unord/unord.set/local_iterators.pass.cpp index 2ffd93f30d19..55c80e4cb185 100644 --- a/test/std/containers/unord/unord.set/local_iterators.pass.cpp +++ b/test/std/containers/unord/unord.set/local_iterators.pass.cpp @@ -203,7 +203,7 @@ int main() assert(std::distance(i, j) == 1); assert(*i == 4); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.set/max_bucket_count.pass.cpp b/test/std/containers/unord/unord.set/max_bucket_count.pass.cpp index 8b5e265de3f2..dab13ea5ae5f 100644 --- a/test/std/containers/unord/unord.set/max_bucket_count.pass.cpp +++ b/test/std/containers/unord/unord.set/max_bucket_count.pass.cpp @@ -27,7 +27,7 @@ int main() const C c; assert(c.max_bucket_count() > 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.set/max_load_factor.pass.cpp b/test/std/containers/unord/unord.set/max_load_factor.pass.cpp index d326f4a2d7e2..542788cca967 100644 --- a/test/std/containers/unord/unord.set/max_load_factor.pass.cpp +++ b/test/std/containers/unord/unord.set/max_load_factor.pass.cpp @@ -41,7 +41,7 @@ int main() c.max_load_factor(2.5); assert(c.max_load_factor() == 2.5); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.set/max_size.pass.cpp b/test/std/containers/unord/unord.set/max_size.pass.cpp index 1c6e74125c7d..3135ad994737 100644 --- a/test/std/containers/unord/unord.set/max_size.pass.cpp +++ b/test/std/containers/unord/unord.set/max_size.pass.cpp @@ -26,7 +26,7 @@ int main() std::unordered_set<int> u; assert(u.max_size() > 0); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> u; diff --git a/test/std/containers/unord/unord.set/rehash.pass.cpp b/test/std/containers/unord/unord.set/rehash.pass.cpp index e28c25dc8197..a4d4d3fbf02c 100644 --- a/test/std/containers/unord/unord.set/rehash.pass.cpp +++ b/test/std/containers/unord/unord.set/rehash.pass.cpp @@ -67,7 +67,7 @@ int main() assert(c.bucket_count() == 31); test(c); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.set/reserve.pass.cpp b/test/std/containers/unord/unord.set/reserve.pass.cpp index 078b886b267e..4bd5332f0796 100644 --- a/test/std/containers/unord/unord.set/reserve.pass.cpp +++ b/test/std/containers/unord/unord.set/reserve.pass.cpp @@ -73,7 +73,7 @@ int main() assert(c.bucket_count() >= 16); test(c); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, std::hash<int>, std::equal_to<int>, min_allocator<int>> C; diff --git a/test/std/containers/unord/unord.set/swap_member.pass.cpp b/test/std/containers/unord/unord.set/swap_member.pass.cpp index 89ec986d08f3..5ddb2d00daef 100644 --- a/test/std/containers/unord/unord.set/swap_member.pass.cpp +++ b/test/std/containers/unord/unord.set/swap_member.pass.cpp @@ -386,7 +386,7 @@ int main() assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); assert(c2.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef test_hash<std::hash<int> > Hash; typedef test_compare<std::equal_to<int> > Compare; diff --git a/test/std/containers/unord/unord.set/types.pass.cpp b/test/std/containers/unord/unord.set/types.pass.cpp index 7e752a434ece..fdda2b8072e3 100644 --- a/test/std/containers/unord/unord.set/types.pass.cpp +++ b/test/std/containers/unord/unord.set/types.pass.cpp @@ -48,7 +48,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::unordered_set<short, std::hash<short>, std::equal_to<short>, min_allocator<short>> C; diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp index 30905aeb9fe2..d0b03b2cd0b8 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/allocator.pass.cpp @@ -43,7 +43,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp index 6925e3045412..05cb0525eb79 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/assign_copy.pass.cpp @@ -134,7 +134,7 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef min_allocator<int> A; typedef std::unordered_set<int, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp index 69d19a4dac2e..a99e74af5943 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/assign_init.pass.cpp @@ -59,7 +59,7 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef min_allocator<int> A; typedef std::unordered_set<int, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp index e8712b7431c4..d8732268b85f 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/assign_move.pass.cpp @@ -162,7 +162,7 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef min_allocator<int> A; typedef std::unordered_set<int, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/compare_copy_constructible.fail.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/compare_copy_constructible.fail.cpp new file mode 100644 index 000000000000..6b675f00f16b --- /dev/null +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/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. +// +//===----------------------------------------------------------------------===// + +// <unordered_set> + +// Check that std::unordered_set fails to instantiate if the comparison predicate is +// not copy-constructible. This is LWG issue 2436 + +#include <unordered_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::unordered_set<int, std::hash<int>, Comp<int> > m; +} diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp index e1a9b27619b7..07278be79e57 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/copy.pass.cpp @@ -105,7 +105,7 @@ int main() assert(c.max_load_factor() == 1); } #endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp index b31875befa38..59f4bfabd582 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/copy_alloc.pass.cpp @@ -65,7 +65,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp index 6efa9ed8d1de..e53f381f2d6d 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/default.pass.cpp @@ -43,7 +43,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp index f419c31c4796..3dcc3247902e 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/default_noexcept.pass.cpp @@ -17,9 +17,12 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <unordered_set> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" #include "../../../test_hash.h" @@ -30,6 +33,7 @@ struct some_comp typedef T value_type; some_comp(); some_comp(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; template <class T> @@ -42,15 +46,14 @@ struct some_hash int main() { -#if __has_feature(cxx_noexcept) { typedef std::unordered_set<MoveOnly> C; - static_assert(std::is_nothrow_default_constructible<C>::value, ""); + LIBCPP_STATIC_ASSERT(std::is_nothrow_default_constructible<C>::value, ""); } { typedef std::unordered_set<MoveOnly, std::hash<MoveOnly>, std::equal_to<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::unordered_set<MoveOnly, std::hash<MoveOnly>, @@ -66,5 +69,4 @@ int main() some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_default_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp index 1e196b2e119e..b6837ccaec8d 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/dtor_noexcept.pass.cpp @@ -11,19 +11,20 @@ // ~unordered_set() // implied noexcept; +// UNSUPPORTED: c++98, c++03 + #include <unordered_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; } }; template <class T> @@ -35,11 +36,8 @@ struct some_hash ~some_hash() noexcept(false); }; -#endif - int main() { -#if __has_feature(cxx_noexcept) { typedef std::unordered_set<MoveOnly> C; static_assert(std::is_nothrow_destructible<C>::value, ""); @@ -63,5 +61,4 @@ int main() some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_destructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/hash_copy_constructible.fail.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/hash_copy_constructible.fail.cpp new file mode 100644 index 000000000000..066f160a2586 --- /dev/null +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/hash_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. +// +//===----------------------------------------------------------------------===// + +// <unordered_map> + +// Check that std::unordered_set fails to instantiate if the hash function is +// not copy-constructible. This is mentioned in LWG issue 2436 + +#include <unordered_set> + +template <class T> +struct Hash { + std::size_t operator () (const T& lhs) const { return 0; } + + Hash () {} +private: + Hash (const Hash &); // declared but not defined + }; + + +int main() { + std::unordered_set<int, Hash<int> > m; +} diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp index 2c31d575b635..3fd0c3926c0b 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/init.pass.cpp @@ -57,7 +57,7 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp index 340fc410109a..b7eed1e5b253 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size.pass.cpp @@ -60,7 +60,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp index fa6f0bd2ad5f..735babd522b3 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash.pass.cpp @@ -62,7 +62,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp index dc3a6652ec25..643a57fa99ca 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal.pass.cpp @@ -63,7 +63,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp index 1b006dbbc91c..72b9ed2a1de0 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/init_size_hash_equal_allocator.pass.cpp @@ -64,7 +64,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp index f2a2a68d4036..e865986337c4 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/move.pass.cpp @@ -103,7 +103,7 @@ int main() assert(c0.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp index 92eb36d513b6..2342bbc130be 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/move_alloc.pass.cpp @@ -110,7 +110,7 @@ int main() assert(c0.empty()); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef int P; typedef min_allocator<int> A; diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp index 02af34d8f885..45f18dbbcb5c 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/move_assign_noexcept.pass.cpp @@ -17,6 +17,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <unordered_set> #include <cassert> @@ -28,6 +30,7 @@ struct some_comp { typedef T value_type; some_comp& operator=(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; template <class T> @@ -41,7 +44,6 @@ struct some_hash int main() { -#if __has_feature(cxx_noexcept) { typedef std::unordered_set<MoveOnly> C; static_assert(std::is_nothrow_move_assignable<C>::value, ""); @@ -65,5 +67,4 @@ int main() some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_assignable<C>::value, ""); } -#endif } diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp index b2d89ba5c33b..b4046148bc79 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/move_noexcept.pass.cpp @@ -15,6 +15,8 @@ // This tests a conforming extension +// UNSUPPORTED: c++98, c++03 + #include <unordered_set> #include <cassert> @@ -26,6 +28,7 @@ struct some_comp { typedef T value_type; some_comp(const some_comp&); + bool operator()(const T&, const T&) const { return false; } }; template <class T> @@ -38,7 +41,6 @@ struct some_hash int main() { -#if __has_feature(cxx_noexcept) { typedef std::unordered_set<MoveOnly> C; static_assert(std::is_nothrow_move_constructible<C>::value, ""); @@ -62,5 +64,4 @@ int main() some_comp<MoveOnly>> C; static_assert(!std::is_nothrow_move_constructible<C>::value, ""); } -#endif } diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp index 40f3f4f4d7f9..c978d8d5d8a4 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/range.pass.cpp @@ -60,7 +60,7 @@ int main() assert(fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp index ff50c712ab5d..b87d5615e00e 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size.pass.cpp @@ -63,7 +63,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp index bcdcc5510c3c..7234d8a80aec 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash.pass.cpp @@ -65,7 +65,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp index 632265ac861d..bcf3058aa835 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal.pass.cpp @@ -66,7 +66,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp index ebe54fd4cbc6..ad9b414d7f13 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/range_size_hash_equal_allocator.pass.cpp @@ -68,7 +68,7 @@ int main() assert(std::fabs(c.load_factor() - (float)c.size()/c.bucket_count()) < FLT_EPSILON); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<int, test_hash<std::hash<int> >, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp index 8f6228ad8ec4..88e499773bf3 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/size.pass.cpp @@ -43,7 +43,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp index 4c2c18edd1ce..eb98dcc7b7e4 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash.pass.cpp @@ -45,7 +45,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp index e9368782ad9a..4ae012038ae5 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal.pass.cpp @@ -46,7 +46,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp b/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp index 96233e187af5..b2ddbe94e741 100644 --- a/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.cnstr/size_hash_equal_allocator.pass.cpp @@ -47,7 +47,7 @@ int main() assert(c.load_factor() == 0); assert(c.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef std::unordered_set<NotConstructible, test_hash<std::hash<NotConstructible> >, diff --git a/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp b/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp index 5d746407a80c..d35d79b31266 100644 --- a/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.swap/swap_noexcept.pass.cpp @@ -7,6 +7,8 @@ // //===----------------------------------------------------------------------===// +// UNSUPPORTED: c++98, c++03 + // <unordered_set> // void swap(unordered_set& c) @@ -26,6 +28,7 @@ #include <unordered_set> #include <cassert> +#include "test_macros.h" #include "MoveOnly.h" #include "test_allocator.h" @@ -33,20 +36,20 @@ template <class T> struct some_comp { typedef T value_type; - + some_comp() {} some_comp(const some_comp&) {} + 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 @@ -60,6 +63,7 @@ struct some_hash typedef T value_type; some_hash() {} some_hash(const some_hash&); + std::size_t operator()(const T&) const { return 0; } }; template <class T> @@ -68,6 +72,7 @@ struct some_hash2 typedef T value_type; some_hash2() {} some_hash2(const some_hash2&); + std::size_t operator()(const T&) const { return 0; } }; #if TEST_STD_VER >= 14 @@ -79,7 +84,7 @@ template <class T> struct some_alloc { typedef T value_type; - + some_alloc() {} some_alloc(const some_alloc&); void deallocate(void*, unsigned) {} @@ -91,7 +96,7 @@ template <class T> struct some_alloc2 { typedef T value_type; - + some_alloc2() {} some_alloc2(const some_alloc2&); void deallocate(void*, unsigned) {} @@ -104,7 +109,7 @@ template <class T> struct some_alloc3 { typedef T value_type; - + some_alloc3() {} some_alloc3(const some_alloc3&); void deallocate(void*, unsigned) {} @@ -115,7 +120,6 @@ struct some_alloc3 int main() { -#if __has_feature(cxx_noexcept) { typedef std::unordered_set<MoveOnly> C; C c1, c2; @@ -193,6 +197,4 @@ int main() static_assert( noexcept(swap(c1, c2)), ""); } #endif - -#endif } diff --git a/test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp b/test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp index 7415e2977716..2755b5285027 100644 --- a/test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp +++ b/test/std/containers/unord/unord.set/unord.set.swap/swap_non_member.pass.cpp @@ -386,7 +386,7 @@ int main() assert(std::distance(c2.cbegin(), c2.cend()) == c2.size()); assert(c2.max_load_factor() == 1); } -#if __cplusplus >= 201103L +#if TEST_STD_VER >= 11 { typedef test_hash<std::hash<int> > Hash; typedef test_compare<std::equal_to<int> > Compare; |