aboutsummaryrefslogtreecommitdiff
path: root/test/std/utilities/memory
diff options
context:
space:
mode:
authorDimitry Andric <dim@FreeBSD.org>2017-01-02 19:18:58 +0000
committerDimitry Andric <dim@FreeBSD.org>2017-01-02 19:18:58 +0000
commit53a420fba21cf1644972b34dcd811a43cdb8368d (patch)
tree66a19f6f8b65215772549a51d688492ab8addc0d /test/std/utilities/memory
parentb50f1549701eb950921e5d6f2e55ba1a1dadbb43 (diff)
downloadsrc-53a420fba21cf1644972b34dcd811a43cdb8368d.tar.gz
src-53a420fba21cf1644972b34dcd811a43cdb8368d.zip
Vendor import of libc++ trunk r290819:vendor/libc++/libc++-trunk-r290819
Notes
Notes: svn path=/vendor/libc++/dist/; revision=311123 svn path=/vendor/libc++/libc++-trunk-r290819/; revision=311124; tag=vendor/libc++/libc++-trunk-r290819
Diffstat (limited to 'test/std/utilities/memory')
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp5
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp17
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp10
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp5
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp6
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp20
-rw-r--r--test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp6
-rw-r--r--test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp8
-rw-r--r--test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp38
-rw-r--r--test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp34
-rw-r--r--test/std/utilities/memory/default.allocator/allocator_types.pass.cpp4
-rw-r--r--test/std/utilities/memory/pointer.traits/rebind.pass.cpp4
-rw-r--r--test/std/utilities/memory/specialized.algorithms/specialized.addressof/addressof.temp.fail.cpp26
-rw-r--r--test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp2
-rw-r--r--test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy.pass.cpp47
-rw-r--r--test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy_at.pass.cpp78
-rw-r--r--test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy_n.pass.cpp49
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct.pass.cpp112
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct_n.pass.cpp116
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct.pass.cpp111
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct_n.pass.cpp115
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp13
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp13
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp13
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp13
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move.pass.cpp114
-rw-r--r--test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move_n.pass.cpp117
-rw-r--r--test/std/utilities/memory/storage.iterator/raw_storage_iterator.pass.cpp3
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp1
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp11
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp6
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp2
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp42
-rw-r--r--test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp42
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp4
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp4
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp2
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp2
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp2
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp2
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp2
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp16
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp16
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp3
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp7
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp3
-rw-r--r--test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp6
47 files changed, 1098 insertions, 174 deletions
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp
index 490fdf5d332b..ab8179c5ab4d 100644
--- a/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp
@@ -17,6 +17,7 @@
// };
#include <memory>
+#include <cstdint>
#include <cassert>
template <class T>
@@ -27,12 +28,12 @@ struct A
value_type* allocate(std::size_t n)
{
assert(n == 10);
- return (value_type*)0xDEADBEEF;
+ return reinterpret_cast<value_type*>(static_cast<std::uintptr_t>(0xDEADBEEF));
}
};
int main()
{
A<int> a;
- assert(std::allocator_traits<A<int> >::allocate(a, 10) == (int*)0xDEADBEEF);
+ assert(std::allocator_traits<A<int> >::allocate(a, 10) == reinterpret_cast<int*>(static_cast<std::uintptr_t>(0xDEADBEEF)));
}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp
index 079db3526ac7..808284261f7d 100644
--- a/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp
@@ -17,8 +17,11 @@
// };
#include <memory>
+#include <cstdint>
#include <cassert>
+#include "test_macros.h"
+
template <class T>
struct A
{
@@ -27,7 +30,7 @@ struct A
value_type* allocate(std::size_t n)
{
assert(n == 10);
- return (value_type*)0xDEADBEEF;
+ return reinterpret_cast<value_type*>(static_cast<std::uintptr_t>(0xDEADBEEF));
}
};
@@ -39,22 +42,22 @@ struct B
value_type* allocate(std::size_t n)
{
assert(n == 12);
- return (value_type*)0xEEADBEEF;
+ return reinterpret_cast<value_type*>(static_cast<std::uintptr_t>(0xEEADBEEF));
}
value_type* allocate(std::size_t n, const void* p)
{
assert(n == 11);
assert(p == 0);
- return (value_type*)0xFEADBEEF;
+ return reinterpret_cast<value_type*>(static_cast<std::uintptr_t>(0xFEADBEEF));
}
};
int main()
{
-#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if TEST_STD_VER >= 11
A<int> a;
- assert(std::allocator_traits<A<int> >::allocate(a, 10, nullptr) == (int*)0xDEADBEEF);
-#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ assert(std::allocator_traits<A<int> >::allocate(a, 10, nullptr) == reinterpret_cast<int*>(static_cast<std::uintptr_t>(0xDEADBEEF)));
+#endif
B<int> b;
- assert(std::allocator_traits<B<int> >::allocate(b, 11, nullptr) == (int*)0xFEADBEEF);
+ assert(std::allocator_traits<B<int> >::allocate(b, 11, nullptr) == reinterpret_cast<int*>(static_cast<std::uintptr_t>(0xFEADBEEF)));
}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp
index 634019758e70..46075f62c6c1 100644
--- a/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp
@@ -22,6 +22,8 @@
#include <type_traits>
#include <cassert>
+#include "test_macros.h"
+
template <class T>
struct A
{
@@ -36,14 +38,14 @@ struct B
{
typedef T value_type;
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#if TEST_STD_VER >= 11
template <class U, class ...Args>
void construct(U* p, Args&& ...args)
{
++b_construct;
::new ((void*)p) U(std::forward<Args>(args)...);
}
-#endif // _LIBCPP_HAS_NO_VARIADICS
+#endif
};
struct A0
@@ -105,7 +107,7 @@ int main()
std::allocator_traits<A<int> >::construct(a, (A2*)&a2, 'd', 5);
assert(A2::count == 1);
}
-#ifndef _LIBCPP_HAS_NO_VARIADICS
+#if TEST_STD_VER >= 11
{
A0::count = 0;
b_construct = 0;
@@ -139,5 +141,5 @@ int main()
assert(A2::count == 1);
assert(b_construct == 1);
}
-#endif // _LIBCPP_HAS_NO_VARIADICS
+#endif
}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp
index b137dc6d36c3..8176d8b3767a 100644
--- a/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp
@@ -17,6 +17,7 @@
// };
#include <memory>
+#include <cstdint>
#include <cassert>
int called = 0;
@@ -28,7 +29,7 @@ struct A
void deallocate(value_type* p, std::size_t n)
{
- assert(p == (value_type*)0xDEADBEEF);
+ assert(p == reinterpret_cast<value_type*>(static_cast<std::uintptr_t>(0xDEADBEEF)));
assert(n == 10);
++called;
}
@@ -37,6 +38,6 @@ struct A
int main()
{
A<int> a;
- std::allocator_traits<A<int> >::deallocate(a, (int*)0xDEADBEEF, 10);
+ std::allocator_traits<A<int> >::deallocate(a, reinterpret_cast<int*>(static_cast<std::uintptr_t>(0xDEADBEEF)), 10);
assert(called == 1);
}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
index 54726c929efe..2ee64b8b4a07 100644
--- a/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
@@ -22,6 +22,8 @@
#include <type_traits>
#include <cassert>
+#include "test_macros.h"
+
template <class T>
struct A
{
@@ -63,7 +65,7 @@ int main()
std::allocator_traits<A<int> >::destroy(a, (A0*)&a0);
assert(A0::count == 1);
}
-#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if TEST_STD_VER >= 11
{
A0::count = 0;
b_destroy = 0;
@@ -76,5 +78,5 @@ int main()
assert(A0::count == 1);
assert(b_destroy == 1);
}
-#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#endif
}
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp
index bbc6b470174d..d2c9a9826e14 100644
--- a/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp
@@ -43,7 +43,15 @@ struct B
int main()
{
-#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+ {
+ B<int> b;
+ assert(std::allocator_traits<B<int> >::max_size(b) == 100);
+ }
+ {
+ const B<int> b = {};
+ assert(std::allocator_traits<B<int> >::max_size(b) == 100);
+ }
+#if TEST_STD_VER >= 11
{
A<int> a;
assert(std::allocator_traits<A<int> >::max_size(a) ==
@@ -54,16 +62,6 @@ int main()
assert(std::allocator_traits<A<int> >::max_size(a) ==
std::numeric_limits<std::size_t>::max() / sizeof(int));
}
-#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
- {
- B<int> b;
- assert(std::allocator_traits<B<int> >::max_size(b) == 100);
- }
- {
- const B<int> b = {};
- assert(std::allocator_traits<B<int> >::max_size(b) == 100);
- }
-#if TEST_STD_VER >= 11
{
std::allocator<int> a;
static_assert(noexcept(std::allocator_traits<std::allocator<int>>::max_size(a)) == true, "");
diff --git a/test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp b/test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp
index 29fe2be126f3..2e9703037894 100644
--- a/test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp
+++ b/test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp
@@ -22,6 +22,8 @@
#include <type_traits>
#include <cassert>
+#include "test_macros.h"
+
template <class T>
struct A
{
@@ -55,7 +57,7 @@ int main()
const A<int> a(0);
assert(std::allocator_traits<A<int> >::select_on_container_copy_construction(a).id == 0);
}
-#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#if TEST_STD_VER >= 11
{
B<int> b;
assert(std::allocator_traits<B<int> >::select_on_container_copy_construction(b).id == 100);
@@ -64,5 +66,5 @@ int main()
const B<int> b(0);
assert(std::allocator_traits<B<int> >::select_on_container_copy_construction(b).id == 100);
}
-#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE
+#endif
}
diff --git a/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp b/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp
index 87da9a0a85da..af4f5bc3fb46 100644
--- a/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp
+++ b/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp
@@ -19,6 +19,8 @@
#include <memory>
#include <type_traits>
+#include "test_macros.h"
+
template <class T>
struct ReboundA {};
@@ -63,17 +65,17 @@ struct E
int main()
{
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+#if TEST_STD_VER >= 11
static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>, std::allocator_traits<ReboundA<double> > >::value), "");
static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>, std::allocator_traits<ReboundB<double, char> > >::value), "");
static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>, std::allocator_traits<C<double> > >::value), "");
static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>, std::allocator_traits<D<double, char> > >::value), "");
static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>, std::allocator_traits<E<double> > >::value), "");
-#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+#else
static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_traits<double>::other, std::allocator_traits<ReboundA<double> > >::value), "");
static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_traits<double>::other, std::allocator_traits<ReboundB<double, char> > >::value), "");
static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_traits<double>::other, std::allocator_traits<C<double> > >::value), "");
static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_traits<double>::other, std::allocator_traits<D<double, char> > >::value), "");
static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_traits<double>::other, std::allocator_traits<E<double> > >::value), "");
-#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+#endif
}
diff --git a/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp b/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp
index bd32bc34e7a0..2831399c3047 100644
--- a/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp
+++ b/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp
@@ -38,16 +38,38 @@ private:
typedef int allocator_type;
};
+template <bool Expected, class T, class A>
+void
+test()
+{
+ static_assert((std::uses_allocator<T, A>::value == Expected), "");
+#if TEST_STD_VER > 14
+ static_assert((std::uses_allocator_v<T, A> == Expected), "");
+#endif
+}
+
int main()
{
- static_assert((!std::uses_allocator<int, std::allocator<int> >::value), "");
- static_assert(( std::uses_allocator<std::vector<int>, std::allocator<int> >::value), "");
- static_assert((!std::uses_allocator<A, std::allocator<int> >::value), "");
- static_assert((!std::uses_allocator<B, std::allocator<int> >::value), "");
- static_assert(( std::uses_allocator<B, double>::value), "");
- static_assert((!std::uses_allocator<C, decltype(C::allocator_type)>::value), "");
- static_assert((!std::uses_allocator<D, decltype(D::allocator_type)>::value), "");
+ test<false, int, std::allocator<int> >();
+ test<true, std::vector<int>, std::allocator<int> >();
+ test<false, A, std::allocator<int> >();
+ test<false, B, std::allocator<int> >();
+ test<true, B, double>();
+ test<false, C, decltype(C::allocator_type)>();
+ test<false, D, decltype(D::allocator_type)>();
#if TEST_STD_VER >= 11
- static_assert((!std::uses_allocator<E, int>::value), "");
+ test<false, E, int>();
#endif
+
+
+// static_assert((!std::uses_allocator<int, std::allocator<int> >::value), "");
+// static_assert(( std::uses_allocator<std::vector<int>, std::allocator<int> >::value), "");
+// static_assert((!std::uses_allocator<A, std::allocator<int> >::value), "");
+// static_assert((!std::uses_allocator<B, std::allocator<int> >::value), "");
+// static_assert(( std::uses_allocator<B, double>::value), "");
+// static_assert((!std::uses_allocator<C, decltype(C::allocator_type)>::value), "");
+// static_assert((!std::uses_allocator<D, decltype(D::allocator_type)>::value), "");
+// #if TEST_STD_VER >= 11
+// static_assert((!std::uses_allocator<E, int>::value), "");
+// #endif
}
diff --git a/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp b/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp
index dc0bdd047c61..768d41878437 100644
--- a/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp
+++ b/test/std/utilities/memory/default.allocator/allocator.members/allocate.size.pass.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
// <memory>
// allocator:
@@ -16,6 +16,8 @@
#include <memory>
#include <cassert>
+#include "test_macros.h"
+
template <typename T>
void test_max(size_t count)
{
@@ -27,23 +29,19 @@ void test_max(size_t count)
}
}
-int main()
+template <typename T>
+void test()
{
- { // Bug 26812 -- allocating too large
- typedef double T;
- std::allocator<T> a;
- test_max<T> (a.max_size() + 1); // just barely too large
- test_max<T> (a.max_size() * 2); // significantly too large
- test_max<T> (((size_t) -1) / sizeof(T) + 1); // multiply will overflow
- test_max<T> ((size_t) -1); // way too large
- }
+ // Bug 26812 -- allocating too large
+ std::allocator<T> a;
+ test_max<T> (a.max_size() + 1); // just barely too large
+ test_max<T> (a.max_size() * 2); // significantly too large
+ test_max<T> (((size_t) -1) / sizeof(T) + 1); // multiply will overflow
+ test_max<T> ((size_t) -1); // way too large
+}
- {
- typedef const double T;
- std::allocator<T> a;
- test_max<T> (a.max_size() + 1); // just barely too large
- test_max<T> (a.max_size() * 2); // significantly too large
- test_max<T> (((size_t) -1) / sizeof(T) + 1); // multiply will overflow
- test_max<T> ((size_t) -1); // way too large
- }
+int main()
+{
+ test<double>();
+ LIBCPP_ONLY(test<const double>());
}
diff --git a/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp b/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp
index cba32103dcd4..7f25e57765d4 100644
--- a/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp
+++ b/test/std/utilities/memory/default.allocator/allocator_types.pass.cpp
@@ -32,6 +32,8 @@
#include <type_traits>
#include <cstddef>
+#include "test_macros.h"
+
int main()
{
static_assert((std::is_same<std::allocator<char>::size_type, std::size_t>::value), "");
@@ -45,7 +47,7 @@ int main()
std::allocator<int> >::value), "");
static_assert((std::is_same<std::allocator< char>::is_always_equal, std::true_type>::value), "");
- static_assert((std::is_same<std::allocator<const char>::is_always_equal, std::true_type>::value), "");
+ LIBCPP_STATIC_ASSERT((std::is_same<std::allocator<const char>::is_always_equal, std::true_type>::value), "");
std::allocator<char> a;
std::allocator<char> a2 = a;
diff --git a/test/std/utilities/memory/pointer.traits/rebind.pass.cpp b/test/std/utilities/memory/pointer.traits/rebind.pass.cpp
index 8716c05f3335..4caf4f650297 100644
--- a/test/std/utilities/memory/pointer.traits/rebind.pass.cpp
+++ b/test/std/utilities/memory/pointer.traits/rebind.pass.cpp
@@ -19,9 +19,11 @@
#include <memory>
#include <type_traits>
+#include "test_macros.h"
+
int main()
{
-#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+#if TEST_STD_VER >= 11
static_assert((std::is_same<std::pointer_traits<int*>::rebind<double>, double*>::value), "");
#else
static_assert((std::is_same<std::pointer_traits<int*>::rebind<double>::other, double*>::value), "");
diff --git a/test/std/utilities/memory/specialized.algorithms/specialized.addressof/addressof.temp.fail.cpp b/test/std/utilities/memory/specialized.algorithms/specialized.addressof/addressof.temp.fail.cpp
new file mode 100644
index 000000000000..81f49eaac39b
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/specialized.addressof/addressof.temp.fail.cpp
@@ -0,0 +1,26 @@
+//===----------------------------------------------------------------------===//
+//
+// 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.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <ObjectType T> T* addressof(T&& r) = delete;
+
+#include <memory>
+#include <cassert>
+
+#include "test_macros.h"
+
+int main()
+{
+#if TEST_STD_VER > 14
+ const int *p = std::addressof<const int>(0);
+#else
+#error
+#endif
+}
diff --git a/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp b/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp
index a371f8eda1a8..41f06c519609 100644
--- a/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp
+++ b/test/std/utilities/memory/specialized.algorithms/specialized.addressof/constexpr_addressof.pass.cpp
@@ -8,7 +8,7 @@
//===----------------------------------------------------------------------===//
// UNSUPPORTED: c++98, c++03, c++11, c++14
-// XFAIL: gcc
+// XFAIL: gcc-4, gcc-5, gcc-6
// <memory>
diff --git a/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy.pass.cpp b/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy.pass.cpp
new file mode 100644
index 000000000000..2ad9d04e59b7
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy.pass.cpp
@@ -0,0 +1,47 @@
+//===----------------------------------------------------------------------===//
+//
+// 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, c++11, c++14
+
+// <memory>
+
+// template <class ForwardIt>
+// void destroy(ForwardIt, ForwardIt);
+
+#include <memory>
+#include <cstdlib>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_iterators.h"
+
+struct Counted {
+ static int count;
+ static void reset() { count = 0; }
+ Counted() { ++count; }
+ Counted(Counted const&) { ++count; }
+ ~Counted() { --count; }
+ friend void operator&(Counted) = delete;
+};
+int Counted::count = 0;
+
+int main()
+{
+ using It = forward_iterator<Counted*>;
+ const int N = 5;
+ alignas(Counted) char pool[sizeof(Counted)*N] = {};
+ Counted* p = (Counted*)pool;
+ std::uninitialized_fill(p, p+N, Counted());
+ assert(Counted::count == 5);
+ std::destroy(p, p+1);
+ p += 1;
+ assert(Counted::count == 4);
+ std::destroy(It(p), It(p + 4));
+ assert(Counted::count == 0);
+}
diff --git a/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy_at.pass.cpp b/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy_at.pass.cpp
new file mode 100644
index 000000000000..4e67b1eceb57
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy_at.pass.cpp
@@ -0,0 +1,78 @@
+//===----------------------------------------------------------------------===//
+//
+// 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, c++11, c++14
+
+// <memory>
+
+// template <class _Tp>
+// void destroy_at(_Tp*);
+
+#include <memory>
+#include <cstdlib>
+#include <cassert>
+
+struct Counted {
+ static int count;
+ static void reset() { count = 0; }
+ Counted() { ++count; }
+ Counted(Counted const&) { ++count; }
+ ~Counted() { --count; }
+ friend void operator&(Counted) = delete;
+};
+int Counted::count = 0;
+
+struct VCounted {
+ static int count;
+ static void reset() { count = 0; }
+ VCounted() { ++count; }
+ VCounted(VCounted const&) { ++count; }
+ virtual ~VCounted() { --count; }
+ friend void operator&(VCounted) = delete;
+};
+int VCounted::count = 0;
+
+struct DCounted : VCounted {
+ friend void operator&(DCounted) = delete;
+};
+
+int main()
+{
+ {
+ void* mem1 = std::malloc(sizeof(Counted));
+ void* mem2 = std::malloc(sizeof(Counted));
+ assert(mem1 && mem2);
+ assert(Counted::count == 0);
+ Counted* ptr1 = ::new(mem1) Counted();
+ Counted* ptr2 = ::new(mem2) Counted();
+ assert(Counted::count == 2);
+ std::destroy_at(ptr1);
+ assert(Counted::count == 1);
+ std::destroy_at(ptr2);
+ assert(Counted::count == 0);
+ std::free(mem1);
+ std::free(mem2);
+ }
+ {
+ void* mem1 = std::malloc(sizeof(DCounted));
+ void* mem2 = std::malloc(sizeof(DCounted));
+ assert(mem1 && mem2);
+ assert(DCounted::count == 0);
+ DCounted* ptr1 = ::new(mem1) DCounted();
+ DCounted* ptr2 = ::new(mem2) DCounted();
+ assert(DCounted::count == 2);
+ assert(VCounted::count == 2);
+ std::destroy_at(ptr1);
+ assert(VCounted::count == 1);
+ std::destroy_at(ptr2);
+ assert(VCounted::count == 0);
+ std::free(mem1);
+ std::free(mem2);
+ }
+}
diff --git a/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy_n.pass.cpp
new file mode 100644
index 000000000000..d1eaca558a73
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/specialized.destroy/destroy_n.pass.cpp
@@ -0,0 +1,49 @@
+//===----------------------------------------------------------------------===//
+//
+// 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, c++11, c++14
+
+// <memory>
+
+// template <class ForwardIt, class Size>
+// ForwardIt destroy_n(ForwardIt, Size s);
+
+#include <memory>
+#include <cstdlib>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_iterators.h"
+
+struct Counted {
+ static int count;
+ static void reset() { count = 0; }
+ Counted() { ++count; }
+ Counted(Counted const&) { ++count; }
+ ~Counted() { --count; }
+ friend void operator&(Counted) = delete;
+};
+int Counted::count = 0;
+
+int main()
+{
+ using It = forward_iterator<Counted*>;
+ const int N = 5;
+ alignas(Counted) char pool[sizeof(Counted)*N] = {};
+ Counted* p = (Counted*)pool;
+ std::uninitialized_fill(p, p+N, Counted());
+ assert(Counted::count == 5);
+ Counted* np = std::destroy_n(p, 1);
+ assert(np == p+1);
+ assert(Counted::count == 4);
+ p += 1;
+ It it = std::destroy_n(It(p), 4);
+ assert(it == It(p+4));
+ assert(Counted::count == 0);
+}
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct.pass.cpp
new file mode 100644
index 000000000000..533d516707e1
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct.pass.cpp
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// 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, c++11, c++14
+
+// <memory>
+
+// template <class ForwardIt>
+// void uninitialized_default_construct(ForwardIt, ForwardIt);
+
+#include <memory>
+#include <cstdlib>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_iterators.h"
+
+struct Counted {
+ static int count;
+ static int constructed;
+ static void reset() { count = constructed = 0; }
+ explicit Counted() { ++count; ++constructed; }
+ Counted(Counted const&) { assert(false); }
+ ~Counted() { --count; }
+ friend void operator&(Counted) = delete;
+};
+int Counted::count = 0;
+int Counted::constructed = 0;
+
+
+struct ThrowsCounted {
+ static int count;
+ static int constructed;
+ static int throw_after;
+ static void reset() { throw_after = count = constructed = 0; }
+ explicit ThrowsCounted() {
+ ++constructed;
+ if (throw_after > 0 && --throw_after == 0) {
+ TEST_THROW(1);
+ }
+ ++count;
+ }
+ ThrowsCounted(ThrowsCounted const&) { assert(false); }
+ ~ThrowsCounted() { assert(count > 0); --count; }
+ friend void operator&(ThrowsCounted) = delete;
+};
+int ThrowsCounted::count = 0;
+int ThrowsCounted::constructed = 0;
+int ThrowsCounted::throw_after = 0;
+
+
+void test_ctor_throws()
+{
+#ifndef TEST_HAS_NO_EXCEPTIONS
+ using It = forward_iterator<ThrowsCounted*>;
+ const int N = 5;
+ alignas(ThrowsCounted) char pool[sizeof(ThrowsCounted)*N] = {};
+ ThrowsCounted* p = (ThrowsCounted*)pool;
+ try {
+ ThrowsCounted::throw_after = 4;
+ std::uninitialized_default_construct(It(p), It(p+N));
+ assert(false);
+ } catch (...) {}
+ assert(ThrowsCounted::count == 0);
+ assert(ThrowsCounted::constructed == 4); // forth construction throws
+#endif
+}
+
+void test_counted()
+{
+ using It = forward_iterator<Counted*>;
+ const int N = 5;
+ alignas(Counted) char pool[sizeof(Counted)*N] = {};
+ Counted* p = (Counted*)pool;
+ std::uninitialized_default_construct(It(p), It(p+1));
+ assert(Counted::count == 1);
+ assert(Counted::constructed = 1);
+ std::uninitialized_default_construct(It(p+1), It(p+N));
+ assert(Counted::count == 5);
+ assert(Counted::constructed == 5);
+ std::destroy(p, p+N);
+ assert(Counted::count == 0);
+}
+
+void test_value_initialized()
+{
+ using It = forward_iterator<int*>;
+ const int N = 5;
+ int pool[N] = {-1, -1, -1, -1, -1};
+ int* p = pool;
+ std::uninitialized_default_construct(It(p), It(p+1));
+ assert(pool[0] == -1);
+ assert(pool[1] == -1);
+ std::uninitialized_default_construct(It(p+1), It(p+N));
+ assert(pool[1] == -1);
+ assert(pool[2] == -1);
+ assert(pool[3] == -1);
+ assert(pool[4] == -1);
+}
+
+int main()
+{
+ test_counted();
+ test_value_initialized();
+ test_ctor_throws();
+}
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct_n.pass.cpp
new file mode 100644
index 000000000000..f22a74f1f832
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.default/uninitialized_default_construct_n.pass.cpp
@@ -0,0 +1,116 @@
+//===----------------------------------------------------------------------===//
+//
+// 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, c++11, c++14
+
+// <memory>
+
+// template <class ForwardIt>
+// void uninitialized_default_construct(ForwardIt, ForwardIt);
+
+#include <memory>
+#include <cstdlib>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_iterators.h"
+
+struct Counted {
+ static int count;
+ static int constructed;
+ static void reset() { count = constructed = 0; }
+ explicit Counted() { ++count; ++constructed; }
+ Counted(Counted const&) { assert(false); }
+ ~Counted() { assert(count > 0); --count; }
+ friend void operator&(Counted) = delete;
+};
+int Counted::count = 0;
+int Counted::constructed = 0;
+
+
+struct ThrowsCounted {
+ static int count;
+ static int constructed;
+ static int throw_after;
+ static void reset() { throw_after = count = constructed = 0; }
+ explicit ThrowsCounted() {
+ ++constructed;
+ if (throw_after > 0 && --throw_after == 0) {
+ TEST_THROW(1);
+ }
+ ++count;
+ }
+ ThrowsCounted(ThrowsCounted const&) { assert(false); }
+ ~ThrowsCounted() { assert(count > 0); --count; }
+ friend void operator&(ThrowsCounted) = delete;
+};
+int ThrowsCounted::count = 0;
+int ThrowsCounted::constructed = 0;
+int ThrowsCounted::throw_after = 0;
+
+void test_ctor_throws()
+{
+#ifndef TEST_HAS_NO_EXCEPTIONS
+ using It = forward_iterator<ThrowsCounted*>;
+ const int N = 5;
+ alignas(ThrowsCounted) char pool[sizeof(ThrowsCounted)*N] = {};
+ ThrowsCounted* p = (ThrowsCounted*)pool;
+ try {
+ ThrowsCounted::throw_after = 4;
+ std::uninitialized_default_construct_n(It(p), N);
+ assert(false);
+ } catch (...) {}
+ assert(ThrowsCounted::count == 0);
+ assert(ThrowsCounted::constructed == 4); // forth construction throws
+#endif
+}
+
+void test_counted()
+{
+ using It = forward_iterator<Counted*>;
+ const int N = 5;
+ alignas(Counted) char pool[sizeof(Counted)*N] = {};
+ Counted* p = (Counted*)pool;
+ It e = std::uninitialized_default_construct_n(It(p), 1);
+ assert(e == It(p+1));
+ assert(Counted::count == 1);
+ assert(Counted::constructed = 1);
+ e = std::uninitialized_default_construct_n(It(p+1), 4);
+ assert(e == It(p+N));
+ assert(Counted::count == 5);
+ assert(Counted::constructed == 5);
+ std::destroy(p, p+N);
+ assert(Counted::count == 0);
+}
+
+void test_value_initialized()
+{
+ using It = forward_iterator<int*>;
+ const int N = 5;
+ int pool[N] = {-1, -1, -1, -1, -1};
+ int* p = pool;
+ auto e = std::uninitialized_default_construct_n(It(p), 1);
+ assert(e == It(p+1));
+ assert(pool[0] == -1);
+ assert(pool[1] == -1);
+ e = std::uninitialized_default_construct_n(It(p+1), 4);
+ assert(e == It(p+N));
+ assert(pool[1] == -1);
+ assert(pool[2] == -1);
+ assert(pool[3] == -1);
+ assert(pool[4] == -1);
+}
+
+
+int main()
+{
+ test_counted();
+ test_value_initialized();
+ test_ctor_throws();
+}
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct.pass.cpp
new file mode 100644
index 000000000000..c2d860694a75
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct.pass.cpp
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// 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, c++11, c++14
+
+// <memory>
+
+// template <class ForwardIt>
+// void uninitialized_value_construct(ForwardIt, ForwardIt);
+
+#include <memory>
+#include <cstdlib>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_iterators.h"
+
+struct Counted {
+ static int count;
+ static int constructed;
+ static void reset() { count = constructed = 0; }
+ explicit Counted() { ++count; ++constructed; }
+ Counted(Counted const&) { assert(false); }
+ ~Counted() { assert(count > 0); --count; }
+ friend void operator&(Counted) = delete;
+};
+int Counted::count = 0;
+int Counted::constructed = 0;
+
+
+struct ThrowsCounted {
+ static int count;
+ static int constructed;
+ static int throw_after;
+ static void reset() { throw_after = count = constructed = 0; }
+ explicit ThrowsCounted() {
+ ++constructed;
+ if (throw_after > 0 && --throw_after == 0) {
+ TEST_THROW(1);
+ }
+ ++count;
+ }
+ ThrowsCounted(ThrowsCounted const&) { assert(false); }
+ ~ThrowsCounted() { assert(count > 0); --count; }
+ friend void operator&(ThrowsCounted) = delete;
+};
+int ThrowsCounted::count = 0;
+int ThrowsCounted::constructed = 0;
+int ThrowsCounted::throw_after = 0;
+
+void test_ctor_throws()
+{
+#ifndef TEST_HAS_NO_EXCEPTIONS
+ using It = forward_iterator<ThrowsCounted*>;
+ const int N = 5;
+ alignas(ThrowsCounted) char pool[sizeof(ThrowsCounted)*N] = {};
+ ThrowsCounted* p = (ThrowsCounted*)pool;
+ try {
+ ThrowsCounted::throw_after = 4;
+ std::uninitialized_value_construct(It(p), It(p+N));
+ assert(false);
+ } catch (...) {}
+ assert(ThrowsCounted::count == 0);
+ assert(ThrowsCounted::constructed == 4); // forth construction throws
+#endif
+}
+
+void test_counted()
+{
+ using It = forward_iterator<Counted*>;
+ const int N = 5;
+ alignas(Counted) char pool[sizeof(Counted)*N] = {};
+ Counted* p = (Counted*)pool;
+ std::uninitialized_value_construct(It(p), It(p+1));
+ assert(Counted::count == 1);
+ assert(Counted::constructed = 1);
+ std::uninitialized_value_construct(It(p+1), It(p+N));
+ assert(Counted::count == 5);
+ assert(Counted::constructed == 5);
+ std::destroy(p, p+N);
+ assert(Counted::count == 0);
+}
+
+void test_value_initialized()
+{
+ using It = forward_iterator<int*>;
+ const int N = 5;
+ int pool[N] = {-1, -1, -1, -1, -1};
+ int* p = pool;
+ std::uninitialized_value_construct(It(p), It(p+1));
+ assert(pool[0] == 0);
+ assert(pool[1] == -1);
+ std::uninitialized_value_construct(It(p+1), It(p+N));
+ assert(pool[1] == 0);
+ assert(pool[2] == 0);
+ assert(pool[3] == 0);
+ assert(pool[4] == 0);
+}
+
+int main()
+{
+ test_counted();
+ test_value_initialized();
+ test_ctor_throws();
+}
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct_n.pass.cpp
new file mode 100644
index 000000000000..323d00f7c9c4
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.construct.value/uninitialized_value_construct_n.pass.cpp
@@ -0,0 +1,115 @@
+//===----------------------------------------------------------------------===//
+//
+// 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, c++11, c++14
+
+// <memory>
+
+// template <class ForwardIt>
+// void uninitialized_value_construct(ForwardIt, ForwardIt);
+
+#include <memory>
+#include <cstdlib>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_iterators.h"
+
+struct Counted {
+ static int count;
+ static int constructed;
+ static void reset() { count = constructed = 0; }
+ explicit Counted() { ++count; ++constructed; }
+ Counted(Counted const&) { assert(false); }
+ ~Counted() { --count; }
+ friend void operator&(Counted) = delete;
+};
+int Counted::count = 0;
+int Counted::constructed = 0;
+
+struct ThrowsCounted {
+ static int count;
+ static int constructed;
+ static int throw_after;
+ static void reset() { throw_after = count = constructed = 0; }
+ explicit ThrowsCounted() {
+ ++constructed;
+ if (throw_after > 0 && --throw_after == 0) {
+ TEST_THROW(1);
+ }
+ ++count;
+ }
+ ThrowsCounted(ThrowsCounted const&) { assert(false); }
+ ~ThrowsCounted() { --count; }
+ friend void operator&(ThrowsCounted) = delete;
+};
+int ThrowsCounted::count = 0;
+int ThrowsCounted::constructed = 0;
+int ThrowsCounted::throw_after = 0;
+
+void test_ctor_throws()
+{
+#ifndef TEST_HAS_NO_EXCEPTIONS
+ using It = forward_iterator<ThrowsCounted*>;
+ const int N = 5;
+ alignas(ThrowsCounted) char pool[sizeof(ThrowsCounted)*N] = {};
+ ThrowsCounted* p = (ThrowsCounted*)pool;
+ try {
+ ThrowsCounted::throw_after = 4;
+ std::uninitialized_value_construct_n(It(p), N);
+ assert(false);
+ } catch (...) {}
+ assert(ThrowsCounted::count == 3);
+ assert(ThrowsCounted::constructed == 4); // forth construction throws
+ std::destroy(p, p+3);
+ assert(ThrowsCounted::count == 0);
+#endif
+}
+
+void test_counted()
+{
+ using It = forward_iterator<Counted*>;
+ const int N = 5;
+ alignas(Counted) char pool[sizeof(Counted)*N] = {};
+ Counted* p = (Counted*)pool;
+ It e = std::uninitialized_value_construct_n(It(p), 1);
+ assert(e == It(p+1));
+ assert(Counted::count == 1);
+ assert(Counted::constructed = 1);
+ e = std::uninitialized_value_construct_n(It(p+1), 4);
+ assert(e == It(p+N));
+ assert(Counted::count == 5);
+ assert(Counted::constructed == 5);
+ std::destroy(p, p+N);
+ assert(Counted::count == 0);
+}
+
+void test_value_initialized()
+{
+ using It = forward_iterator<int*>;
+ const int N = 5;
+ int pool[N] = {-1, -1, -1, -1, -1};
+ int* p = pool;
+ It e = std::uninitialized_value_construct_n(It(p), 1);
+ assert(e == It(p+1));
+ assert(pool[0] == 0);
+ assert(pool[1] == -1);
+ e = std::uninitialized_value_construct_n(It(p+1), 4);
+ assert(e == It(p+N));
+ assert(pool[1] == 0);
+ assert(pool[2] == 0);
+ assert(pool[3] == 0);
+ assert(pool[4] == 0);
+}
+
+int main()
+{
+ test_counted();
+ test_value_initialized();
+} \ No newline at end of file
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
index 1debd6d75ff0..1829dff354d3 100644
--- a/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp
@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
// <memory>
// template <class InputIterator, class ForwardIterator>
@@ -18,13 +17,21 @@
#include <memory>
#include <cassert>
+#include "test_macros.h"
+
struct B
{
static int count_;
static int population_;
int data_;
explicit B() : data_(1) { ++population_; }
- B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; }
+ B(const B &b) {
+ ++count_;
+ if (count_ == 3)
+ TEST_THROW(1);
+ data_ = b.data_;
+ ++population_;
+ }
~B() {data_ = 0; --population_; }
};
@@ -49,6 +56,7 @@ int main()
B* bp = (B*)pool;
B b[N];
assert(B::population_ == N);
+#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
std::uninitialized_copy(b, b+N, bp);
@@ -58,6 +66,7 @@ int main()
{
assert(B::population_ == N);
}
+#endif
B::count_ = 0;
std::uninitialized_copy(b, b+2, bp);
for (int i = 0; i < 2; ++i)
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
index 83aa19471ada..af20cd220291 100644
--- a/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp
@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
// <memory>
// template <class InputIterator, class Size, class ForwardIterator>
@@ -18,13 +17,21 @@
#include <memory>
#include <cassert>
+#include "test_macros.h"
+
struct B
{
static int count_;
static int population_;
int data_;
explicit B() : data_(1) { ++population_; }
- B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; }
+ B(const B &b) {
+ ++count_;
+ if (count_ == 3)
+ TEST_THROW(1);
+ data_ = b.data_;
+ ++population_;
+ }
~B() {data_ = 0; --population_; }
};
@@ -49,6 +56,7 @@ int main()
B* bp = (B*)pool;
B b[N];
assert(B::population_ == N);
+#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
std::uninitialized_copy_n(b, 5, bp);
@@ -58,6 +66,7 @@ int main()
{
assert(B::population_ == N);
}
+#endif
B::count_ = 0;
std::uninitialized_copy_n(b, 2, bp);
for (int i = 0; i < 2; ++i)
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
index 5f90a3792064..862e5be8e363 100644
--- a/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp
@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
// <memory>
// template <class ForwardIterator, class Size, class T>
@@ -17,13 +16,21 @@
#include <memory>
#include <cassert>
+#include "test_macros.h"
+
struct B
{
static int count_;
static int population_;
int data_;
explicit B() : data_(1) { ++population_; }
- B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; }
+ B(const B &b) {
+ ++count_;
+ if (count_ == 3)
+ TEST_THROW(1);
+ data_ = b.data_;
+ ++population_;
+ }
~B() {data_ = 0; --population_; }
};
@@ -47,6 +54,7 @@ int main()
char pool[sizeof(B)*N] = {0};
B* bp = (B*)pool;
assert(B::population_ == 0);
+#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
std::uninitialized_fill_n(bp, 5, B());
@@ -56,6 +64,7 @@ int main()
{
assert(B::population_ == 0);
}
+#endif
B::count_ = 0;
B* r = std::uninitialized_fill_n(bp, 2, B());
assert(r == bp + 2);
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
index 3816a2528688..57438e9cb0d5 100644
--- a/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp
@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
// <memory>
// template <class ForwardIterator, class T>
@@ -18,13 +17,21 @@
#include <memory>
#include <cassert>
+#include "test_macros.h"
+
struct B
{
static int count_;
static int population_;
int data_;
explicit B() : data_(1) { ++population_; }
- B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_; ++population_; }
+ B(const B &b) {
+ ++count_;
+ if (count_ == 3)
+ TEST_THROW(1);
+ data_ = b.data_;
+ ++population_;
+ }
~B() {data_ = 0; --population_; }
};
@@ -48,6 +55,7 @@ int main()
char pool[sizeof(B)*N] = {0};
B* bp = (B*)pool;
assert(B::population_ == 0);
+#ifndef TEST_HAS_NO_EXCEPTIONS
try
{
std::uninitialized_fill(bp, bp+N, B());
@@ -57,6 +65,7 @@ int main()
{
assert(B::population_ == 0);
}
+#endif
B::count_ = 0;
std::uninitialized_fill(bp, bp+2, B());
for (int i = 0; i < 2; ++i)
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move.pass.cpp
new file mode 100644
index 000000000000..d7a9542b4c27
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move.pass.cpp
@@ -0,0 +1,114 @@
+//===----------------------------------------------------------------------===//
+//
+// 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, c++11, c++14
+
+// <memory>
+
+// template <class InputIt, class ForwardIt>
+// ForwardIt uninitialized_move(InputIt, InputIt, ForwardIt);
+
+#include <memory>
+#include <cstdlib>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_iterators.h"
+
+struct Counted {
+ static int count;
+ static int constructed;
+ static void reset() { count = constructed = 0; }
+ explicit Counted(int&& x) : value(x) { x = 0; ++count; ++constructed; }
+ Counted(Counted const&) { assert(false); }
+ ~Counted() { assert(count > 0); --count; }
+ friend void operator&(Counted) = delete;
+ int value;
+};
+int Counted::count = 0;
+int Counted::constructed = 0;
+
+struct ThrowsCounted {
+ static int count;
+ static int constructed;
+ static int throw_after;
+ static void reset() { throw_after = count = constructed = 0; }
+ explicit ThrowsCounted(int&& x) {
+ ++constructed;
+ if (throw_after > 0 && --throw_after == 0) {
+ TEST_THROW(1);
+ }
+ ++count;
+ x = 0;
+ }
+ ThrowsCounted(ThrowsCounted const&) { assert(false); }
+ ~ThrowsCounted() { assert(count > 0); --count; }
+ friend void operator&(ThrowsCounted) = delete;
+};
+int ThrowsCounted::count = 0;
+int ThrowsCounted::constructed = 0;
+int ThrowsCounted::throw_after = 0;
+
+void test_ctor_throws()
+{
+#ifndef TEST_HAS_NO_EXCEPTIONS
+ using It = forward_iterator<ThrowsCounted*>;
+ const int N = 5;
+ int values[N] = {1, 2, 3, 4, 5};
+ alignas(ThrowsCounted) char pool[sizeof(ThrowsCounted)*N] = {};
+ ThrowsCounted* p = (ThrowsCounted*)pool;
+ try {
+ ThrowsCounted::throw_after = 4;
+ std::uninitialized_move(values, values + N, It(p));
+ assert(false);
+ } catch (...) {}
+ assert(ThrowsCounted::count == 0);
+ assert(ThrowsCounted::constructed == 4); // forth construction throws
+ assert(values[0] == 0);
+ assert(values[1] == 0);
+ assert(values[2] == 0);
+ assert(values[3] == 4);
+ assert(values[4] == 5);
+#endif
+}
+
+void test_counted()
+{
+ using It = input_iterator<int*>;
+ using FIt = forward_iterator<Counted*>;
+ const int N = 5;
+ int values[N] = {1, 2, 3, 4, 5};
+ alignas(Counted) char pool[sizeof(Counted)*N] = {};
+ Counted* p = (Counted*)pool;
+ auto ret = std::uninitialized_move(It(values), It(values + 1), FIt(p));
+ assert(ret == FIt(p +1));
+ assert(Counted::constructed = 1);
+ assert(Counted::count == 1);
+ assert(p[0].value == 1);
+ assert(values[0] == 0);
+ ret = std::uninitialized_move(It(values+1), It(values+N), FIt(p+1));
+ assert(ret == FIt(p + N));
+ assert(Counted::count == 5);
+ assert(Counted::constructed == 5);
+ assert(p[1].value == 2);
+ assert(p[2].value == 3);
+ assert(p[3].value == 4);
+ assert(p[4].value == 5);
+ assert(values[1] == 0);
+ assert(values[2] == 0);
+ assert(values[3] == 0);
+ assert(values[4] == 0);
+ std::destroy(p, p+N);
+ assert(Counted::count == 0);
+}
+
+int main() {
+ test_counted();
+ test_ctor_throws();
+} \ No newline at end of file
diff --git a/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move_n.pass.cpp b/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move_n.pass.cpp
new file mode 100644
index 000000000000..f27e5726135f
--- /dev/null
+++ b/test/std/utilities/memory/specialized.algorithms/uninitialized.move/uninitialized_move_n.pass.cpp
@@ -0,0 +1,117 @@
+//===----------------------------------------------------------------------===//
+//
+// 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, c++11, c++14
+
+// <memory>
+
+// template <class InputIt, class Size, class ForwardIt>
+// pair<InputIt, ForwardIt> uninitialized_move_n(InputIt, Size, ForwardIt);
+
+#include <memory>
+#include <cstdlib>
+#include <cassert>
+
+#include "test_macros.h"
+#include "test_iterators.h"
+
+struct Counted {
+ static int count;
+ static int constructed;
+ static void reset() { count = constructed = 0; }
+ explicit Counted(int&& x) : value(x) { x = 0; ++count; ++constructed; }
+ Counted(Counted const&) { assert(false); }
+ ~Counted() { assert(count > 0); --count; }
+ friend void operator&(Counted) = delete;
+ int value;
+};
+int Counted::count = 0;
+int Counted::constructed = 0;
+
+struct ThrowsCounted {
+ static int count;
+ static int constructed;
+ static int throw_after;
+ static void reset() { throw_after = count = constructed = 0; }
+ explicit ThrowsCounted(int&& x) {
+ ++constructed;
+ if (throw_after > 0 && --throw_after == 0) {
+ TEST_THROW(1);
+ }
+ ++count;
+ x = 0;
+ }
+ ThrowsCounted(ThrowsCounted const&) { assert(false); }
+ ~ThrowsCounted() { assert(count > 0); --count; }
+ friend void operator&(ThrowsCounted) = delete;
+};
+int ThrowsCounted::count = 0;
+int ThrowsCounted::constructed = 0;
+int ThrowsCounted::throw_after = 0;
+
+void test_ctor_throws()
+{
+#ifndef TEST_HAS_NO_EXCEPTIONS
+ using It = forward_iterator<ThrowsCounted*>;
+ const int N = 5;
+ int values[N] = {1, 2, 3, 4, 5};
+ alignas(ThrowsCounted) char pool[sizeof(ThrowsCounted)*N] = {};
+ ThrowsCounted* p = (ThrowsCounted*)pool;
+ try {
+ ThrowsCounted::throw_after = 4;
+ std::uninitialized_move_n(values, N, It(p));
+ assert(false);
+ } catch (...) {}
+ assert(ThrowsCounted::count == 0);
+ assert(ThrowsCounted::constructed == 4); // forth construction throws
+ assert(values[0] == 0);
+ assert(values[1] == 0);
+ assert(values[2] == 0);
+ assert(values[3] == 4);
+ assert(values[4] == 5);
+#endif
+}
+
+void test_counted()
+{
+ using It = input_iterator<int*>;
+ using FIt = forward_iterator<Counted*>;
+ const int N = 5;
+ int values[N] = {1, 2, 3, 4, 5};
+ alignas(Counted) char pool[sizeof(Counted)*N] = {};
+ Counted* p = (Counted*)pool;
+ auto ret = std::uninitialized_move_n(It(values), 1, FIt(p));
+ assert(ret.first == It(values +1));
+ assert(ret.second == FIt(p +1));
+ assert(Counted::constructed = 1);
+ assert(Counted::count == 1);
+ assert(p[0].value == 1);
+ assert(values[0] == 0);
+ ret = std::uninitialized_move_n(It(values+1), N-1, FIt(p+1));
+ assert(ret.first == It(values+N));
+ assert(ret.second == FIt(p + N));
+ assert(Counted::count == 5);
+ assert(Counted::constructed == 5);
+ assert(p[1].value == 2);
+ assert(p[2].value == 3);
+ assert(p[3].value == 4);
+ assert(p[4].value == 5);
+ assert(values[1] == 0);
+ assert(values[2] == 0);
+ assert(values[3] == 0);
+ assert(values[4] == 0);
+ std::destroy(p, p+N);
+ assert(Counted::count == 0);
+}
+
+int main()
+{
+ test_counted();
+ test_ctor_throws();
+} \ No newline at end of file
diff --git a/test/std/utilities/memory/storage.iterator/raw_storage_iterator.pass.cpp b/test/std/utilities/memory/storage.iterator/raw_storage_iterator.pass.cpp
index 914802423ce7..3df8dd0eded0 100644
--- a/test/std/utilities/memory/storage.iterator/raw_storage_iterator.pass.cpp
+++ b/test/std/utilities/memory/storage.iterator/raw_storage_iterator.pass.cpp
@@ -13,6 +13,7 @@
#include <type_traits>
#include <cassert>
+#include "test_macros.h"
#include <MoveOnly.h>
int A_constructed = 0;
@@ -46,7 +47,7 @@ int main()
assert(A_constructed == i+1);
}
}
-#if _LIBCPP_STD_VER >= 14
+#if TEST_STD_VER >= 14
{
typedef MoveOnly S;
typedef std::aligned_storage<3*sizeof(S), std::alignment_of<S>::value>::type
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp
index a611b1a12f05..2949d6310c59 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.pass.cpp
@@ -24,4 +24,5 @@ int main()
{
std::default_delete<int[]> d1;
std::default_delete<const int[]> d2 = d1;
+ ((void)d2);
}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp
index 6d752b9951a5..50389978e8ab 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp
@@ -16,6 +16,8 @@
#include <memory>
#include <cassert>
+#include "test_macros.h"
+
class Deleter
{
int state_;
@@ -36,9 +38,18 @@ int main()
Deleter d;
assert(d.state() == 0);
{
+ std::unique_ptr<int[], Deleter&> p(nullptr, d);
+ assert(p.get() == 0);
+ assert(&p.get_deleter() == &d);
+ }
+#if defined(_LIBCPP_VERSION)
+ {
+ // The standard only requires the constructor accept nullptr, but libc++
+ // also supports the literal 0.
std::unique_ptr<int[], Deleter&> p(0, d);
assert(p.get() == 0);
assert(&p.get_deleter() == &d);
}
+#endif
assert(d.state() == 0);
}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp
index 5720d3bd288f..89b6fa248845 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp
@@ -38,7 +38,7 @@ source1()
return std::unique_ptr<A[]>(new A[3]);
}
-void sink1(std::unique_ptr<A[]> p)
+void sink1(std::unique_ptr<A[]>)
{
}
@@ -48,7 +48,7 @@ source2()
return std::unique_ptr<A[], Deleter<A[]> >(new A[3]);
}
-void sink2(std::unique_ptr<A[], Deleter<A[]> > p)
+void sink2(std::unique_ptr<A[], Deleter<A[]> >)
{
}
@@ -59,7 +59,7 @@ source3()
return std::unique_ptr<A[], NCDeleter<A[]>&>(new A[3], d);
}
-void sink3(std::unique_ptr<A[], NCDeleter<A[]>&> p)
+void sink3(std::unique_ptr<A[], NCDeleter<A[]>&>)
{
}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp
index 2b0b5f0d945d..3de556563f97 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp
@@ -42,7 +42,9 @@ int main()
assert(A::count == 0);
{ // LWG#2520 says that nullptr is a valid input as well as null
+#ifdef _LIBCPP_VERSION
std::unique_ptr<A[], Deleter<A[]> > s1(NULL, Deleter<A[]>());
+#endif
std::unique_ptr<A[], Deleter<A[]> > s2(nullptr, Deleter<A[]>());
}
assert(A::count == 0);
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp
index e14bba0763c5..016eadcb2460 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <memory>
// unique_ptr
@@ -46,17 +48,10 @@ template <class T>
class Deleter
{
int state_;
-
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Deleter(const Deleter&);
Deleter& operator=(const Deleter&);
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- Deleter(Deleter&);
- Deleter& operator=(Deleter&);
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
public:
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
Deleter& operator=(Deleter&& r)
{
@@ -64,20 +59,9 @@ public:
r.state_ = 0;
return *this;
}
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
- Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
- Deleter& operator=(std::__rv<Deleter> r)
- {
- state_ = r->state_;
- r->state_ = 0;
- return *this;
- }
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Deleter() : state_(5) {}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class U>
Deleter(Deleter<U>&& d,
typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
@@ -87,12 +71,7 @@ private:
template <class U>
Deleter(const Deleter<U>& d,
typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- template <class U>
- Deleter(Deleter<U> d,
- typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
- : state_(d.state()) {}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
public:
int state() const {return state_;}
void set_state(int i) {state_ = i;}
@@ -102,17 +81,6 @@ public:
int main()
{
- {
- const std::unique_ptr<B, Deleter<B> > s(new B);
- A* p = s.get();
- std::unique_ptr<A, Deleter<A> > s2(s);
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- assert(B::count == 1);
- assert(s2.get_deleter().state() == 5);
- assert(s.get_deleter().state() == 0);
- }
- assert(A::count == 0);
- assert(B::count == 0);
+ const std::unique_ptr<B, Deleter<B> > s;
+ std::unique_ptr<A, Deleter<A> > s2(s); // expected-error {{no matching constructor}}
}
diff --git a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp
index bcf94a978144..1b8bb736df20 100644
--- a/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp
+++ b/test/std/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <memory>
// unique_ptr
@@ -47,16 +49,9 @@ class Deleter
{
int state_;
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Deleter(const Deleter&);
Deleter& operator=(const Deleter&);
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- Deleter(Deleter&);
- Deleter& operator=(Deleter&);
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
-
public:
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
Deleter(Deleter&& r) : state_(r.state_) {r.state_ = 0;}
Deleter& operator=(Deleter&& r)
{
@@ -64,20 +59,9 @@ public:
r.state_ = 0;
return *this;
}
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- operator std::__rv<Deleter>() {return std::__rv<Deleter>(*this);}
- Deleter(std::__rv<Deleter> r) : state_(r->state_) {r->state_ = 0;}
- Deleter& operator=(std::__rv<Deleter> r)
- {
- state_ = r->state_;
- r->state_ = 0;
- return *this;
- }
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
Deleter() : state_(5) {}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
template <class U>
Deleter(Deleter<U>&& d,
typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
@@ -87,12 +71,7 @@ private:
template <class U>
Deleter(const Deleter<U>& d,
typename std::enable_if<!std::is_same<U, T>::value>::type* = 0);
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
- template <class U>
- Deleter(Deleter<U> d,
- typename std::enable_if<!std::is_same<U, T>::value>::type* = 0)
- : state_(d.state()) {}
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+
public:
int state() const {return state_;}
void set_state(int i) {state_ = i;}
@@ -102,17 +81,6 @@ public:
int main()
{
- {
- const std::unique_ptr<B, Deleter<B> > s(new B);
- A* p = s.get();
- std::unique_ptr<A, Deleter<A> > s2 = s;
- assert(s2.get() == p);
- assert(s.get() == 0);
- assert(A::count == 1);
- assert(B::count == 1);
- assert(s2.get_deleter().state() == 5);
- assert(s.get_deleter().state() == 0);
- }
- assert(A::count == 0);
- assert(B::count == 0);
+ const std::unique_ptr<B, Deleter<B> > s;
+ std::unique_ptr<A, Deleter<A> > s2 = s; // expected-error {{no viable conversion}}
}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp
index 93956bcae663..20275de603e2 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <memory>
// shared_ptr
@@ -42,7 +44,6 @@ int A::count = 0;
int main()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::shared_ptr<A> pA(new A);
A* ptrA = pA.get();
@@ -119,5 +120,4 @@ int main()
}
assert(B::count == 0);
assert(A::count == 0);
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp
index 4194890dda2d..4a85633a89ad 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <memory>
// shared_ptr
@@ -42,7 +44,6 @@ int A::count = 0;
int main()
{
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
{
std::shared_ptr<A> pA(new A);
A* ptrA = pA.get();
@@ -119,5 +120,4 @@ int main()
}
assert(B::count == 0);
assert(A::count == 0);
-#endif // _LIBCXX_HAS_NO_RVALUE_REFERENCES
}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
index 41aeb04a5feb..2e6441d66316 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
// <memory>
// template<class D, class A> shared_ptr(nullptr_t, D d, A a);
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
index 85fc5e930544..009b4cfc00f9 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
// UNSUPPORTED: sanitizer-new-delete
// <memory>
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
index c72847791778..388599bd7015 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
// <memory>
// template<class Y, class D, class A> shared_ptr(Y* p, D d, A a);
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
index 70af2964113d..7b40d6df2164 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
// UNSUPPORTED: sanitizer-new-delete
// <memory>
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp
index 2fa975eca833..182d5f4a4937 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp
@@ -7,7 +7,7 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
+// UNSUPPORTED: libcpp-no-exceptions
// UNSUPPORTED: sanitizer-new-delete
// <memory>
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp
index f041d9451a6d..ea0720404b48 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <memory>
// shared_ptr
@@ -17,6 +19,8 @@
#include <type_traits>
#include <cassert>
+#include "test_macros.h"
+
struct B
{
static int count;
@@ -66,24 +70,24 @@ int main()
std::shared_ptr<B> pB(std::move(pA));
assert(B::count == 1);
assert(A::count == 1);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if TEST_STD_VER >= 11
assert(pB.use_count() == 1);
assert(pA.use_count() == 0);
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#else
assert(pB.use_count() == 2);
assert(pA.use_count() == 2);
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
assert(p == pB.get());
}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if TEST_STD_VER >= 11
assert(pA.use_count() == 0);
assert(B::count == 0);
assert(A::count == 0);
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#else
assert(pA.use_count() == 1);
assert(B::count == 1);
assert(A::count == 1);
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
}
assert(B::count == 0);
assert(A::count == 0);
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp
index b89178e201cf..257d3ce19be3 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp
@@ -7,6 +7,8 @@
//
//===----------------------------------------------------------------------===//
+// UNSUPPORTED: c++98, c++03
+
// <memory>
// shared_ptr
@@ -16,6 +18,8 @@
#include <memory>
#include <cassert>
+#include "test_macros.h"
+
struct A
{
static int count;
@@ -37,22 +41,22 @@ int main()
A* p = pA.get();
std::shared_ptr<A> pA2(std::move(pA));
assert(A::count == 1);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if TEST_STD_VER >= 11
assert(pA.use_count() == 0);
assert(pA2.use_count() == 1);
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#else
assert(pA.use_count() == 2);
assert(pA2.use_count() == 2);
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
assert(pA2.get() == p);
}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if TEST_STD_VER >= 11
assert(pA.use_count() == 0);
assert(A::count == 0);
-#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#else
assert(pA.use_count() == 1);
assert(A::count == 1);
-#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#endif
}
assert(A::count == 0);
{
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
index 5c424f5c7428..877577c9ce58 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp
@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
// UNSUPPORTED: sanitizer-new-delete
// <memory>
@@ -63,6 +62,7 @@ int main()
assert(p.get() == raw_ptr);
assert(ptr.get() == 0);
}
+#ifndef TEST_HAS_NO_EXCEPTIONS
assert(A::count == 0);
{
std::unique_ptr<A> ptr(new A);
@@ -86,6 +86,7 @@ int main()
#endif
}
}
+#endif
assert(A::count == 0);
{ // LWG 2399
fn(std::unique_ptr<int>(new int));
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
index 35a7d077b424..830aa5bbca4c 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp
@@ -7,7 +7,6 @@
//
//===----------------------------------------------------------------------===//
-// XFAIL: libcpp-no-exceptions
// <memory>
// shared_ptr
@@ -17,6 +16,8 @@
#include <memory>
#include <cassert>
+#include "test_macros.h"
+
struct B
{
static int count;
@@ -42,6 +43,7 @@ int A::count = 0;
int main()
{
+#ifndef TEST_HAS_NO_EXCEPTIONS
{
std::weak_ptr<A> wp;
try
@@ -54,6 +56,7 @@ int main()
}
assert(A::count == 0);
}
+#endif
{
std::shared_ptr<A> sp0(new A);
std::weak_ptr<A> wp(sp0);
@@ -63,6 +66,7 @@ int main()
assert(A::count == 1);
}
assert(A::count == 0);
+#ifndef TEST_HAS_NO_EXCEPTIONS
{
std::shared_ptr<A> sp0(new A);
std::weak_ptr<A> wp(sp0);
@@ -77,4 +81,5 @@ int main()
}
}
assert(A::count == 0);
+#endif
}
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
index 8cb972b0c1a1..8d782716b94f 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp
@@ -16,6 +16,7 @@
#include <memory>
#include <cassert>
+#include "test_macros.h"
#include "count_new.hpp"
struct A
@@ -65,7 +66,7 @@ int main()
assert(p2.get());
}
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if TEST_STD_VER >= 11
nc = globalMemCounter.outstanding_new;
{
char c = 'e';
diff --git a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp
index 75bf3df90aa3..90f958e26852 100644
--- a/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp
+++ b/test/std/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp
@@ -18,6 +18,8 @@
#include <type_traits>
#include <cassert>
+#include "test_macros.h"
+
struct B
{
static int count;
@@ -55,7 +57,7 @@ int C::count = 0;
template <class T>
std::weak_ptr<T> source (std::shared_ptr<T> p) { return std::weak_ptr<T>(p); }
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if TEST_STD_VER >= 11
template <class T>
void sink (std::weak_ptr<T> &&) {}
#endif
@@ -100,7 +102,7 @@ int main()
assert(B::count == 0);
assert(A::count == 0);
-#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES
+#if TEST_STD_VER >= 11
{
std::shared_ptr<A> ps(new A);
std::weak_ptr<A> pA = source(ps);