diff options
| author | Eric Fiselier <eric@efcs.ca> | 2014-12-20 01:40:03 +0000 |
|---|---|---|
| committer | Eric Fiselier <eric@efcs.ca> | 2014-12-20 01:40:03 +0000 |
| commit | 5a83710e371fe68a06e6e3876c6a2c8b820a8976 (patch) | |
| tree | afde4c82ad6704681781c5cd49baa3fbd05c85db /libcxx/test/utilities/memory | |
| parent | f11e8eab527fba316c64112f6e05de1a79693a3e (diff) | |
| download | bcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.tar.gz bcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.zip | |
Move test into test/std subdirectory.
llvm-svn: 224658
Diffstat (limited to 'libcxx/test/utilities/memory')
310 files changed, 0 insertions, 17003 deletions
diff --git a/libcxx/test/utilities/memory/allocator.tag/allocator_arg.pass.cpp b/libcxx/test/utilities/memory/allocator.tag/allocator_arg.pass.cpp deleted file mode 100644 index 636998aa0d7..00000000000 --- a/libcxx/test/utilities/memory/allocator.tag/allocator_arg.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// struct allocator_arg_t { }; -// const allocator_arg_t allocator_arg = allocator_arg_t(); - -#include <memory> - -void test(std::allocator_arg_t) {} - -int main() -{ - test(std::allocator_arg); -} diff --git a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp deleted file mode 100644 index 490fdf5d332..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp +++ /dev/null @@ -1,38 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// static pointer allocate(allocator_type& a, size_type n); -// ... -// }; - -#include <memory> -#include <cassert> - -template <class T> -struct A -{ - typedef T value_type; - - value_type* allocate(std::size_t n) - { - assert(n == 10); - return (value_type*)0xDEADBEEF; - } -}; - -int main() -{ - A<int> a; - assert(std::allocator_traits<A<int> >::allocate(a, 10) == (int*)0xDEADBEEF); -} diff --git a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp deleted file mode 100644 index 079db3526ac..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// static pointer allocate(allocator_type& a, size_type n, const_void_pointer hint); -// ... -// }; - -#include <memory> -#include <cassert> - -template <class T> -struct A -{ - typedef T value_type; - - value_type* allocate(std::size_t n) - { - assert(n == 10); - return (value_type*)0xDEADBEEF; - } -}; - -template <class T> -struct B -{ - typedef T value_type; - - value_type* allocate(std::size_t n) - { - assert(n == 12); - return (value_type*)0xEEADBEEF; - } - value_type* allocate(std::size_t n, const void* p) - { - assert(n == 11); - assert(p == 0); - return (value_type*)0xFEADBEEF; - } -}; - -int main() -{ -#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE - A<int> a; - assert(std::allocator_traits<A<int> >::allocate(a, 10, nullptr) == (int*)0xDEADBEEF); -#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE - B<int> b; - assert(std::allocator_traits<B<int> >::allocate(b, 11, nullptr) == (int*)0xFEADBEEF); -} diff --git a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp deleted file mode 100644 index 634019758e7..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp +++ /dev/null @@ -1,143 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// template <class Ptr, class... Args> -// static void construct(allocator_type& a, Ptr p, Args&&... args); -// ... -// }; - -#include <memory> -#include <new> -#include <type_traits> -#include <cassert> - -template <class T> -struct A -{ - typedef T value_type; - -}; - -int b_construct = 0; - -template <class T> -struct B -{ - typedef T value_type; - -#ifndef _LIBCPP_HAS_NO_VARIADICS - 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 -}; - -struct A0 -{ - static int count; - A0() {++count;} -}; - -int A0::count = 0; - -struct A1 -{ - static int count; - A1(char c) - { - assert(c == 'c'); - ++count; - } -}; - -int A1::count = 0; - -struct A2 -{ - static int count; - A2(char c, int i) - { - assert(c == 'd'); - assert(i == 5); - ++count; - } -}; - -int A2::count = 0; - -int main() -{ - { - A0::count = 0; - A<int> a; - std::aligned_storage<sizeof(A0)>::type a0; - assert(A0::count == 0); - std::allocator_traits<A<int> >::construct(a, (A0*)&a0); - assert(A0::count == 1); - } - { - A1::count = 0; - A<int> a; - std::aligned_storage<sizeof(A1)>::type a1; - assert(A1::count == 0); - std::allocator_traits<A<int> >::construct(a, (A1*)&a1, 'c'); - assert(A1::count == 1); - } - { - A2::count = 0; - A<int> a; - std::aligned_storage<sizeof(A2)>::type a2; - assert(A2::count == 0); - std::allocator_traits<A<int> >::construct(a, (A2*)&a2, 'd', 5); - assert(A2::count == 1); - } -#ifndef _LIBCPP_HAS_NO_VARIADICS - { - A0::count = 0; - b_construct = 0; - B<int> b; - std::aligned_storage<sizeof(A0)>::type a0; - assert(A0::count == 0); - assert(b_construct == 0); - std::allocator_traits<B<int> >::construct(b, (A0*)&a0); - assert(A0::count == 1); - assert(b_construct == 1); - } - { - A1::count = 0; - b_construct = 0; - B<int> b; - std::aligned_storage<sizeof(A1)>::type a1; - assert(A1::count == 0); - assert(b_construct == 0); - std::allocator_traits<B<int> >::construct(b, (A1*)&a1, 'c'); - assert(A1::count == 1); - assert(b_construct == 1); - } - { - A2::count = 0; - b_construct = 0; - B<int> b; - std::aligned_storage<sizeof(A2)>::type a2; - assert(A2::count == 0); - assert(b_construct == 0); - std::allocator_traits<B<int> >::construct(b, (A2*)&a2, 'd', 5); - assert(A2::count == 1); - assert(b_construct == 1); - } -#endif // _LIBCPP_HAS_NO_VARIADICS -} diff --git a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp deleted file mode 100644 index b137dc6d36c..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp +++ /dev/null @@ -1,42 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// static void deallocate(allocator_type& a, pointer p, size_type n); -// ... -// }; - -#include <memory> -#include <cassert> - -int called = 0; - -template <class T> -struct A -{ - typedef T value_type; - - void deallocate(value_type* p, std::size_t n) - { - assert(p == (value_type*)0xDEADBEEF); - assert(n == 10); - ++called; - } -}; - -int main() -{ - A<int> a; - std::allocator_traits<A<int> >::deallocate(a, (int*)0xDEADBEEF, 10); - assert(called == 1); -} diff --git a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp deleted file mode 100644 index 54726c929ef..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp +++ /dev/null @@ -1,80 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// template <class Ptr> -// static void destroy(allocator_type& a, Ptr p); -// ... -// }; - -#include <memory> -#include <new> -#include <type_traits> -#include <cassert> - -template <class T> -struct A -{ - typedef T value_type; - -}; - -int b_destroy = 0; - -template <class T> -struct B -{ - typedef T value_type; - - template <class U> - void destroy(U* p) - { - ++b_destroy; - p->~U(); - } -}; - -struct A0 -{ - static int count; - ~A0() {++count;} -}; - -int A0::count = 0; - -int main() -{ - { - A0::count = 0; - A<int> a; - std::aligned_storage<sizeof(A0)>::type a0; - std::allocator_traits<A<int> >::construct(a, (A0*)&a0); - assert(A0::count == 0); - std::allocator_traits<A<int> >::destroy(a, (A0*)&a0); - assert(A0::count == 1); - } -#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE - { - A0::count = 0; - b_destroy = 0; - B<int> b; - std::aligned_storage<sizeof(A0)>::type a0; - std::allocator_traits<B<int> >::construct(b, (A0*)&a0); - assert(A0::count == 0); - assert(b_destroy == 0); - std::allocator_traits<B<int> >::destroy(b, (A0*)&a0); - assert(A0::count == 1); - assert(b_destroy == 1); - } -#endif // _LIBCPP_HAS_NO_ADVANCED_SFINAE -} diff --git a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp deleted file mode 100644 index 1fa7291203e..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp +++ /dev/null @@ -1,70 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// static size_type max_size(const allocator_type& a) noexcept; -// ... -// }; - -#include <memory> -#include <new> -#include <type_traits> -#include <cassert> - -template <class T> -struct A -{ - typedef T value_type; - -}; - -template <class T> -struct B -{ - typedef T value_type; - - size_t max_size() const - { - return 100; - } -}; - -int main() -{ -#ifndef _LIBCPP_HAS_NO_ADVANCED_SFINAE - { - A<int> a; - assert(std::allocator_traits<A<int> >::max_size(a) == - std::numeric_limits<std::size_t>::max()); - } - { - const A<int> a = {}; - assert(std::allocator_traits<A<int> >::max_size(a) == - std::numeric_limits<std::size_t>::max()); - } -#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 __cplusplus >= 201103 - { - std::allocator<int> a; - static_assert(noexcept(std::allocator_traits<std::allocator<int>>::max_size(a)) == true, ""); - } -#endif -} diff --git a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp deleted file mode 100644 index 29fe2be126f..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp +++ /dev/null @@ -1,68 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// static allocator_type -// select_on_container_copy_construction(const allocator_type& a); -// ... -// }; - -#include <memory> -#include <new> -#include <type_traits> -#include <cassert> - -template <class T> -struct A -{ - typedef T value_type; - int id; - explicit A(int i = 0) : id(i) {} - -}; - -template <class T> -struct B -{ - typedef T value_type; - - int id; - explicit B(int i = 0) : id(i) {} - - B select_on_container_copy_construction() const - { - return B(100); - } -}; - -int main() -{ - { - A<int> a; - assert(std::allocator_traits<A<int> >::select_on_container_copy_construction(a).id == 0); - } - { - 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 - { - B<int> b; - assert(std::allocator_traits<B<int> >::select_on_container_copy_construction(b).id == 100); - } - { - 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 -} diff --git a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp deleted file mode 100644 index 20348d20c10..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp +++ /dev/null @@ -1,55 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// typedef Alloc::const_pointer -// | pointer_traits<pointer>::rebind<const value_type> -// ... -// }; - -#include <memory> -#include <type_traits> - -template <class T> -struct Ptr {}; - -template <class T> -struct A -{ - typedef T value_type; - typedef Ptr<T> pointer; -}; - -template <class T> -struct B -{ - typedef T value_type; -}; - -template <class T> -struct CPtr {}; - -template <class T> -struct C -{ - typedef T value_type; - typedef CPtr<T> pointer; - typedef CPtr<const T> const_pointer; -}; - -int main() -{ - static_assert((std::is_same<std::allocator_traits<A<char> >::const_pointer, Ptr<const char> >::value), ""); - static_assert((std::is_same<std::allocator_traits<B<char> >::const_pointer, const char*>::value), ""); - static_assert((std::is_same<std::allocator_traits<C<char> >::const_pointer, CPtr<const char> >::value), ""); -} diff --git a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp deleted file mode 100644 index 4b4045a51ba..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp +++ /dev/null @@ -1,55 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// typedef Alloc::const_void_pointer -// | pointer_traits<pointer>::rebind<const void> -// const_void_pointer; -// ... -// }; - -#include <memory> -#include <type_traits> - -template <class T> -struct Ptr {}; - -template <class T> -struct A -{ - typedef T value_type; - typedef Ptr<T> pointer; -}; - -template <class T> -struct B -{ - typedef T value_type; -}; - -template <class T> -struct CPtr {}; - -template <class T> -struct C -{ - typedef T value_type; - typedef CPtr<const void> const_void_pointer; -}; - -int main() -{ - static_assert((std::is_same<std::allocator_traits<A<char> >::const_void_pointer, Ptr<const void> >::value), ""); - static_assert((std::is_same<std::allocator_traits<B<char> >::const_void_pointer, const void*>::value), ""); - static_assert((std::is_same<std::allocator_traits<C<char> >::const_void_pointer, CPtr<const void> >::value), ""); -} diff --git a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp deleted file mode 100644 index 085c911b070..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp +++ /dev/null @@ -1,62 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// typedef Alloc::difference_type -// | pointer_traits<pointer>::difference_type difference_type; -// ... -// }; - -#include <memory> -#include <type_traits> - -template <class T> -struct A -{ - typedef T value_type; - typedef short difference_type; -}; - -template <class T> -struct B -{ - typedef T value_type; -}; - -template <class T> -struct C -{ - typedef T value_type; - struct pointer {}; - struct const_pointer {}; - struct void_pointer {}; - struct const_void_pointer {}; -}; - -namespace std -{ - -template <> -struct pointer_traits<C<char>::pointer> -{ - typedef signed char difference_type; -}; - -} - -int main() -{ - static_assert((std::is_same<std::allocator_traits<A<char> >::difference_type, short>::value), ""); - static_assert((std::is_same<std::allocator_traits<B<char> >::difference_type, std::ptrdiff_t>::value), ""); - static_assert((std::is_same<std::allocator_traits<C<char> >::difference_type, signed char>::value), ""); -} diff --git a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp deleted file mode 100644 index 60ba0949934..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp +++ /dev/null @@ -1,42 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// typedef Alloc::pointer | value_type* pointer; -// ... -// }; - -#include <memory> -#include <type_traits> - -template <class T> -struct Ptr {}; - -template <class T> -struct A -{ - typedef T value_type; - typedef Ptr<T> pointer; -}; - -template <class T> -struct B -{ - typedef T value_type; -}; - -int main() -{ - static_assert((std::is_same<std::allocator_traits<A<char> >::pointer, Ptr<char> >::value), ""); - static_assert((std::is_same<std::allocator_traits<B<char> >::pointer, char*>::value), ""); -} diff --git a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp deleted file mode 100644 index 604e890efaa..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp +++ /dev/null @@ -1,40 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// typedef Alloc::propagate_on_container_copy_assignment -// | false_type propagate_on_container_copy_assignment; -// ... -// }; - -#include <memory> -#include <type_traits> - -template <class T> -struct A -{ - typedef T value_type; - typedef std::true_type propagate_on_container_copy_assignment; -}; - -template <class T> -struct B -{ - typedef T value_type; -}; - -int main() -{ - static_assert((std::is_same<std::allocator_traits<A<char> >::propagate_on_container_copy_assignment, std::true_type>::value), ""); - static_assert((std::is_same<std::allocator_traits<B<char> >::propagate_on_container_copy_assignment, std::false_type>::value), ""); -} diff --git a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp deleted file mode 100644 index 1d2b18686d0..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp +++ /dev/null @@ -1,40 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// typedef Alloc::propagate_on_container_move_assignment -// | false_type propagate_on_container_move_assignment; -// ... -// }; - -#include <memory> -#include <type_traits> - -template <class T> -struct A -{ - typedef T value_type; - typedef std::true_type propagate_on_container_move_assignment; -}; - -template <class T> -struct B -{ - typedef T value_type; -}; - -int main() -{ - static_assert((std::is_same<std::allocator_traits<A<char> >::propagate_on_container_move_assignment, std::true_type>::value), ""); - static_assert((std::is_same<std::allocator_traits<B<char> >::propagate_on_container_move_assignment, std::false_type>::value), ""); -} diff --git a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp deleted file mode 100644 index 6730d1ae261..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp +++ /dev/null @@ -1,40 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// typedef Alloc::propagate_on_container_swap -// | false_type propagate_on_container_swap; -// ... -// }; - -#include <memory> -#include <type_traits> - -template <class T> -struct A -{ - typedef T value_type; - typedef std::true_type propagate_on_container_swap; -}; - -template <class T> -struct B -{ - typedef T value_type; -}; - -int main() -{ - static_assert((std::is_same<std::allocator_traits<A<char> >::propagate_on_container_swap, std::true_type>::value), ""); - static_assert((std::is_same<std::allocator_traits<B<char> >::propagate_on_container_swap, std::false_type>::value), ""); -} diff --git a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp deleted file mode 100644 index 50611b99da9..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp +++ /dev/null @@ -1,79 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// template <class T> using rebind_alloc = Alloc::rebind<U>::other | Alloc<T, Args...>; -// ... -// }; - -#include <memory> -#include <type_traits> - -template <class T> -struct ReboundA {}; - -template <class T> -struct A -{ - typedef T value_type; - - template <class U> struct rebind {typedef ReboundA<U> other;}; -}; - -template <class T, class U> -struct ReboundB {}; - -template <class T, class U> -struct B -{ - typedef T value_type; - - template <class V> struct rebind {typedef ReboundB<V, U> other;}; -}; - -template <class T> -struct C -{ - typedef T value_type; -}; - -template <class T, class U> -struct D -{ - typedef T value_type; -}; - -template <class T> -struct E -{ - typedef T value_type; - - template <class U> struct rebind {typedef ReboundA<U> otter;}; -}; - -int main() -{ -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_alloc<double>, ReboundA<double> >::value), ""); - static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_alloc<double>, ReboundB<double, char> >::value), ""); - static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_alloc<double>, C<double> >::value), ""); - static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_alloc<double>, D<double, char> >::value), ""); - static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_alloc<double>, E<double> >::value), ""); -#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES - static_assert((std::is_same<std::allocator_traits<A<char> >::rebind_alloc<double>::other, ReboundA<double> >::value), ""); - static_assert((std::is_same<std::allocator_traits<B<int, char> >::rebind_alloc<double>::other, ReboundB<double, char> >::value), ""); - static_assert((std::is_same<std::allocator_traits<C<char> >::rebind_alloc<double>::other, C<double> >::value), ""); - static_assert((std::is_same<std::allocator_traits<D<int, char> >::rebind_alloc<double>::other, D<double, char> >::value), ""); - static_assert((std::is_same<std::allocator_traits<E<char> >::rebind_alloc<double>::other, E<double> >::value), ""); -#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES -} diff --git a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp deleted file mode 100644 index e9c175fe86a..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp +++ /dev/null @@ -1,63 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// typedef Alloc::size_type | size_t size_type; -// ... -// }; - -#include <memory> -#include <type_traits> - -template <class T> -struct A -{ - typedef T value_type; - typedef unsigned short size_type; -}; - -template <class T> -struct B -{ - typedef T value_type; -}; - -template <class T> -struct C -{ - typedef T value_type; - struct pointer {}; - struct const_pointer {}; - struct void_pointer {}; - struct const_void_pointer {}; -}; - -namespace std -{ - -template <> -struct pointer_traits<C<char>::pointer> -{ - typedef signed char difference_type; -}; - -} - -int main() -{ - static_assert((std::is_same<std::allocator_traits<A<char> >::size_type, unsigned short>::value), ""); - static_assert((std::is_same<std::allocator_traits<B<char> >::size_type, - std::make_unsigned<std::ptrdiff_t>::type>::value), ""); - static_assert((std::is_same<std::allocator_traits<C<char> >::size_type, - unsigned char>::value), ""); -} diff --git a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp deleted file mode 100644 index 74cd3475f66..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp +++ /dev/null @@ -1,55 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// typedef Alloc::void_pointer -// | pointer_traits<pointer>::rebind<void> -// void_pointer; -// ... -// }; - -#include <memory> -#include <type_traits> - -template <class T> -struct Ptr {}; - -template <class T> -struct A -{ - typedef T value_type; - typedef Ptr<T> pointer; -}; - -template <class T> -struct B -{ - typedef T value_type; -}; - -template <class T> -struct CPtr {}; - -template <class T> -struct C -{ - typedef T value_type; - typedef CPtr<void> void_pointer; -}; - -int main() -{ - static_assert((std::is_same<std::allocator_traits<A<char> >::void_pointer, Ptr<void> >::value), ""); - static_assert((std::is_same<std::allocator_traits<B<char> >::void_pointer, void*>::value), ""); - static_assert((std::is_same<std::allocator_traits<C<char> >::void_pointer, CPtr<void> >::value), ""); -} diff --git a/libcxx/test/utilities/memory/allocator.traits/allocator_type.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/allocator_type.pass.cpp deleted file mode 100644 index fe35ae48757..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/allocator_type.pass.cpp +++ /dev/null @@ -1,31 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// typedef Alloc allocator_type; -// ... -// }; - -#include <memory> -#include <type_traits> - -template <class T> -struct A -{ - typedef T value_type; -}; - -int main() -{ - static_assert((std::is_same<std::allocator_traits<A<char> >::allocator_type, A<char> >::value), ""); -} diff --git a/libcxx/test/utilities/memory/allocator.traits/rebind_traits.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/rebind_traits.pass.cpp deleted file mode 100644 index 87da9a0a85d..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/rebind_traits.pass.cpp +++ /dev/null @@ -1,79 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// template <class T> using rebind_traits = allocator_traits<rebind_alloc<T>>; -// ... -// }; - -#include <memory> -#include <type_traits> - -template <class T> -struct ReboundA {}; - -template <class T> -struct A -{ - typedef T value_type; - - template <class U> struct rebind {typedef ReboundA<U> other;}; -}; - -template <class T, class U> -struct ReboundB {}; - -template <class T, class U> -struct B -{ - typedef T value_type; - - template <class V> struct rebind {typedef ReboundB<V, U> other;}; -}; - -template <class T> -struct C -{ - typedef T value_type; -}; - -template <class T, class U> -struct D -{ - typedef T value_type; -}; - -template <class T> -struct E -{ - typedef T value_type; - - template <class U> struct rebind {typedef ReboundA<U> otter;}; -}; - -int main() -{ -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - 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 - 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 -} diff --git a/libcxx/test/utilities/memory/allocator.traits/value_type.pass.cpp b/libcxx/test/utilities/memory/allocator.traits/value_type.pass.cpp deleted file mode 100644 index d0c3d2c09a1..00000000000 --- a/libcxx/test/utilities/memory/allocator.traits/value_type.pass.cpp +++ /dev/null @@ -1,31 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Alloc> -// struct allocator_traits -// { -// typedef typename Alloc::value_type value_type; -// ... -// }; - -#include <memory> -#include <type_traits> - -template <class T> -struct A -{ - typedef T value_type; -}; - -int main() -{ - static_assert((std::is_same<std::allocator_traits<A<char> >::value_type, char>::value), ""); -} diff --git a/libcxx/test/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp b/libcxx/test/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp deleted file mode 100644 index b58f5c55b64..00000000000 --- a/libcxx/test/utilities/memory/allocator.uses/allocator.uses.construction/tested_elsewhere.pass.cpp +++ /dev/null @@ -1,12 +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. -// -//===----------------------------------------------------------------------===// - -int main() -{ -} diff --git a/libcxx/test/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp b/libcxx/test/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp deleted file mode 100644 index 0477d9912e6..00000000000 --- a/libcxx/test/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp +++ /dev/null @@ -1,33 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class T, class Alloc> struct uses_allocator; - -#include <memory> -#include <vector> - -struct A -{ -}; - -struct B -{ - typedef int allocator_type; -}; - -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), ""); -} diff --git a/libcxx/test/utilities/memory/allocator.uses/nothing_to_do.pass.cpp b/libcxx/test/utilities/memory/allocator.uses/nothing_to_do.pass.cpp deleted file mode 100644 index b58f5c55b64..00000000000 --- a/libcxx/test/utilities/memory/allocator.uses/nothing_to_do.pass.cpp +++ /dev/null @@ -1,12 +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. -// -//===----------------------------------------------------------------------===// - -int main() -{ -} diff --git a/libcxx/test/utilities/memory/c.malloc/nothing_to_do.pass.cpp b/libcxx/test/utilities/memory/c.malloc/nothing_to_do.pass.cpp deleted file mode 100644 index a7180633006..00000000000 --- a/libcxx/test/utilities/memory/c.malloc/nothing_to_do.pass.cpp +++ /dev/null @@ -1,14 +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. -// -//===----------------------------------------------------------------------===// - -// <cstdlib> and <cstring> are already tested elsewhere - -int main() -{ -} diff --git a/libcxx/test/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp b/libcxx/test/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp deleted file mode 100644 index 8ce49b90d48..00000000000 --- a/libcxx/test/utilities/memory/default.allocator/allocator.globals/eq.pass.cpp +++ /dev/null @@ -1,31 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// allocator: - -// template <class T1, class T2> -// bool -// operator==(const allocator<T1>&, const allocator<T2>&) throw(); -// -// template <class T1, class T2> -// bool -// operator!=(const allocator<T1>&, const allocator<T2>&) throw(); - -#include <memory> -#include <cassert> - -int main() -{ - std::allocator<int> a1; - std::allocator<int> a2; - assert(a1 == a2); - assert(!(a1 != a2)); -} diff --git a/libcxx/test/utilities/memory/default.allocator/allocator.members/address.pass.cpp b/libcxx/test/utilities/memory/default.allocator/allocator.members/address.pass.cpp deleted file mode 100644 index 04534f24d50..00000000000 --- a/libcxx/test/utilities/memory/default.allocator/allocator.members/address.pass.cpp +++ /dev/null @@ -1,39 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// allocator: -// pointer address(reference x) const; -// const_pointer address(const_reference x) const; - -#include <memory> -#include <cassert> - -template <class T> -void test_address() -{ - T* tp = new T(); - const T* ctp = tp; - const std::allocator<T> a; - assert(a.address(*tp) == tp); - assert(a.address(*ctp) == tp); - delete tp; -} - -struct A -{ - void operator&() const {} -}; - -int main() -{ - test_address<int>(); - test_address<A>(); -} diff --git a/libcxx/test/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp b/libcxx/test/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp deleted file mode 100644 index a4a84e877dc..00000000000 --- a/libcxx/test/utilities/memory/default.allocator/allocator.members/allocate.pass.cpp +++ /dev/null @@ -1,65 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// allocator: -// pointer allocate(size_type n, allocator<void>::const_pointer hint=0); - -// UNSUPPORTED: asan, msan - -#include <memory> -#include <new> -#include <cstdlib> -#include <cassert> - -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - assert(s == 3 * sizeof(int)); - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} - -int A_constructed = 0; - -struct A -{ - int data; - A() {++A_constructed;} - A(const A&) {++A_constructed;} - ~A() {--A_constructed;} -}; - -int main() -{ - std::allocator<A> a; - assert(new_called == 0); - assert(A_constructed == 0); - A* ap = a.allocate(3); - assert(new_called == 1); - assert(A_constructed == 0); - a.deallocate(ap, 3); - assert(new_called == 0); - assert(A_constructed == 0); - - A* ap2 = a.allocate(3, (const void*)5); - assert(new_called == 1); - assert(A_constructed == 0); - a.deallocate(ap2, 3); - assert(new_called == 0); - assert(A_constructed == 0); -} diff --git a/libcxx/test/utilities/memory/default.allocator/allocator.members/construct.pass.cpp b/libcxx/test/utilities/memory/default.allocator/allocator.members/construct.pass.cpp deleted file mode 100644 index b9a174973f2..00000000000 --- a/libcxx/test/utilities/memory/default.allocator/allocator.members/construct.pass.cpp +++ /dev/null @@ -1,155 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// allocator: -// template <class... Args> void construct(pointer p, Args&&... args); - -// UNSUPPORTED: asan, msan - -#include <memory> -#include <new> -#include <cstdlib> -#include <cassert> - -int new_called = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_called; - assert(s == 3 * sizeof(int)); - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - --new_called; - std::free(p); -} - -int A_constructed = 0; - -struct A -{ - int data; - A() {++A_constructed;} - - A(const A&) {++A_constructed;} - - explicit A(int) {++A_constructed;} - A(int, int*) {++A_constructed;} - - ~A() {--A_constructed;} -}; - -int move_only_constructed = 0; - -class move_only -{ - int data; -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - move_only(const move_only&); - move_only& operator=(const move_only&); -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - move_only(move_only&); - move_only& operator=(move_only&); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - -public: - -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - move_only(move_only&&) {++move_only_constructed;} - move_only& operator=(move_only&&) {return *this;} -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - operator std::__rv<move_only> () {return std::__rv<move_only>(*this);} - move_only(std::__rv<move_only>) {++move_only_constructed;} -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - - move_only() {++move_only_constructed;} - ~move_only() {--move_only_constructed;} -}; - -int main() -{ - { - std::allocator<A> a; - assert(new_called == 0); - assert(A_constructed == 0); - - A* ap = a.allocate(3); - assert(new_called == 1); - assert(A_constructed == 0); - - a.construct(ap); - assert(new_called == 1); - assert(A_constructed == 1); - - a.destroy(ap); - assert(new_called == 1); - assert(A_constructed == 0); - - a.construct(ap, A()); - assert(new_called == 1); - assert(A_constructed == 1); - - a.destroy(ap); - assert(new_called == 1); - assert(A_constructed == 0); - - a.construct(ap, 5); - assert(new_called == 1); - assert(A_constructed == 1); - - a.destroy(ap); - assert(new_called == 1); - assert(A_constructed == 0); - - a.construct(ap, 5, (int*)0); - assert(new_called == 1); - assert(A_constructed == 1); - - a.destroy(ap); - assert(new_called == 1); - assert(A_constructed == 0); - - a.deallocate(ap, 3); - assert(new_called == 0); - assert(A_constructed == 0); - } - { - std::allocator<move_only> a; - assert(new_called == 0); - assert(move_only_constructed == 0); - - move_only* ap = a.allocate(3); - assert(new_called == 1); - assert(move_only_constructed == 0); - - a.construct(ap); - assert(new_called == 1); - assert(move_only_constructed == 1); - - a.destroy(ap); - assert(new_called == 1); - assert(move_only_constructed == 0); - - a.construct(ap, move_only()); - assert(new_called == 1); - assert(move_only_constructed == 1); - - a.destroy(ap); - assert(new_called == 1); - assert(move_only_constructed == 0); - - a.deallocate(ap, 3); - assert(new_called == 0); - assert(move_only_constructed == 0); - } -} diff --git a/libcxx/test/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp b/libcxx/test/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp deleted file mode 100644 index 6ec9339bc48..00000000000 --- a/libcxx/test/utilities/memory/default.allocator/allocator.members/max_size.pass.cpp +++ /dev/null @@ -1,27 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// allocator: -// size_type max_size() const throw(); - -#include <memory> -#include <limits> -#include <cstddef> -#include <cassert> - -int new_called = 0; - -int main() -{ - const std::allocator<int> a; - std::size_t M = a.max_size() * sizeof(int); - assert(M > 0xFFFF && M <= std::numeric_limits<std::size_t>::max()); -} diff --git a/libcxx/test/utilities/memory/default.allocator/allocator_pointers.pass.cpp b/libcxx/test/utilities/memory/default.allocator/allocator_pointers.pass.cpp deleted file mode 100644 index 5a8f7a28a04..00000000000 --- a/libcxx/test/utilities/memory/default.allocator/allocator_pointers.pass.cpp +++ /dev/null @@ -1,116 +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. -// -//===----------------------------------------------------------------------===// - -#include <memory> -#include <cassert> - -#if __cplusplus >= 201103L -// #include <memory> -// -// template <class Alloc> -// struct allocator_traits -// { -// typedef Alloc allocator_type; -// typedef typename allocator_type::value_type -// value_type; -// -// typedef Alloc::pointer | value_type* pointer; -// typedef Alloc::const_pointer -// | pointer_traits<pointer>::rebind<const value_type> -// const_pointer; -// typedef Alloc::void_pointer -// | pointer_traits<pointer>::rebind<void> -// void_pointer; -// typedef Alloc::const_void_pointer -// | pointer_traits<pointer>::rebind<const void> -// const_void_pointer; - -template <typename Alloc> -void test_pointer() -{ - typename std::allocator_traits<Alloc>::pointer vp; - typename std::allocator_traits<Alloc>::const_pointer cvp; - - static_assert(std::is_same<bool, decltype( vp == vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp != vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp > vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp >= vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp < vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp <= vp)>::value, ""); - - static_assert(std::is_same<bool, decltype( vp == cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp == vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp != cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp != vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp > cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp > vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp >= vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp < cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp < vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp <= vp)>::value, ""); - - static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp > cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp < cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, ""); -} - -template <typename Alloc> -void test_void_pointer() -{ - typename std::allocator_traits<Alloc>::void_pointer vp; - typename std::allocator_traits<Alloc>::const_void_pointer cvp; - - static_assert(std::is_same<bool, decltype( vp == vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp != vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp > vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp >= vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp < vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp <= vp)>::value, ""); - - static_assert(std::is_same<bool, decltype( vp == cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp == vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp != cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp != vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp > cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp > vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp >= cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp >= vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp < cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp < vp)>::value, ""); - static_assert(std::is_same<bool, decltype( vp <= cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp <= vp)>::value, ""); - - static_assert(std::is_same<bool, decltype(cvp == cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp != cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp > cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp >= cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp < cvp)>::value, ""); - static_assert(std::is_same<bool, decltype(cvp <= cvp)>::value, ""); -} - -struct Foo { int x; }; - -int main() -{ - test_pointer<std::allocator<char>> (); - test_pointer<std::allocator<int>> (); - test_pointer<std::allocator<Foo>> (); - - test_void_pointer<std::allocator<char>> (); - test_void_pointer<std::allocator<int>> (); - test_void_pointer<std::allocator<Foo>> (); -} -#else -int main() {} -#endif diff --git a/libcxx/test/utilities/memory/default.allocator/allocator_types.pass.cpp b/libcxx/test/utilities/memory/default.allocator/allocator_types.pass.cpp deleted file mode 100644 index b0282d7b887..00000000000 --- a/libcxx/test/utilities/memory/default.allocator/allocator_types.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// check nested types: - -// template <class T> -// class allocator -// { -// public: -// typedef size_t size_type; -// typedef ptrdiff_t difference_type; -// typedef T* pointer; -// typedef const T* const_pointer; -// typedef typename add_lvalue_reference<T>::type reference; -// typedef typename add_lvalue_reference<const T>::type const_reference; -// typedef T value_type; -// -// template <class U> struct rebind {typedef allocator<U> other;}; -// ... -// }; - -#include <memory> -#include <type_traits> -#include <cstddef> - -int main() -{ - static_assert((std::is_same<std::allocator<char>::size_type, std::size_t>::value), ""); - static_assert((std::is_same<std::allocator<char>::difference_type, std::ptrdiff_t>::value), ""); - static_assert((std::is_same<std::allocator<char>::pointer, char*>::value), ""); - static_assert((std::is_same<std::allocator<char>::const_pointer, const char*>::value), ""); - static_assert((std::is_same<std::allocator<char>::value_type, char>::value), ""); - static_assert((std::is_same<std::allocator<char>::reference, char&>::value), ""); - static_assert((std::is_same<std::allocator<char>::const_reference, const char&>::value), ""); - static_assert((std::is_same<std::allocator<char>::rebind<int>::other, - std::allocator<int> >::value), ""); - std::allocator<char> a; - std::allocator<char> a2 = a; - a2 = a; - std::allocator<int> a3 = a2; -} diff --git a/libcxx/test/utilities/memory/default.allocator/allocator_void.pass.cpp b/libcxx/test/utilities/memory/default.allocator/allocator_void.pass.cpp deleted file mode 100644 index cc1dbebae03..00000000000 --- a/libcxx/test/utilities/memory/default.allocator/allocator_void.pass.cpp +++ /dev/null @@ -1,36 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <> -// class allocator<void> -// { -// public: -// typedef void* pointer; -// typedef const void* const_pointer; -// typedef void value_type; -// -// template <class _Up> struct rebind {typedef allocator<_Up> other;}; -// }; - -#include <memory> -#include <type_traits> - -int main() -{ - static_assert((std::is_same<std::allocator<void>::pointer, void*>::value), ""); - static_assert((std::is_same<std::allocator<void>::const_pointer, const void*>::value), ""); - static_assert((std::is_same<std::allocator<void>::value_type, void>::value), ""); - static_assert((std::is_same<std::allocator<void>::rebind<int>::other, - std::allocator<int> >::value), ""); - std::allocator<void> a; - std::allocator<void> a2 = a; - a2 = a; -} diff --git a/libcxx/test/utilities/memory/pointer.traits/difference_type.pass.cpp b/libcxx/test/utilities/memory/pointer.traits/difference_type.pass.cpp deleted file mode 100644 index 483c32561e8..00000000000 --- a/libcxx/test/utilities/memory/pointer.traits/difference_type.pass.cpp +++ /dev/null @@ -1,25 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class T> -// struct pointer_traits<T*> -// { -// typedef ptrdiff_t difference_type; -// ... -// }; - -#include <memory> -#include <type_traits> - -int main() -{ - static_assert((std::is_same<std::pointer_traits<double*>::difference_type, std::ptrdiff_t>::value), ""); -} diff --git a/libcxx/test/utilities/memory/pointer.traits/element_type.pass.cpp b/libcxx/test/utilities/memory/pointer.traits/element_type.pass.cpp deleted file mode 100644 index 44694fcb013..00000000000 --- a/libcxx/test/utilities/memory/pointer.traits/element_type.pass.cpp +++ /dev/null @@ -1,25 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class T> -// struct pointer_traits<T*> -// { -// typedef T element_type; -// ... -// }; - -#include <memory> -#include <type_traits> - -int main() -{ - static_assert((std::is_same<std::pointer_traits<const short*>::element_type, const short>::value), ""); -} diff --git a/libcxx/test/utilities/memory/pointer.traits/pointer.pass.cpp b/libcxx/test/utilities/memory/pointer.traits/pointer.pass.cpp deleted file mode 100644 index 66e90cfcb85..00000000000 --- a/libcxx/test/utilities/memory/pointer.traits/pointer.pass.cpp +++ /dev/null @@ -1,32 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Ptr> -// struct pointer_traits -// { -// typedef Ptr pointer; -// ... -// }; - -#include <memory> -#include <type_traits> - -struct A -{ - typedef short element_type; - typedef char difference_type; -}; - -int main() -{ - static_assert((std::is_same<std::pointer_traits<A>::pointer, A>::value), ""); - static_assert((std::is_same<std::pointer_traits<int*>::pointer, int*>::value), ""); -} diff --git a/libcxx/test/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp b/libcxx/test/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp deleted file mode 100644 index a8ad936c936..00000000000 --- a/libcxx/test/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp +++ /dev/null @@ -1,48 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Ptr> -// struct pointer_traits -// { -// static pointer pointer_to(<details>); -// ... -// }; - -#include <memory> -#include <cassert> - -template <class T> -struct A -{ -private: - struct nat {}; -public: - typedef T element_type; - element_type* t_; - - A(element_type* t) : t_(t) {} - - static A pointer_to(typename std::conditional<std::is_void<element_type>::value, - nat, element_type>::type& et) - {return A(&et);} -}; - -int main() -{ - { - int i = 0; - A<int> a = std::pointer_traits<A<int> >::pointer_to(i); - assert(a.t_ == &i); - } - { - (std::pointer_traits<A<void> >::element_type)0; - } -} diff --git a/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp b/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp deleted file mode 100644 index 4efe6134242..00000000000 --- a/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp +++ /dev/null @@ -1,48 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Ptr> -// struct pointer_traits -// { -// typedef <details> difference_type; -// ... -// }; - -#include <memory> -#include <type_traits> - -struct A -{ - typedef short element_type; - typedef char difference_type; -}; - -struct B -{ - typedef short element_type; -}; - -template <class T> -struct C {}; - -template <class T> -struct D -{ - typedef char difference_type; -}; - -int main() -{ - static_assert((std::is_same<std::pointer_traits<A>::difference_type, char>::value), ""); - static_assert((std::is_same<std::pointer_traits<B>::difference_type, std::ptrdiff_t>::value), ""); - static_assert((std::is_same<std::pointer_traits<C<double> >::difference_type, std::ptrdiff_t>::value), ""); - static_assert((std::is_same<std::pointer_traits<D<int> >::difference_type, char>::value), ""); -} diff --git a/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp b/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp deleted file mode 100644 index 0ee1e8c93a6..00000000000 --- a/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/element_type.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Ptr> -// struct pointer_traits -// { -// typedef <details> element_type; -// ... -// }; - -#include <memory> -#include <type_traits> - -struct A -{ - typedef char element_type; -}; - -template <class T> -struct B -{ - typedef char element_type; -}; - -template <class T> -struct C -{ -}; - -template <class T, class U> -struct D -{ -}; - -int main() -{ - static_assert((std::is_same<std::pointer_traits<A>::element_type, char>::value), ""); - static_assert((std::is_same<std::pointer_traits<B<int> >::element_type, char>::value), ""); - static_assert((std::is_same<std::pointer_traits<C<int> >::element_type, int>::value), ""); - static_assert((std::is_same<std::pointer_traits<D<double, int> >::element_type, double>::value), ""); -} diff --git a/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp b/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp deleted file mode 100644 index 4a1455c53ef..00000000000 --- a/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp +++ /dev/null @@ -1,69 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Ptr> -// struct pointer_traits -// { -// template <class U> using rebind = <details>; -// ... -// }; - -#include <memory> -#include <type_traits> - -template <class T> -struct A -{ -}; - -template <class T> struct B1 {}; - -template <class T> -struct B -{ -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - template <class U> using rebind = B1<U>; -#else - template <class U> struct rebind {typedef B1<U> other;}; -#endif -}; - -template <class T, class U> -struct C -{ -}; - -template <class T, class U> struct D1 {}; - -template <class T, class U> -struct D -{ -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - template <class V> using rebind = D1<V, U>; -#else - template <class V> struct rebind {typedef D1<V, U> other;}; -#endif -}; - -int main() -{ -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - static_assert((std::is_same<std::pointer_traits<A<int*> >::rebind<double*>, A<double*> >::value), ""); - static_assert((std::is_same<std::pointer_traits<B<int> >::rebind<double>, B1<double> >::value), ""); - static_assert((std::is_same<std::pointer_traits<C<char, int> >::rebind<double>, C<double, int> >::value), ""); - static_assert((std::is_same<std::pointer_traits<D<char, int> >::rebind<double>, D1<double, int> >::value), ""); -#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES - static_assert((std::is_same<std::pointer_traits<A<int*> >::rebind<double*>::other, A<double*> >::value), ""); - static_assert((std::is_same<std::pointer_traits<B<int> >::rebind<double>::other, B1<double> >::value), ""); - static_assert((std::is_same<std::pointer_traits<C<char, int> >::rebind<double>::other, C<double, int> >::value), ""); - static_assert((std::is_same<std::pointer_traits<D<char, int> >::rebind<double>::other, D1<double, int> >::value), ""); -#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES -} diff --git a/libcxx/test/utilities/memory/pointer.traits/pointer_to.pass.cpp b/libcxx/test/utilities/memory/pointer.traits/pointer_to.pass.cpp deleted file mode 100644 index fc44d9d77a2..00000000000 --- a/libcxx/test/utilities/memory/pointer.traits/pointer_to.pass.cpp +++ /dev/null @@ -1,32 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class T> -// struct pointer_traits<T*> -// { -// static pointer pointer_to(<details>); -// ... -// }; - -#include <memory> -#include <cassert> - -int main() -{ - { - int i = 0; - int* a = std::pointer_traits<int*>::pointer_to(i); - assert(a == &i); - } - { - (std::pointer_traits<void*>::element_type)0; - } -} diff --git a/libcxx/test/utilities/memory/pointer.traits/rebind.pass.cpp b/libcxx/test/utilities/memory/pointer.traits/rebind.pass.cpp deleted file mode 100644 index 8716c05f333..00000000000 --- a/libcxx/test/utilities/memory/pointer.traits/rebind.pass.cpp +++ /dev/null @@ -1,29 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class T> -// struct pointer_traits<T*> -// { -// template <class U> using rebind = U*; -// ... -// }; - -#include <memory> -#include <type_traits> - -int main() -{ -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES - 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), ""); -#endif -} diff --git a/libcxx/test/utilities/memory/ptr.align/align.pass.cpp b/libcxx/test/utilities/memory/ptr.align/align.pass.cpp deleted file mode 100644 index e4e2e0ae6a5..00000000000 --- a/libcxx/test/utilities/memory/ptr.align/align.pass.cpp +++ /dev/null @@ -1,85 +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. -// -//===----------------------------------------------------------------------===// - -// #include <memory> - -// void* align(size_t alignment, size_t size, void*& ptr, size_t& space); - -#include <memory> -#include <cassert> - -int main() -{ - int i = 0; - const unsigned N = 20; - char buf[N]; - void* r; - void* p = &buf[0]; - std::size_t s = N; - r = std::align(4, 10, p, s); - assert(p == &buf[0]); - assert(r == p); - assert(s == N); - - p = &buf[1]; - s = N; - r = std::align(4, 10, p, s); - assert(p == &buf[4]); - assert(r == p); - assert(s == N-3); - - p = &buf[2]; - s = N; - r = std::align(4, 10, p, s); - assert(p == &buf[4]); - assert(r == p); - assert(s == N-2); - - p = &buf[3]; - s = N; - r = std::align(4, 10, p, s); - assert(p == &buf[4]); - assert(r == p); - assert(s == N-1); - - p = &buf[4]; - s = N; - r = std::align(4, 10, p, s); - assert(p == &buf[4]); - assert(r == p); - assert(s == N); - - p = &buf[0]; - s = N; - r = std::align(4, N, p, s); - assert(p == &buf[0]); - assert(r == p); - assert(s == N); - - p = &buf[1]; - s = N-1; - r = std::align(4, N-4, p, s); - assert(p == &buf[4]); - assert(r == p); - assert(s == N-4); - - p = &buf[1]; - s = N-1; - r = std::align(4, N-3, p, s); - assert(p == &buf[1]); - assert(r == nullptr); - assert(s == N-1); - - p = &buf[0]; - s = N; - r = std::align(1, N+1, p, s); - assert(p == &buf[0]); - assert(r == nullptr); - assert(s == N); -} diff --git a/libcxx/test/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp b/libcxx/test/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp deleted file mode 100644 index b58f5c55b64..00000000000 --- a/libcxx/test/utilities/memory/specialized.algorithms/nothing_to_do.pass.cpp +++ /dev/null @@ -1,12 +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. -// -//===----------------------------------------------------------------------===// - -int main() -{ -} diff --git a/libcxx/test/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp b/libcxx/test/utilities/memory/specialized.algorithms/specialized.addressof/addressof.pass.cpp deleted file mode 100644 index e07bec4d0a4..00000000000 --- a/libcxx/test/utilities/memory/specialized.algorithms/specialized.addressof/addressof.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <ObjectType T> T* addressof(T& r); - -#include <memory> -#include <cassert> - -struct A -{ - void operator&() const {} -}; - -struct nothing { - operator char&() - { - static char c; - return c; - } -}; - -int main() -{ - { - int i; - double d; - assert(std::addressof(i) == &i); - assert(std::addressof(d) == &d); - A* tp = new A; - const A* ctp = tp; - assert(std::addressof(*tp) == tp); - assert(std::addressof(*ctp) == tp); - delete tp; - } - { - union - { - nothing n; - int i; - }; - assert(std::addressof(n) == (void*)std::addressof(i)); - } -} diff --git a/libcxx/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp b/libcxx/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.pass.cpp deleted file mode 100644 index 7de7eccc65f..00000000000 --- a/libcxx/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class InputIterator, class ForwardIterator> -// ForwardIterator -// uninitialized_copy(InputIterator first, InputIterator last, -// ForwardIterator result); - -#include <memory> -#include <cassert> - -struct B -{ - static int count_; - int data_; - explicit B() : data_(1) {} - B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;} - ~B() {data_ = 0;} -}; - -int B::count_ = 0; - -int main() -{ - const int N = 5; - char pool[sizeof(B)*N] = {0}; - B* bp = (B*)pool; - B b[N]; - try - { - std::uninitialized_copy(b, b+N, bp); - assert(false); - } - catch (...) - { - for (int i = 0; i < N; ++i) - assert(bp[i].data_ == 0); - } - B::count_ = 0; - std::uninitialized_copy(b, b+2, bp); - for (int i = 0; i < 2; ++i) - assert(bp[i].data_ == 1); -} diff --git a/libcxx/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp b/libcxx/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.pass.cpp deleted file mode 100644 index 79afa4f8f18..00000000000 --- a/libcxx/test/utilities/memory/specialized.algorithms/uninitialized.copy/uninitialized_copy_n.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class InputIterator, class Size, class ForwardIterator> -// ForwardIterator -// uninitialized_copy_n(InputIterator first, Size n, -// ForwardIterator result); - -#include <memory> -#include <cassert> - -struct B -{ - static int count_; - int data_; - explicit B() : data_(1) {} - B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;} - ~B() {data_ = 0;} -}; - -int B::count_ = 0; - -int main() -{ - const int N = 5; - char pool[sizeof(B)*N] = {0}; - B* bp = (B*)pool; - B b[N]; - try - { - std::uninitialized_copy_n(b, 5, bp); - assert(false); - } - catch (...) - { - for (int i = 0; i < N; ++i) - assert(bp[i].data_ == 0); - } - B::count_ = 0; - std::uninitialized_copy_n(b, 2, bp); - for (int i = 0; i < 2; ++i) - assert(bp[i].data_ == 1); -} diff --git a/libcxx/test/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp b/libcxx/test/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp deleted file mode 100644 index 8fc6b819484..00000000000 --- a/libcxx/test/utilities/memory/specialized.algorithms/uninitialized.fill.n/uninitialized_fill_n.pass.cpp +++ /dev/null @@ -1,50 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class ForwardIterator, class Size, class T> -// ForwardIterator -// uninitialized_fill_n(ForwardIterator first, Size n, const T& x); - -#include <memory> -#include <cassert> - -struct B -{ - static int count_; - int data_; - explicit B() : data_(1) {} - B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;} - ~B() {data_ = 0;} -}; - -int B::count_ = 0; - -int main() -{ - const int N = 5; - char pool[sizeof(B)*N] = {0}; - B* bp = (B*)pool; - try - { - std::uninitialized_fill_n(bp, 5, B()); - assert(false); - } - catch (...) - { - for (int i = 0; i < N; ++i) - assert(bp[i].data_ == 0); - } - B::count_ = 0; - B* r = std::uninitialized_fill_n(bp, 2, B()); - assert(r == bp + 2); - for (int i = 0; i < 2; ++i) - assert(bp[i].data_ == 1); -} diff --git a/libcxx/test/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp b/libcxx/test/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp deleted file mode 100644 index c34fdc7a14e..00000000000 --- a/libcxx/test/utilities/memory/specialized.algorithms/uninitialized.fill/uninitialized_fill.pass.cpp +++ /dev/null @@ -1,50 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class ForwardIterator, class T> -// void -// uninitialized_fill(ForwardIterator first, ForwardIterator last, -// const T& x); - -#include <memory> -#include <cassert> - -struct B -{ - static int count_; - int data_; - explicit B() : data_(1) {} - B(const B& b) {if (++count_ == 3) throw 1; data_ = b.data_;} - ~B() {data_ = 0;} -}; - -int B::count_ = 0; - -int main() -{ - const int N = 5; - char pool[sizeof(B)*N] = {0}; - B* bp = (B*)pool; - try - { - std::uninitialized_fill(bp, bp+N, B()); - assert(false); - } - catch (...) - { - for (int i = 0; i < N; ++i) - assert(bp[i].data_ == 0); - } - B::count_ = 0; - std::uninitialized_fill(bp, bp+2, B()); - for (int i = 0; i < 2; ++i) - assert(bp[i].data_ == 1); -} diff --git a/libcxx/test/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp b/libcxx/test/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp deleted file mode 100644 index f77d6c75e17..00000000000 --- a/libcxx/test/utilities/memory/storage.iterator/raw_storag_iterator.pass.cpp +++ /dev/null @@ -1,44 +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. -// -//===----------------------------------------------------------------------===// - -// raw_storage_iterator - -#include <memory> -#include <type_traits> -#include <cassert> - -int A_constructed = 0; - -struct A -{ - int data_; -public: - explicit A(int i) : data_(i) {++A_constructed;} - - A(const A& a) : data_(a.data_) {++A_constructed;} - ~A() {--A_constructed; data_ = 0;} - - bool operator==(int i) const {return data_ == i;} -}; - -int main() -{ - typedef std::aligned_storage<3*sizeof(A), std::alignment_of<A>::value>::type - Storage; - Storage buffer; - std::raw_storage_iterator<A*, A> it((A*)&buffer); - assert(A_constructed == 0); - for (int i = 0; i < 3; ++i) - { - *it++ = A(i+1); - A* ap = (A*)&buffer + i; - assert(*ap == i+1); - assert(A_constructed == i+1); - } -} diff --git a/libcxx/test/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp b/libcxx/test/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp deleted file mode 100644 index c1575bda2ba..00000000000 --- a/libcxx/test/utilities/memory/temporary.buffer/temporary_buffer.pass.cpp +++ /dev/null @@ -1,29 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class T> -// pair<T*, ptrdiff_t> -// get_temporary_buffer(ptrdiff_t n); -// -// template <class T> -// void -// return_temporary_buffer(T* p); - -#include <memory> -#include <cassert> - -int main() -{ - std::pair<int*, std::ptrdiff_t> ip = std::get_temporary_buffer<int>(5); - assert(ip.first); - assert(ip.second == 5); - std::return_temporary_buffer(ip.first); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/deleter.h b/libcxx/test/utilities/memory/unique.ptr/deleter.h deleted file mode 100644 index 04b6de7c7de..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/deleter.h +++ /dev/null @@ -1,181 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Example move-only deleter - -#ifndef DELETER_H -#define DELETER_H - -#include <type_traits> -#include <cassert> - -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) - { - state_ = r.state_; - 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_(0) {} - explicit Deleter(int s) : state_(s) {} - ~Deleter() {assert(state_ >= 0); state_ = -1;} - -#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) - : state_(d.state()) {d.set_state(0);} - -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;} - - void operator()(T* p) {delete p;} -}; - -template <class T> -class Deleter<T[]> -{ - 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) - { - state_ = r.state_; - 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_(0) {} - explicit Deleter(int s) : state_(s) {} - ~Deleter() {assert(state_ >= 0); state_ = -1;} - - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete [] p;} -}; - -template <class T> -void -swap(Deleter<T>& x, Deleter<T>& y) -{ - Deleter<T> t(std::move(x)); - x = std::move(y); - y = std::move(t); -} - -template <class T> -class CDeleter -{ - int state_; - -public: - - CDeleter() : state_(0) {} - explicit CDeleter(int s) : state_(s) {} - ~CDeleter() {assert(state_ >= 0); state_ = -1;} - - template <class U> - CDeleter(const CDeleter<U>& d) - : state_(d.state()) {} - - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete p;} -}; - -template <class T> -class CDeleter<T[]> -{ - int state_; - -public: - - CDeleter() : state_(0) {} - explicit CDeleter(int s) : state_(s) {} - ~CDeleter() {assert(state_ >= 0); state_ = -1;} - - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {delete [] p;} -}; - -template <class T> -void -swap(CDeleter<T>& x, CDeleter<T>& y) -{ - CDeleter<T> t(std::move(x)); - x = std::move(y); - y = std::move(t); -} - -#endif // DELETER_H diff --git a/libcxx/test/utilities/memory/unique.ptr/nothing_to_do.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/nothing_to_do.pass.cpp deleted file mode 100644 index b58f5c55b64..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/nothing_to_do.pass.cpp +++ /dev/null @@ -1,12 +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. -// -//===----------------------------------------------------------------------===// - -int main() -{ -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp deleted file mode 100644 index b2fb58f529f..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array.pass.cpp +++ /dev/null @@ -1,45 +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. -// -//===----------------------------------------------------------------------===// - -#include <memory> -#include <string> -#include <cassert> - -// The only way to create an unique_ptr<T[]> is to default construct them. - -class foo { -public: - foo () : val_(3) {} - int get () const { return val_; } -private: - int val_; - }; - -int main() -{ -#if _LIBCPP_STD_VER > 11 - { - auto p1 = std::make_unique<int[]>(5); - for ( int i = 0; i < 5; ++i ) - assert ( p1[i] == 0 ); - } - - { - auto p2 = std::make_unique<std::string[]>(5); - for ( int i = 0; i < 5; ++i ) - assert ( p2[i].size () == 0 ); - } - - { - auto p3 = std::make_unique<foo[]>(7); - for ( int i = 0; i < 7; ++i ) - assert ( p3[i].get () == 3 ); - } -#endif // _LIBCPP_STD_VER > 11 -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp deleted file mode 100644 index 00987919413..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array1.fail.cpp +++ /dev/null @@ -1,17 +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. -// -//===----------------------------------------------------------------------===// - -#include <memory> -#include <string> -#include <cassert> - -int main() -{ - auto up1 = std::make_unique<std::string[]>("error"); // doesn't compile - no bound -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp deleted file mode 100644 index cc94e9ab3aa..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array2.fail.cpp +++ /dev/null @@ -1,17 +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. -// -//===----------------------------------------------------------------------===// - -#include <memory> -#include <string> -#include <cassert> - -int main() -{ - auto up2 = std::make_unique<int[]>(10, 20, 30, 40); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp deleted file mode 100644 index cfdc2e1d886..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array3.fail.cpp +++ /dev/null @@ -1,17 +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. -// -//===----------------------------------------------------------------------===// - -#include <memory> -#include <string> -#include <cassert> - -int main() -{ - auto up3 = std::make_unique<int[5]>(); // this is deleted -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp deleted file mode 100644 index 26eb59bbfd7..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.array4.fail.cpp +++ /dev/null @@ -1,17 +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. -// -//===----------------------------------------------------------------------===// - -#include <memory> -#include <string> -#include <cassert> - -int main() -{ - auto up4 = std::make_unique<int[5]>(11, 22, 33, 44, 55); // deleted -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp deleted file mode 100644 index 7326ed22655..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.create/make_unique.single.pass.cpp +++ /dev/null @@ -1,33 +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. -// -//===----------------------------------------------------------------------===// - -#include <memory> -#include <string> -#include <cassert> - -int main() -{ -#if _LIBCPP_STD_VER > 11 - { - std::unique_ptr<int> p1 = std::make_unique<int>(1); - assert ( *p1 == 1 ); - p1 = std::make_unique<int> (); - assert ( *p1 == 0 ); - } - - { - std::unique_ptr<std::string> p2 = std::make_unique<std::string> ( "Meow!" ); - assert ( *p2 == "Meow!" ); - p2 = std::make_unique<std::string> (); - assert ( *p2 == "" ); - p2 = std::make_unique<std::string> ( 6, 'z' ); - assert ( *p2 == "zzzzzz" ); - } -#endif // _LIBCPP_STD_VER > 11 -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp deleted file mode 100644 index b58f5c55b64..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/nothing_to_do.pass.cpp +++ /dev/null @@ -1,12 +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. -// -//===----------------------------------------------------------------------===// - -int main() -{ -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp deleted file mode 100644 index 9bf794caeda..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/convert_ctor.pass.cpp +++ /dev/null @@ -1,48 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// default_delete - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - std::default_delete<B> d2; - std::default_delete<A> d1 = d2; - A* p = new B; - assert(A::count == 1); - assert(B::count == 1); - d1(p); - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp deleted file mode 100644 index f686e9f01f1..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/default.pass.cpp +++ /dev/null @@ -1,34 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// default_delete - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - std::default_delete<A> d; - A* p = new A; - assert(A::count == 1); - d(p); - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp deleted file mode 100644 index 255e5cd39c6..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/incomplete.fail.cpp +++ /dev/null @@ -1,26 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// default_delete - -// Test that default_delete's operator() requires a complete type - -#include <memory> -#include <cassert> - -struct A; - -int main() -{ - std::default_delete<A> d; - A* p = 0; - d(p); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp deleted file mode 100644 index 5d1cf1ff498..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt/void.fail.cpp +++ /dev/null @@ -1,24 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// default_delete - -// Test that default_delete's operator() requires a complete type - -#include <memory> -#include <cassert> - -int main() -{ - std::default_delete<const void> d; - const void* p = 0; - d(p); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp deleted file mode 100644 index 41209d977b7..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/convert_ctor.fail.cpp +++ /dev/null @@ -1,32 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// default_delete - -// Test that default_delete<T[]> does not have a working converting constructor - -#include <memory> -#include <cassert> - -struct A -{ -}; - -struct B - : public A -{ -}; - -int main() -{ - std::default_delete<B[]> d2; - std::default_delete<A[]> d1 = d2; -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp deleted file mode 100644 index 7a409766412..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/default.pass.cpp +++ /dev/null @@ -1,36 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// default_delete - -// Test that default_delete<T[]> has a working default constructor - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - std::default_delete<A[]> d; - A* p = new A[3]; - assert(A::count == 3); - d(p); - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp deleted file mode 100644 index 528b10e9085..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.dflt1/incomplete.fail.cpp +++ /dev/null @@ -1,26 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// default_delete - -// Test that default_delete<T[]>'s operator() requires a complete type - -#include <memory> -#include <cassert> - -struct A; - -int main() -{ - std::default_delete<A[]> d; - A* p = 0; - d(p); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp deleted file mode 100644 index b58f5c55b64..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.dltr/unique.ptr.dltr.general/nothing_to_do.pass.cpp +++ /dev/null @@ -1,12 +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. -// -//===----------------------------------------------------------------------===// - -int main() -{ -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp deleted file mode 100644 index 57724ae10a7..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.fail.cpp +++ /dev/null @@ -1,38 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> -#include <cassert> - -// Can't copy from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> s(new A); - std::unique_ptr<A> s2; - s2 = s; - } -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp deleted file mode 100644 index 2426dd30f88..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move01.pass.cpp +++ /dev/null @@ -1,78 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -// test move assignment. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. - -#include <memory> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A[]> s1(new A[3]); - A* p = s1.get(); - assert(A::count == 3); - std::unique_ptr<A[]> s2(new A[2]); - assert(A::count == 5); - s2 = std::move(s1); - assert(A::count == 3); - assert(s2.get() == p); - assert(s1.get() == 0); - } - assert(A::count == 0); - { - std::unique_ptr<A[], Deleter<A[]> > s1(new A[4], Deleter<A[]>(5)); - A* p = s1.get(); - assert(A::count == 4); - std::unique_ptr<A[], Deleter<A[]> > s2(new A[5]); - assert(A::count == 9); - s2 = std::move(s1); - assert(s2.get() == p); - assert(s1.get() == 0); - assert(A::count == 4); - assert(s2.get_deleter().state() == 5); - assert(s1.get_deleter().state() == 0); - } - assert(A::count == 0); - { - CDeleter<A[]> d1(5); - std::unique_ptr<A[], CDeleter<A[]>&> s1(new A[6], d1); - A* p = s1.get(); - assert(A::count == 6); - CDeleter<A[]> d2(6); - std::unique_ptr<A[], CDeleter<A[]>&> s2(new A[3], d2); - assert(A::count == 9); - s2 = std::move(s1); - assert(A::count == 6); - assert(s2.get() == p); - assert(s1.get() == 0); - assert(d1.state() == 5); - assert(d2.state() == 5); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp deleted file mode 100644 index bfaac880510..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move02.fail.cpp +++ /dev/null @@ -1,38 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> -#include <cassert> - -// Can't copy from const lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - const std::unique_ptr<A[]> s(new A[3]); - std::unique_ptr<A[]> s2; - s2 = s; - } -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.cpp deleted file mode 100644 index aa4fdb8a96b..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move03.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> -#include <cassert> - -// Can't copy from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - std::unique_ptr<A, Deleter> s(new A); - A* p = s.get(); - std::unique_ptr<A, Deleter> s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.cpp deleted file mode 100644 index e0d7c891c80..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move04.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <cassert> - -// test move ctor. Can't copy from const lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - const std::unique_ptr<A, Deleter> s(new A); - A* p = s.get(); - std::unique_ptr<A, Deleter> s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.cpp deleted file mode 100644 index a0ea40bc8e0..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert01.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> -#include <cassert> - -// Can't assign from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.cpp deleted file mode 100644 index b46092354b0..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert02.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from lvalue - -#include <memory> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - boost::unique_ptr<B[], Deleter<B> > s(new B); - A* p = s.get(); - boost::unique_ptr<A[], Deleter<A> > s2; - 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); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp deleted file mode 100644 index e18be7b040e..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert03.fail.cpp +++ /dev/null @@ -1,61 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from lvalue - -#include <memory> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - Deleter<B> db(5); - boost::unique_ptr<B[], Deleter<B>&> s(new B, db); - A* p = s.get(); - Deleter<A> da(6); - boost::unique_ptr<A[], Deleter<A>&> s2(new A, da); - 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(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.cpp deleted file mode 100644 index 8d2e0746640..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert04.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> -#include <cassert> - -// Can't assign from const lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const boost::unique_ptr<B[]> s(new B); - A* p = s.get(); - boost::unique_ptr<A[]> s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.cpp deleted file mode 100644 index 3ba514c9206..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert05.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from const lvalue - -#include <memory> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const boost::unique_ptr<B[], Deleter<B> > s(new B); - A* p = s.get(); - boost::unique_ptr<A[], Deleter<A> > s2; - 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); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp deleted file mode 100644 index f4c45bc5f8e..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert06.fail.cpp +++ /dev/null @@ -1,61 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from const lvalue - -#include <memory> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - Deleter<B> db(5); - const boost::unique_ptr<B[], Deleter<B>&> s(new B, db); - A* p = s.get(); - Deleter<A> da(6); - boost::unique_ptr<A[], Deleter<A>&> s2(new A, da); - 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(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp deleted file mode 100644 index 5e238bd2770..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert07.fail.cpp +++ /dev/null @@ -1,55 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - boost::unique_ptr<B[]> s(new B); - A* p = s.get(); - boost::unique_ptr<A[]> s2(new A); - assert(A::count == 2); - s2 = boost::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.cpp deleted file mode 100644 index d084d38201c..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert08.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - boost::unique_ptr<B[], Deleter<B> > s(new B); - A* p = s.get(); - boost::unique_ptr<A[], Deleter<A> > s2(new A); - assert(A::count == 2); - s2 = (boost::move(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); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp deleted file mode 100644 index 972c5593be6..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/move_convert09.fail.cpp +++ /dev/null @@ -1,61 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// test converting move assignment with reference deleters - -#include <memory> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - Deleter<B> db(5); - boost::unique_ptr<B[], Deleter<B>&> s(new B, db); - A* p = s.get(); - Deleter<A> da(6); - boost::unique_ptr<A[], Deleter<A>&> s2(new A, da); - s2 = boost::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s2.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp deleted file mode 100644 index e2d7956cda6..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_asgn.pass.cpp +++ /dev/null @@ -1,41 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> -#include <cassert> - -// test assignment from null - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> s2(new A); - assert(A::count == 1); - s2 = 0; - assert(A::count == 0); - assert(s2.get() == 0); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp deleted file mode 100644 index 6d752b9951a..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/null_ctor.pass.cpp +++ /dev/null @@ -1,44 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// The deleter is not called if get() == 0 - -#include <memory> -#include <cassert> - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(0) {} - - int state() const {return state_;} - - void operator()(void*) {++state_;} -}; - -int main() -{ - Deleter d; - assert(d.state() == 0); - { - std::unique_ptr<int[], Deleter&> p(0, d); - assert(p.get() == 0); - assert(&p.get_deleter() == &d); - } - assert(d.state() == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp deleted file mode 100644 index 30ecdded3cf..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/nullptr_asgn.pass.cpp +++ /dev/null @@ -1,41 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> -#include <cassert> - -// test assignment from null - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A[]> s2(new A[3]); - assert(A::count == 3); - s2 = nullptr; - assert(A::count == 0); - assert(s2.get() == 0); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp deleted file mode 100644 index e7ad6ad7ef3..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/pointer_type.pass.cpp +++ /dev/null @@ -1,34 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr<T[]>::pointer type - -#include <memory> -#include <type_traits> - -struct Deleter -{ - struct pointer {}; -}; - -int main() -{ - { - typedef std::unique_ptr<int[]> P; - static_assert((std::is_same<P::pointer, int*>::value), ""); - } - { - typedef std::unique_ptr<int[], Deleter> P; - static_assert((std::is_same<P::pointer, Deleter::pointer>::value), ""); - } -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp deleted file mode 100644 index 95350a6fc0e..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.fail.cpp +++ /dev/null @@ -1,39 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr default ctor - -// default unique_ptr ctor should require default Deleter ctor - -// USE_VERIFY - -#include <memory> - -class Deleter -{ - // expected-error@memory:* {{base class 'Deleter' has private default constructor}} - // expected-note@memory:* + {{in instantiation of member function}} - Deleter() {} // expected-note {{implicitly declared private here}} - -public: - - Deleter(Deleter&) {} - Deleter& operator=(Deleter&) { return *this; } - - void operator()(void*) const {} -}; - -int main() -{ - std::unique_ptr<int[], Deleter> p; -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp deleted file mode 100644 index 0cc54382b98..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default01.pass.cpp +++ /dev/null @@ -1,47 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr default ctor - -// default unique_ptr ctor should only require default Deleter ctor - -#include <memory> -#include <cassert> - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(void*) {} -}; - -int main() -{ - { - std::unique_ptr<int[]> p; - assert(p.get() == 0); - } - { - std::unique_ptr<int[], Deleter> p; - assert(p.get() == 0); - assert(p.get_deleter().state() == 5); - } -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp deleted file mode 100644 index 82b84948f3f..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.fail.cpp +++ /dev/null @@ -1,30 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr default ctor - -// default unique_ptr ctor should require non-reference Deleter ctor - -#include <memory> - -class Deleter -{ -public: - - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr<int[], Deleter&> p; -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp deleted file mode 100644 index 3ded41c419c..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default02.pass.cpp +++ /dev/null @@ -1,87 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test default unique_ptr<T[]> ctor - -// default unique_ptr<T[]> ctor shouldn't require complete type - -#include <memory> -#include <cassert> - -struct A; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p); -}; - -void check(int i); - -template <class D = std::default_delete<A> > -struct B -{ - std::unique_ptr<A[], D> a_; - B(); - ~B(); - - A* get() const {return a_.get();} - D& get_deleter() {return a_.get_deleter();} -}; - -int main() -{ - { - B<> s; - assert(s.get() == 0); - } - check(0); - { - B<Deleter> s; - assert(s.get() == 0); - assert(s.get_deleter().state() == 5); - } - check(0); -} - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -void Deleter::operator()(A* p) {delete p;} - -void check(int i) -{ - assert(A::count == i); -} - -template <class D> -B<D>::B() {} - -template <class D> -B<D>::~B() {} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp deleted file mode 100644 index 74d24fd488b..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/default03.fail.cpp +++ /dev/null @@ -1,23 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr default ctor - -// default unique_ptr ctor should require non-pointer Deleter - -#include <memory> - -int main() -{ - std::unique_ptr<int[], void (*)(void*)> p; -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp deleted file mode 100644 index bc49a0e5c31..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.fail.cpp +++ /dev/null @@ -1,42 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <cassert> - -// test move ctor. Can't copy from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A[]> s(new A[3]); - A* p = s.get(); - std::unique_ptr<A[]> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp deleted file mode 100644 index fc00c7da38b..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move01.pass.cpp +++ /dev/null @@ -1,85 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class NCDeleter -{ - int state_; - - NCDeleter(NCDeleter&); - NCDeleter& operator=(NCDeleter&); -public: - - NCDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - std::unique_ptr<A[]> s(new A[3]); - A* p = s.get(); - std::unique_ptr<A[]> s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 3); - } - assert(A::count == 0); - { - std::unique_ptr<A[], Deleter<A[]> > s(new A[3], Deleter<A[]>(5)); - A* p = s.get(); - std::unique_ptr<A[], Deleter<A[]> > s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 3); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - { - NCDeleter d; - std::unique_ptr<A[], NCDeleter&> s(new A[3], d); - A* p = s.get(); - std::unique_ptr<A[], NCDeleter&> s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 3); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp deleted file mode 100644 index 8e44c78bf1e..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.fail.cpp +++ /dev/null @@ -1,42 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Can't copy from const lvalue - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - const std::unique_ptr<A[]> s(new A[3]); - A* p = s.get(); - std::unique_ptr<A[]> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp deleted file mode 100644 index ef821a915e4..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move02.pass.cpp +++ /dev/null @@ -1,87 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class NCDeleter -{ - int state_; - - NCDeleter(NCDeleter&); - NCDeleter& operator=(NCDeleter&); -public: - - NCDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) {delete [] p;} -}; - -std::unique_ptr<A[]> -source1() -{ - return std::unique_ptr<A[]>(new A[3]); -} - -void sink1(std::unique_ptr<A[]> p) -{ -} - -std::unique_ptr<A[], Deleter<A[]> > -source2() -{ - return std::unique_ptr<A[], Deleter<A[]> >(new A[3]); -} - -void sink2(std::unique_ptr<A[], Deleter<A[]> > p) -{ -} - -std::unique_ptr<A[], NCDeleter&> -source3() -{ - static NCDeleter d; - return std::unique_ptr<A[], NCDeleter&>(new A[3], d); -} - -void sink3(std::unique_ptr<A[], NCDeleter&> p) -{ -} - -int main() -{ - sink1(source1()); - sink2(source2()); - sink3(source3()); - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp deleted file mode 100644 index c952cf2d4e1..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move03.fail.cpp +++ /dev/null @@ -1,55 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Can't copy from lvalue - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - std::unique_ptr<A[], Deleter> s(new A[3]); - A* p = s.get(); - std::unique_ptr<A[], Deleter> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp deleted file mode 100644 index 0d091ff346d..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move04.fail.cpp +++ /dev/null @@ -1,55 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -// test move ctor. Can't copy from const lvalue - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - const std::unique_ptr<A[], Deleter> s(new A[3]); - A* p = s.get(); - std::unique_ptr<A[], Deleter> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.cpp deleted file mode 100644 index d175fbf93ad..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert01.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp deleted file mode 100644 index 1838511b492..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert02.fail.cpp +++ /dev/null @@ -1,61 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - 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); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp deleted file mode 100644 index 36ad75d8331..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert03.fail.cpp +++ /dev/null @@ -1,78 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B[], CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A[], CDeleter<A>&> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.cpp deleted file mode 100644 index 3a19bde9288..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert04.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp deleted file mode 100644 index bda2a70a4ef..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert05.fail.cpp +++ /dev/null @@ -1,61 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - 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); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp deleted file mode 100644 index fba895137b0..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert06.fail.cpp +++ /dev/null @@ -1,78 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B[], CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A[], CDeleter<A>&> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.cpp deleted file mode 100644 index 24c646988f0..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert07.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp deleted file mode 100644 index 486d90825d9..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert08.fail.cpp +++ /dev/null @@ -1,61 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -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); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp deleted file mode 100644 index e4cbef5c056..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert09.fail.cpp +++ /dev/null @@ -1,78 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - const std::unique_ptr<B[], CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A[], CDeleter<A>&> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.cpp deleted file mode 100644 index 73423d1b375..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert10.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp deleted file mode 100644 index cfc097ba0b8..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert11.fail.cpp +++ /dev/null @@ -1,61 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -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); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp deleted file mode 100644 index fdb088250b9..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert12.fail.cpp +++ /dev/null @@ -1,78 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - const std::unique_ptr<B[], CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A[], CDeleter<A>&> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.cpp deleted file mode 100644 index d9ef8e96fe8..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert13.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2(std::move(s)); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp deleted file mode 100644 index b4577a126c6..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert14.fail.cpp +++ /dev/null @@ -1,61 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[], Deleter<B[]> > s(new B); - A* p = s.get(); - std::unique_ptr<A[], Deleter<A[]> > s2(std::move(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); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp deleted file mode 100644 index 9325d07d0d0..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert15.fail.cpp +++ /dev/null @@ -1,78 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B[], CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A[], CDeleter<A>&> s2(std::move(s)); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.cpp deleted file mode 100644 index b090e593ec6..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert16.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[]> s(new B); - A* p = s.get(); - std::unique_ptr<A[]> s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp deleted file mode 100644 index b2af3c7a693..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert17.fail.cpp +++ /dev/null @@ -1,61 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B[], Deleter<B[]> > s(new B); - A* p = s.get(); - std::unique_ptr<A[], Deleter<A[]> > s2 = std::move(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); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp deleted file mode 100644 index d1c0e8a781e..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/move_convert18.fail.cpp +++ /dev/null @@ -1,78 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B[], CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A[], CDeleter<A>&> s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp deleted file mode 100644 index 9a8c17547bc..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/nullptr.pass.cpp +++ /dev/null @@ -1,46 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// unique_ptr(nullptr_t); - -#include <memory> -#include <cassert> - -// default unique_ptr ctor should only require default Deleter ctor -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(void*) {} -}; - -int main() -{ - { - std::unique_ptr<int[]> p(nullptr); - assert(p.get() == 0); - } - { - std::unique_ptr<int[], Deleter> p(nullptr); - assert(p.get() == 0); - assert(p.get_deleter().state() == 5); - } -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp deleted file mode 100644 index 4c316115083..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.fail.cpp +++ /dev/null @@ -1,36 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr<T[]>(pointer) ctor - -// unique_ptr<T[]>(pointer) ctor should require default Deleter ctor - -#include <memory> - -class Deleter -{ - - Deleter() {} - -public: - - Deleter(Deleter&) {} - Deleter& operator=(Deleter&) {} - - void operator()(void*) const {} -}; - -int main() -{ - std::unique_ptr<int[], Deleter> p(new int); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp deleted file mode 100644 index dab42f27741..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer01.pass.cpp +++ /dev/null @@ -1,63 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -// unique_ptr<T[]>(pointer) ctor should only require default Deleter ctor - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - std::unique_ptr<A[]> s(p); - assert(s.get() == p); - } - assert(A::count == 0); - { - A* p = new A[3]; - assert(A::count == 3); - std::unique_ptr<A[], Deleter> s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp deleted file mode 100644 index af7f27f73fc..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.fail.cpp +++ /dev/null @@ -1,29 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr<T[]>(pointer) ctor - -#include <memory> - -// unique_ptr<T[]>(pointer) ctor should require non-reference Deleter ctor -class Deleter -{ -public: - - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr<int[], Deleter&> p(new int); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp deleted file mode 100644 index 1afb1c32ce8..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer02.pass.cpp +++ /dev/null @@ -1,95 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr<T[]>(pointer) ctor - -// unique_ptr<T[]>(pointer) ctor shouldn't require complete type - -#include <memory> -#include <cassert> - -struct A; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p); -}; - -void check(int i); - -template <class D = std::default_delete<A[]> > -struct B -{ - std::unique_ptr<A[], D> a_; - explicit B(A*); - ~B(); - - A* get() const {return a_.get();} - D& get_deleter() {return a_.get_deleter();} -}; - -A* get(); - -int main() -{ - { - A* p = get(); - check(3); - B<> s(p); - assert(s.get() == p); - } - check(0); - { - A* p = get(); - check(3); - B<Deleter> s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - check(0); -} - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -A* get() {return new A[3];} - -void Deleter::operator()(A* p) {delete [] p;} - -void check(int i) -{ - assert(A::count == i); -} - -template <class D> -B<D>::B(A* a) : a_(a) {} - -template <class D> -B<D>::~B() {} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp deleted file mode 100644 index 31f7ce367e3..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer03.fail.cpp +++ /dev/null @@ -1,23 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr<T[]>(pointer) ctor - -// unique_ptr<T[]>(pointer) ctor should require non-pointer Deleter - -#include <memory> - -int main() -{ - std::unique_ptr<int[], void (*)(void*)> p(new int); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.cpp deleted file mode 100644 index 591144f7aa5..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer04.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -// unique_ptr(pointer) ctor should not work with derived pointers - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - B* p = new B[3]; - std::unique_ptr<A[]> s(p); - } - { - B* p = new B[3]; - std::unique_ptr<A[], Deleter> s(p); - } -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp deleted file mode 100644 index 2d62bccdce5..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter01.pass.cpp +++ /dev/null @@ -1,43 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr(pointer, deleter()) only requires MoveConstructible deleter - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - std::unique_ptr<A[], Deleter<A[]> > s(p, Deleter<A[]>()); - assert(s.get() == p); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.pass.cpp deleted file mode 100644 index 914076b50f4..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter02.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr(pointer, d) requires CopyConstructible deleter - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - Deleter d; - std::unique_ptr<A[], Deleter> s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - d.set_state(6); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.pass.cpp deleted file mode 100644 index a6f535f38f0..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter03.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr<T[], D&>(pointer, d) does not requires CopyConstructible deleter - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - Deleter d; - std::unique_ptr<A[], Deleter&> s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - d.set_state(6); - assert(s.get_deleter().state() == 6); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp deleted file mode 100644 index b635d507b2e..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.fail.cpp +++ /dev/null @@ -1,55 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr<T, const D&>(pointer, D()) should not compile - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) const {delete [] p;} -}; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - std::unique_ptr<A[], const Deleter&> s(p, Deleter()); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.pass.cpp deleted file mode 100644 index a4c917c1af7..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter04.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr<T[], const D&>(pointer, d) does not requires CopyConstructible deleter - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) const {delete [] p;} -}; - -int main() -{ - { - A* p = new A[3]; - assert(A::count == 3); - Deleter d; - std::unique_ptr<A[], const Deleter&> s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.cpp deleted file mode 100644 index 0e03a7da07f..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.ctor/pointer_deleter05.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -// unique_ptr(pointer, deleter) should not work with derived pointers - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -class Deleter -{ - int state_; - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete [] p;} -}; - -int main() -{ - B* p = new B[3]; - std::unique_ptr<A[], Deleter> s(p, Deleter()); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp deleted file mode 100644 index d79a4e396ee..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/release.pass.cpp +++ /dev/null @@ -1,27 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test release - -#include <memory> -#include <cassert> - -int main() -{ - std::unique_ptr<int[]> p(new int[3]); - int* i = p.get(); - int* j = p.release(); - assert(p.get() == 0); - assert(i == j); - delete [] j; -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp deleted file mode 100644 index 8233ca0e143..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset1.pass.cpp +++ /dev/null @@ -1,48 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test reset - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A[]> p(new A[3]); - assert(A::count == 3); - A* i = p.get(); - p.reset(); - assert(A::count == 0); - assert(p.get() == 0); - } - assert(A::count == 0); - { - std::unique_ptr<A[]> p(new A[4]); - assert(A::count == 4); - A* i = p.get(); - p.reset(new A[5]); - assert(A::count == 5); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp deleted file mode 100644 index bca6cb2470a..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/reset2.fail.cpp +++ /dev/null @@ -1,64 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test reset - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<A[]> p(new A); - assert(A::count == 1); - assert(B::count == 0); - A* i = p.get(); - p.reset(new B); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); - { - std::unique_ptr<A[]> p(new B); - assert(A::count == 1); - assert(B::count == 1); - A* i = p.get(); - p.reset(new B); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.pass.cpp deleted file mode 100644 index e9754cc0f22..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.modifiers/swap.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test swap - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - int state_; - static int count; - A() : state_(0) {++count;} - explicit A(int i) : state_(i) {++count;} - A(const A& a) : state_(a.state_) {++count;} - A& operator=(const A& a) {state_ = a.state_; return *this;} - ~A() {--count;} - - friend bool operator==(const A& x, const A& y) - {return x.state_ == y.state_;} -}; - -int A::count = 0; - -int main() -{ - { - A* p1 = new A[3]; - std::unique_ptr<A[], Deleter<A[]> > s1(p1, Deleter<A[]>(1)); - A* p2 = new A[3]; - std::unique_ptr<A[], Deleter<A[]> > s2(p2, Deleter<A[]>(2)); - assert(s1.get() == p1); - assert(s1.get_deleter().state() == 1); - assert(s2.get() == p2); - assert(s2.get_deleter().state() == 2); - s1.swap(s2); - assert(s1.get() == p2); - assert(s1.get_deleter().state() == 2); - assert(s2.get() == p1); - assert(s2.get_deleter().state() == 1); - assert(A::count == 6); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp deleted file mode 100644 index 46ba1395bb8..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/dereference.fail.cpp +++ /dev/null @@ -1,23 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test op*() - -#include <memory> -#include <cassert> - -int main() -{ - std::unique_ptr<int[]> p(new int(3)); - assert(*p == 3); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp deleted file mode 100644 index 9ec9b9527e8..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/explicit_bool.pass.cpp +++ /dev/null @@ -1,39 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test op*() - -#include <memory> -#include <cassert> - -int main() -{ - { - std::unique_ptr<int[]> p(new int [3]); - if (p) - ; - else - assert(false); - if (!p) - assert(false); - } - { - std::unique_ptr<int[]> p; - if (!p) - ; - else - assert(false); - if (p) - assert(false); - } -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp deleted file mode 100644 index 2ae0659adc2..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get.pass.cpp +++ /dev/null @@ -1,24 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test get - -#include <memory> -#include <cassert> - -int main() -{ - int* p = new int[3]; - std::unique_ptr<int[]> s(p); - assert(s.get() == p); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp deleted file mode 100644 index 4496740715a..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/get_deleter.pass.cpp +++ /dev/null @@ -1,37 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test get_deleter() - -#include <memory> -#include <cassert> - -struct Deleter -{ - void operator()(void*) {} - - int test() {return 5;} - int test() const {return 6;} -}; - -int main() -{ - { - std::unique_ptr<int[], Deleter> p; - assert(p.get_deleter().test() == 5); - } - { - const std::unique_ptr<int[], Deleter> p; - assert(p.get_deleter().test() == 6); - } -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp deleted file mode 100644 index 519eae688ec..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/index.pass.cpp +++ /dev/null @@ -1,47 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test op[](size_t) - -#include <memory> -#include <cassert> - -class A -{ - int state_; - static int next_; -public: - A() : state_(++next_) {} - int get() const {return state_;} - - friend bool operator==(const A& x, int y) - {return x.state_ == y;} - - A& operator=(int i) {state_ = i; return *this;} -}; - -int A::next_ = 0; - -int main() -{ - std::unique_ptr<A[]> p(new A[3]); - assert(p[0] == 1); - assert(p[1] == 2); - assert(p[2] == 3); - p[0] = 3; - p[1] = 2; - p[2] = 1; - assert(p[0] == 3); - assert(p[1] == 2); - assert(p[2] == 1); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp deleted file mode 100644 index 1c90ba76af3..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.runtime/unique.ptr.runtime.observers/op_arrow.fail.cpp +++ /dev/null @@ -1,30 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test op->() - -#include <memory> -#include <cassert> - -struct A -{ - int i_; - - A() : i_(7) {} -}; - -int main() -{ - std::unique_ptr<A[]> p(new A); - assert(p->i_ == 7); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp deleted file mode 100644 index 8721062c6d0..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp +++ /dev/null @@ -1,34 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr::pointer type - -#include <memory> -#include <type_traits> - -struct Deleter -{ - struct pointer {}; -}; - -int main() -{ - { - typedef std::unique_ptr<int> P; - static_assert((std::is_same<P::pointer, int*>::value), ""); - } - { - typedef std::unique_ptr<int, Deleter> P; - static_assert((std::is_same<P::pointer, Deleter::pointer>::value), ""); - } -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp deleted file mode 100644 index 57724ae10a7..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.fail.cpp +++ /dev/null @@ -1,38 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> -#include <cassert> - -// Can't copy from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> s(new A); - std::unique_ptr<A> s2; - s2 = s; - } -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp deleted file mode 100644 index 6641a5885af..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move01.pass.cpp +++ /dev/null @@ -1,74 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -// test move assignment. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> s1(new A); - A* p = s1.get(); - std::unique_ptr<A> s2(new A); - assert(A::count == 2); - s2 = std::move(s1); - assert(A::count == 1); - assert(s2.get() == p); - assert(s1.get() == 0); - } - assert(A::count == 0); - { - std::unique_ptr<A, Deleter<A> > s1(new A, Deleter<A>(5)); - A* p = s1.get(); - std::unique_ptr<A, Deleter<A> > s2(new A); - assert(A::count == 2); - s2 = std::move(s1); - assert(s2.get() == p); - assert(s1.get() == 0); - assert(A::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s1.get_deleter().state() == 0); - } - assert(A::count == 0); - { - CDeleter<A> d1(5); - std::unique_ptr<A, CDeleter<A>&> s1(new A, d1); - A* p = s1.get(); - CDeleter<A> d2(6); - std::unique_ptr<A, CDeleter<A>&> s2(new A, d2); - s2 = std::move(s1); - assert(s2.get() == p); - assert(s1.get() == 0); - assert(A::count == 1); - assert(d1.state() == 5); - assert(d2.state() == 5); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp deleted file mode 100644 index 5046fd8aae6..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move02.fail.cpp +++ /dev/null @@ -1,38 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> -#include <cassert> - -// Can't copy from const lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - const std::unique_ptr<A> s(new A); - std::unique_ptr<A> s2; - s2 = s; - } -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.cpp deleted file mode 100644 index aa4fdb8a96b..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move03.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> -#include <cassert> - -// Can't copy from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - std::unique_ptr<A, Deleter> s(new A); - A* p = s.get(); - std::unique_ptr<A, Deleter> s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.cpp deleted file mode 100644 index e0d7c891c80..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move04.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <cassert> - -// test move ctor. Can't copy from const lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - const std::unique_ptr<A, Deleter> s(new A); - A* p = s.get(); - std::unique_ptr<A, Deleter> s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.cpp deleted file mode 100644 index 8940dbe9c07..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> -#include <cassert> - -// Can't assign from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B> s(new B); - A* p = s.get(); - std::unique_ptr<A> s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp deleted file mode 100644 index 64d7b6b9a75..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert01.pass.cpp +++ /dev/null @@ -1,55 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B> s(new B); - A* p = s.get(); - std::unique_ptr<A> s2(new A); - assert(A::count == 2); - s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.cpp deleted file mode 100644 index 1ab0779b1e5..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -// Can't assign from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B, Deleter<B> > s(new B); - A* p = s.get(); - std::unique_ptr<A, Deleter<A> > s2; - 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); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.pass.cpp deleted file mode 100644 index ff59ad4631c..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert02.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B, Deleter<B> > s(new B, Deleter<B>(5)); - A* p = s.get(); - std::unique_ptr<A, Deleter<A> > s2(new A); - assert(A::count == 2); - s2 = std::move(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); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp deleted file mode 100644 index e06b9d0af7a..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.fail.cpp +++ /dev/null @@ -1,61 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from lvalue - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - Deleter<B> db(5); - std::unique_ptr<B, Deleter<B>&> s(new B, db); - A* p = s.get(); - Deleter<A> da(6); - std::unique_ptr<A, Deleter<A>&> s2(new A, da); - 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(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp deleted file mode 100644 index d726a830b6e..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert03.pass.cpp +++ /dev/null @@ -1,62 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// test converting move assignment with reference deleters - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - CDeleter<B> db(5); - std::unique_ptr<B, CDeleter<B>&> s(new B, db); - A* p = s.get(); - CDeleter<A> da(6); - std::unique_ptr<A, CDeleter<A>&> s2(new A, da); - s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - assert(s.get_deleter().state() == 5); - assert(s2.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.cpp deleted file mode 100644 index ab33785bd66..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert04.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -#include <memory> -#include <cassert> - -// Can't assign from const lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B> s(new B); - A* p = s.get(); - std::unique_ptr<A> s2; - s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.cpp deleted file mode 100644 index 50c553e521a..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert05.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from const lvalue - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B, Deleter<B> > s(new B); - A* p = s.get(); - std::unique_ptr<A, Deleter<A> > s2; - 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); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp deleted file mode 100644 index 541e10b8b74..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert06.fail.cpp +++ /dev/null @@ -1,61 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Can't assign from const lvalue - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - Deleter<B> db(5); - const std::unique_ptr<B, Deleter<B>&> s(new B, db); - A* p = s.get(); - Deleter<A> da(6); - std::unique_ptr<A, Deleter<A>&> s2(new A, da); - 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(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp deleted file mode 100644 index f7e128beb81..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/move_convert13.fail.cpp +++ /dev/null @@ -1,35 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move assignment - -// Do not convert from an array unique_ptr - -#include <memory> -#include <cassert> - -struct A -{ -}; - -struct Deleter -{ - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr<A[], Deleter> s; - std::unique_ptr<A, Deleter> s2; - s2 = std::move(s); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp deleted file mode 100644 index e2d7956cda6..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/null.pass.cpp +++ /dev/null @@ -1,41 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> -#include <cassert> - -// test assignment from null - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> s2(new A); - assert(A::count == 1); - s2 = 0; - assert(A::count == 0); - assert(s2.get() == 0); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp deleted file mode 100644 index fb158495199..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.asgn/nullptr.pass.cpp +++ /dev/null @@ -1,41 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move assignment - -#include <memory> -#include <cassert> - -// test assignment from null - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> s2(new A); - assert(A::count == 1); - s2 = nullptr; - assert(A::count == 0); - assert(s2.get() == 0); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.pass.cpp deleted file mode 100644 index a23f029c0fd..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> -#include <cassert> - -// template <class U> explicit unique_ptr(auto_ptr<U>&); - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - B* p = new B; - std::auto_ptr<B> ap(p); - std::unique_ptr<A> up(std::move(ap)); - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); - { - B* p = new B; - std::auto_ptr<B> ap(p); - std::unique_ptr<A> up; - up = std::move(ap); - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.cpp deleted file mode 100644 index 1f317c78245..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer01.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> -#include <cassert> - -// template <class U> explicit unique_ptr(auto_ptr<U>&); - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B -// : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - B* p = new B; - std::auto_ptr<B> ap(p); - std::unique_ptr<A> up(ap); - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); - { - B* p = new B; - std::auto_ptr<B> ap(p); - std::unique_ptr<A> up; - up = ap; - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp deleted file mode 100644 index 2dd5ea30049..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/auto_pointer02.fail.cpp +++ /dev/null @@ -1,61 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> -#include <cassert> - -// template <class U> explicit unique_ptr(auto_ptr<U>&); - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct Deleter -{ - template <class T> - void operator()(T*) {} -}; - -int main() -{ - { - B* p = new B; - std::auto_ptr<B> ap(p); - std::unique_ptr<A, Deleter> up(ap); - assert(up.get() == p); - assert(ap.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp deleted file mode 100644 index 2ffe1be190e..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.fail.cpp +++ /dev/null @@ -1,35 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr default ctor - -#include <memory> - -// default unique_ptr ctor should require default Deleter ctor -class Deleter -{ - - Deleter() {} - -public: - - Deleter(Deleter&) {} - Deleter& operator=(Deleter&) {} - - void operator()(void*) const {} -}; - -int main() -{ - std::unique_ptr<int, Deleter> p; -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp deleted file mode 100644 index e63db5cb718..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default01.pass.cpp +++ /dev/null @@ -1,46 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr default ctor - -#include <memory> -#include <cassert> - -// default unique_ptr ctor should only require default Deleter ctor -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(void*) {} -}; - -int main() -{ - { - std::unique_ptr<int> p; - assert(p.get() == 0); - } - { - std::unique_ptr<int, Deleter> p; - assert(p.get() == 0); - assert(p.get_deleter().state() == 5); - } -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp deleted file mode 100644 index 69075014341..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.fail.cpp +++ /dev/null @@ -1,29 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr default ctor - -#include <memory> - -// default unique_ptr ctor should require non-reference Deleter ctor -class Deleter -{ -public: - - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr<int, Deleter&> p; -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp deleted file mode 100644 index e9af7e28525..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default02.pass.cpp +++ /dev/null @@ -1,84 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test default unique_ptr ctor - -#include <memory> -#include <cassert> - -// default unique_ptr ctor shouldn't require complete type - -struct A; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p); -}; - -void check(int i); - -template <class D = std::default_delete<A> > -struct B -{ - std::unique_ptr<A, D> a_; - B() {} - ~B(); - - A* get() const {return a_.get();} - D& get_deleter() {return a_.get_deleter();} -}; - -int main() -{ - { - B<> s; - assert(s.get() == 0); - } - check(0); - { - B<Deleter> s; - assert(s.get() == 0); - assert(s.get_deleter().state() == 5); - } - check(0); -} - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -void Deleter::operator()(A* p) {delete p;} - -void check(int i) -{ - assert(A::count == i); -} - -template <class D> -B<D>::~B() {} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp deleted file mode 100644 index 78f6e73a1d5..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/default03.fail.cpp +++ /dev/null @@ -1,23 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr default ctor - -#include <memory> - -// default unique_ptr ctor should require non-pointer Deleter - -int main() -{ - std::unique_ptr<int, void (*)(void*)> p; -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp deleted file mode 100644 index 68ad589b114..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.fail.cpp +++ /dev/null @@ -1,42 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <cassert> - -// test move ctor. Can't copy from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> s(new A); - A* p = s.get(); - std::unique_ptr<A> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp deleted file mode 100644 index 65b1694b3ea..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move01.pass.cpp +++ /dev/null @@ -1,141 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <cassert> - -// test move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -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) - { - state_ = r.state_; - 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) - : state_(d.state()) {d.set_state(0);} - -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;} - - void operator()(T* p) {delete p;} -}; - -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - std::unique_ptr<A> s(new A); - A* p = s.get(); - std::unique_ptr<A> s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); - { - std::unique_ptr<A, Deleter<A> > s(new A); - A* p = s.get(); - std::unique_ptr<A, Deleter<A> > s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(s2.get_deleter().state() == 5); - assert(s.get_deleter().state() == 0); - } - assert(A::count == 0); - { - CDeleter d; - std::unique_ptr<A, CDeleter&> s(new A, d); - A* p = s.get(); - std::unique_ptr<A, CDeleter&> s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp deleted file mode 100644 index 897b889d677..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.fail.cpp +++ /dev/null @@ -1,42 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <cassert> - -// test move ctor. Can't copy from const lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - const std::unique_ptr<A> s(new A); - A* p = s.get(); - std::unique_ptr<A> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp deleted file mode 100644 index 4b997df95a0..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move02.pass.cpp +++ /dev/null @@ -1,143 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <cassert> - -// test move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -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) - { - state_ = r.state_; - 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) - : state_(d.state()) {d.set_state(0);} - -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;} - - void operator()(T* p) {delete p;} -}; - -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) {delete p;} -}; - -std::unique_ptr<A> -source1() -{ - return std::unique_ptr<A>(new A); -} - -void sink1(std::unique_ptr<A> p) -{ -} - -std::unique_ptr<A, Deleter<A> > -source2() -{ - return std::unique_ptr<A, Deleter<A> >(new A); -} - -void sink2(std::unique_ptr<A, Deleter<A> > p) -{ -} - -std::unique_ptr<A, CDeleter&> -source3() -{ - static CDeleter d; - return std::unique_ptr<A, CDeleter&>(new A, d); -} - -void sink3(std::unique_ptr<A, CDeleter&> p) -{ -} - -int main() -{ - sink1(source1()); - sink2(source2()); - sink3(source3()); - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp deleted file mode 100644 index 7fb1a0a7481..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move03.fail.cpp +++ /dev/null @@ -1,55 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <cassert> - -// test move ctor. Can't copy from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - std::unique_ptr<A, Deleter> s(new A); - A* p = s.get(); - std::unique_ptr<A, Deleter> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp deleted file mode 100644 index 671e343fd7f..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move04.fail.cpp +++ /dev/null @@ -1,55 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr move ctor - -#include <memory> -#include <cassert> - -// test move ctor. Can't copy from const lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - const std::unique_ptr<A, Deleter> s(new A); - A* p = s.get(); - std::unique_ptr<A, Deleter> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp deleted file mode 100644 index 5cd1b18001d..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.fail.cpp +++ /dev/null @@ -1,55 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <cassert> - -// Can't construct from lvalue - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B> s(new B); - A* p = s.get(); - std::unique_ptr<A> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.pass.cpp deleted file mode 100644 index 42917b1dea2..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert01.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B> s(new B); - A* p = s.get(); - std::unique_ptr<A> s2(std::move(s)); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp deleted file mode 100644 index 8f1259229bd..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.fail.cpp +++ /dev/null @@ -1,61 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - 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); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp deleted file mode 100644 index f72efb98eb2..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert02.pass.cpp +++ /dev/null @@ -1,61 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B, Deleter<B> > s(new B, Deleter<B>(5)); - A* p = s.get(); - std::unique_ptr<A, Deleter<A> > s2(std::move(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); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp deleted file mode 100644 index c9076af41a4..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.fail.cpp +++ /dev/null @@ -1,78 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B, CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A, CDeleter<A>&> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp deleted file mode 100644 index 7463c38e7f0..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert03.pass.cpp +++ /dev/null @@ -1,78 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B, CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A, CDeleter<A>&> s2(std::move(s)); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.cpp deleted file mode 100644 index 7487e2db39b..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B> s(new B); - A* p = s.get(); - std::unique_ptr<A> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.pass.cpp deleted file mode 100644 index 18443a46515..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert04.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B> s(new B); - A* p = s.get(); - std::unique_ptr<A> s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp deleted file mode 100644 index 630fcb77ab2..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.fail.cpp +++ /dev/null @@ -1,50 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - std::unique_ptr<B, Deleter<B> > s(new B); - std::unique_ptr<A, Deleter<A> > s2 = s; -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp deleted file mode 100644 index a8a9c760bb0..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert05.pass.cpp +++ /dev/null @@ -1,61 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<B, Deleter<B> > s(new B, Deleter<B>(5)); - A* p = s.get(); - std::unique_ptr<A, Deleter<A> > s2 = std::move(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); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp deleted file mode 100644 index 04bf0f92ea4..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.fail.cpp +++ /dev/null @@ -1,78 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B, CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A, CDeleter<A>&> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp deleted file mode 100644 index 84cef783ffb..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert06.pass.cpp +++ /dev/null @@ -1,78 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - std::unique_ptr<B, CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A, CDeleter<A>&> s2 = std::move(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.cpp deleted file mode 100644 index da15c5c2024..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B> s(new B); - A* p = s.get(); - std::unique_ptr<A> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp deleted file mode 100644 index f80931022bf..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert07.pass.cpp +++ /dev/null @@ -1,62 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - CDeleter<B> b(5); - std::unique_ptr<B, CDeleter<B>&> s(new B, b); - A* p = s.get(); - std::unique_ptr<A, CDeleter<A> > s2 = std::move(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() == 5); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp deleted file mode 100644 index 4d47bfd7bae..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert08.fail.cpp +++ /dev/null @@ -1,117 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -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) - { - state_ = r.state_; - 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) - : state_(d.state()) {d.set_state(0);} - -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;} - - void operator()(T* p) {delete p;} -}; - -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); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp deleted file mode 100644 index d5687985d34..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert09.fail.cpp +++ /dev/null @@ -1,78 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - const std::unique_ptr<B, CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A, CDeleter<A>&> s2(s); - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.cpp deleted file mode 100644 index 50647b93d77..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert10.fail.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// implicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<B> s(new B); - A* p = s.get(); - std::unique_ptr<A> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp deleted file mode 100644 index 0ca3d8c7f0f..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert11.fail.cpp +++ /dev/null @@ -1,117 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Implicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -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) - { - state_ = r.state_; - 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) - : state_(d.state()) {d.set_state(0);} - -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;} - - void operator()(T* p) {delete p;} -}; - -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); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp deleted file mode 100644 index e1eff8dd92b..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert12.fail.cpp +++ /dev/null @@ -1,78 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -#include <memory> -#include <cassert> - -// test converting move ctor. Should only require a MoveConstructible deleter, or if -// deleter is a reference, not even that. -// Explicit version - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -template <class T> -class CDeleter -{ - int state_; - - CDeleter(CDeleter&); - CDeleter& operator=(CDeleter&); -public: - - CDeleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - CDeleter<A> d; - const std::unique_ptr<B, CDeleter<A>&> s(new B, d); - A* p = s.get(); - std::unique_ptr<A, CDeleter<A>&> s2 = s; - assert(s2.get() == p); - assert(s.get() == 0); - assert(A::count == 1); - assert(B::count == 1); - d.set_state(6); - assert(s2.get_deleter().state() == d.state()); - assert(s.get_deleter().state() == d.state()); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp deleted file mode 100644 index cf03a2bbfc9..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/move_convert13.fail.cpp +++ /dev/null @@ -1,34 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr converting move ctor - -// Do not convert from an array unique_ptr - -#include <memory> -#include <cassert> - -struct A -{ -}; - -struct Deleter -{ - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr<A[], Deleter> s; - std::unique_ptr<A, Deleter> s2(std::move(s)); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp deleted file mode 100644 index 67a48a3e7a1..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/nullptr.pass.cpp +++ /dev/null @@ -1,46 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// unique_ptr(nullptr_t); - -#include <memory> -#include <cassert> - -// default unique_ptr ctor should only require default Deleter ctor -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(void*) {} -}; - -int main() -{ - { - std::unique_ptr<int> p(nullptr); - assert(p.get() == 0); - } - { - std::unique_ptr<int, Deleter> p(nullptr); - assert(p.get() == 0); - assert(p.get_deleter().state() == 5); - } -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp deleted file mode 100644 index 1af04b2c003..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.fail.cpp +++ /dev/null @@ -1,35 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> - -// unique_ptr(pointer) ctor should require default Deleter ctor -class Deleter -{ - - Deleter() {} - -public: - - Deleter(Deleter&) {} - Deleter& operator=(Deleter&) {} - - void operator()(void*) const {} -}; - -int main() -{ - std::unique_ptr<int, Deleter> p(new int); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp deleted file mode 100644 index e5fff774b79..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer01.pass.cpp +++ /dev/null @@ -1,63 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> -#include <cassert> - -// unique_ptr(pointer) ctor should only require default Deleter ctor - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - A* p = new A; - assert(A::count == 1); - std::unique_ptr<A> s(p); - assert(s.get() == p); - } - assert(A::count == 0); - { - A* p = new A; - assert(A::count == 1); - std::unique_ptr<A, Deleter> s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp deleted file mode 100644 index 9b7dd8c70f2..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.fail.cpp +++ /dev/null @@ -1,29 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> - -// unique_ptr(pointer) ctor should require non-reference Deleter ctor -class Deleter -{ -public: - - void operator()(void*) {} -}; - -int main() -{ - std::unique_ptr<int, Deleter&> p(new int); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp deleted file mode 100644 index a226e87d64a..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer02.pass.cpp +++ /dev/null @@ -1,95 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> -#include <cassert> - -// unique_ptr(pointer) ctor shouldn't require complete type - -struct A; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p); -}; - -void check(int i); - -template <class D = std::default_delete<A> > -struct B -{ - std::unique_ptr<A, D> a_; - explicit B(A*); - ~B(); - - A* get() const {return a_.get();} - D& get_deleter() {return a_.get_deleter();} -}; - -A* get(); - -int main() -{ - { - A* p = get(); - check(1); - B<> s(p); - assert(s.get() == p); - } - check(0); - { - A* p = get(); - check(1); - B<Deleter> s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - check(0); -} - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -A* get() {return new A;} - -void Deleter::operator()(A* p) {delete p;} - -void check(int i) -{ - assert(A::count == i); -} - -template <class D> -B<D>::B(A* a) : a_(a) {} - -template <class D> -B<D>::~B() {} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp deleted file mode 100644 index a917d87eeed..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.fail.cpp +++ /dev/null @@ -1,23 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> - -// unique_ptr(pointer) ctor should require non-pointer Deleter - -int main() -{ - std::unique_ptr<int, void (*)(void*)> p(new int); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp deleted file mode 100644 index 42fc0945391..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer03.pass.cpp +++ /dev/null @@ -1,78 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> -#include <cassert> - -// unique_ptr(pointer) ctor should work with derived pointers - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - B* p = new B; - assert(A::count == 1); - assert(B::count == 1); - std::unique_ptr<A> s(p); - assert(s.get() == p); - } - assert(A::count == 0); - assert(B::count == 0); - { - B* p = new B; - assert(A::count == 1); - assert(B::count == 1); - std::unique_ptr<A, Deleter> s(p); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp deleted file mode 100644 index 130f91d6216..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter01.pass.cpp +++ /dev/null @@ -1,99 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> -#include <cassert> - -// unique_ptr(pointer, deleter()) only requires MoveConstructible deleter - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -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) - { - state_ = r.state_; - 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) - : state_(d.state()) {d.set_state(0);} - -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;} - - void operator()(T* p) {delete p;} -}; - -int main() -{ - { - A* p = new A; - assert(A::count == 1); - std::unique_ptr<A, Deleter<A> > s(p, Deleter<A>()); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.pass.cpp deleted file mode 100644 index 421bec55f99..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter02.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> -#include <cassert> - -// unique_ptr(pointer, d) requires CopyConstructible deleter - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - A* p = new A; - assert(A::count == 1); - Deleter d; - std::unique_ptr<A, Deleter> s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - d.set_state(6); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.pass.cpp deleted file mode 100644 index bce79dbb1a9..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter03.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> -#include <cassert> - -// unique_ptr<T, D&>(pointer, d) does not requires CopyConstructible deleter - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - A* p = new A; - assert(A::count == 1); - Deleter d; - std::unique_ptr<A, Deleter&> s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - d.set_state(6); - assert(s.get_deleter().state() == 6); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp deleted file mode 100644 index 7cacd1fda9f..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.fail.cpp +++ /dev/null @@ -1,55 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> -#include <cassert> - -// unique_ptr<T, const D&>(pointer, D()) should not compile - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) const {delete p;} -}; - -int main() -{ - { - A* p = new A; - assert(A::count == 1); - std::unique_ptr<A, const Deleter&> s(p, Deleter()); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.pass.cpp deleted file mode 100644 index a7750fcb9f0..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter04.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer) ctor - -#include <memory> -#include <cassert> - -// unique_ptr<T, const D&>(pointer, d) does not requires CopyConstructible deleter - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -class Deleter -{ - int state_; - - Deleter(const Deleter&); - Deleter& operator=(const Deleter&); -public: - - Deleter() : state_(5) {} - - int state() const {return state_;} - void set_state(int s) {state_ = s;} - - void operator()(A* p) const {delete p;} -}; - -int main() -{ - { - A* p = new A; - assert(A::count == 1); - Deleter d; - std::unique_ptr<A, const Deleter&> s(p, d); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp deleted file mode 100644 index 1a83258e1e4..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter05.pass.cpp +++ /dev/null @@ -1,66 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -#include <memory> -#include <cassert> - -// unique_ptr(pointer, deleter) should work with derived pointers - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -class Deleter -{ - int state_; - -public: - Deleter() : state_(5) {} - - int state() const {return state_;} - - void operator()(A* p) {delete p;} -}; - -int main() -{ - { - B* p = new B; - assert(A::count == 1); - assert(B::count == 1); - std::unique_ptr<A, Deleter> s(p, Deleter()); - assert(s.get() == p); - assert(s.get_deleter().state() == 5); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp deleted file mode 100644 index ed68052cd3b..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.ctor/pointer_deleter06.pass.cpp +++ /dev/null @@ -1,39 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test unique_ptr(pointer, deleter) ctor - -#include <memory> -#include <cassert> - -// unique_ptr(pointer, deleter) should work with function pointers -// unique_ptr<void> should work - -bool my_free_called = false; - -void my_free(void*) -{ - my_free_called = true; -} - -int main() -{ - { - int i = 0; - std::unique_ptr<void, void (*)(void*)> s(&i, my_free); - assert(s.get() == &i); - assert(s.get_deleter() == my_free); - assert(!my_free_called); - } - assert(my_free_called); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp deleted file mode 100644 index 064f38c5f16..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.dtor/null.pass.cpp +++ /dev/null @@ -1,44 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// The deleter is not called if get() == 0 - -#include <memory> -#include <cassert> - -class Deleter -{ - int state_; - - Deleter(Deleter&); - Deleter& operator=(Deleter&); - -public: - Deleter() : state_(0) {} - - int state() const {return state_;} - - void operator()(void*) {++state_;} -}; - -int main() -{ - Deleter d; - assert(d.state() == 0); - { - std::unique_ptr<int, Deleter&> p(0, d); - assert(p.get() == 0); - assert(&p.get_deleter() == &d); - } - assert(d.state() == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp deleted file mode 100644 index dadd4ecbe59..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/release.pass.cpp +++ /dev/null @@ -1,27 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test release - -#include <memory> -#include <cassert> - -int main() -{ - std::unique_ptr<int> p(new int(3)); - int* i = p.get(); - int* j = p.release(); - assert(p.get() == 0); - assert(i == j); - delete j; -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp deleted file mode 100644 index 4041fbb2675..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset1.pass.cpp +++ /dev/null @@ -1,48 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test reset - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> p(new A); - assert(A::count == 1); - A* i = p.get(); - p.reset(); - assert(A::count == 0); - assert(p.get() == 0); - } - assert(A::count == 0); - { - std::unique_ptr<A> p(new A); - assert(A::count == 1); - A* i = p.get(); - p.reset(new A); - assert(A::count == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp deleted file mode 100644 index 6acc3d75063..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset2.pass.cpp +++ /dev/null @@ -1,64 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test reset - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - std::unique_ptr<A> p(new A); - assert(A::count == 1); - assert(B::count == 0); - A* i = p.get(); - p.reset(new B); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); - { - std::unique_ptr<A> p(new B); - assert(A::count == 1); - assert(B::count == 1); - A* i = p.get(); - p.reset(new B); - assert(A::count == 1); - assert(B::count == 1); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp deleted file mode 100644 index 58b05efa25f..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/reset_self.pass.cpp +++ /dev/null @@ -1,29 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test reset against resetting self - -#include <memory> - -struct A -{ - std::unique_ptr<A> ptr_; - - A() : ptr_(this) {} - void reset() {ptr_.reset();} -}; - -int main() -{ - (new A)->reset(); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.pass.cpp deleted file mode 100644 index d0a03be8032..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.modifiers/swap.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test swap - -#include <memory> -#include <cassert> - -#include "../../deleter.h" - -struct A -{ - int state_; - static int count; - explicit A(int i) : state_(i) {++count;} - A(const A& a) : state_(a.state_) {++count;} - A& operator=(const A& a) {state_ = a.state_; return *this;} - ~A() {--count;} - - friend bool operator==(const A& x, const A& y) - {return x.state_ == y.state_;} -}; - -int A::count = 0; - -int main() -{ - { - A* p1 = new A(1); - std::unique_ptr<A, Deleter<A> > s1(p1, Deleter<A>(1)); - A* p2 = new A(2); - std::unique_ptr<A, Deleter<A> > s2(p2, Deleter<A>(2)); - assert(s1.get() == p1); - assert(*s1 == A(1)); - assert(s1.get_deleter().state() == 1); - assert(s2.get() == p2); - assert(*s2 == A(2)); - assert(s2.get_deleter().state() == 2); - s1.swap(s2); - assert(s1.get() == p2); - assert(*s1 == A(2)); - assert(s1.get_deleter().state() == 2); - assert(s2.get() == p1); - assert(*s2 == A(1)); - assert(s2.get_deleter().state() == 1); - assert(A::count == 2); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp deleted file mode 100644 index 9d0cfcaaf35..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/dereference.pass.cpp +++ /dev/null @@ -1,23 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test op*() - -#include <memory> -#include <cassert> - -int main() -{ - std::unique_ptr<int> p(new int(3)); - assert(*p == 3); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp deleted file mode 100644 index d5c7445b0d8..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/explicit_bool.pass.cpp +++ /dev/null @@ -1,39 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test op*() - -#include <memory> -#include <cassert> - -int main() -{ - { - std::unique_ptr<int> p(new int(3)); - if (p) - ; - else - assert(false); - if (!p) - assert(false); - } - { - std::unique_ptr<int> p; - if (!p) - ; - else - assert(false); - if (p) - assert(false); - } -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp deleted file mode 100644 index 24fa6beb427..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get.pass.cpp +++ /dev/null @@ -1,24 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test get - -#include <memory> -#include <cassert> - -int main() -{ - int* p = new int; - std::unique_ptr<int> s(p); - assert(s.get() == p); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp deleted file mode 100644 index 5ed8a22b14c..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/get_deleter.pass.cpp +++ /dev/null @@ -1,37 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test get_deleter() - -#include <memory> -#include <cassert> - -struct Deleter -{ - void operator()(void*) {} - - int test() {return 5;} - int test() const {return 6;} -}; - -int main() -{ - { - std::unique_ptr<int, Deleter> p; - assert(p.get_deleter().test() == 5); - } - { - const std::unique_ptr<int, Deleter> p; - assert(p.get_deleter().test() == 6); - } -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp deleted file mode 100644 index 21e829cbc44..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/index.fail.cpp +++ /dev/null @@ -1,47 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test op[](size_t) - -#include <memory> -#include <cassert> - -class A -{ - int state_; - static int next_; -public: - A() : state_(++next_) {} - int get() const {return state_;} - - friend bool operator==(const A& x, int y) - {return x.state_ == y;} - - A& operator=(int i) {state_ = i; return *this;} -}; - -int A::next_ = 0; - -int main() -{ - std::unique_ptr<A> p(new A[3]); - assert(p[0] == 1); - assert(p[1] == 2); - assert(p[2] == 3); - p[0] = 3; - p[1] = 2; - p[2] = 1; - assert(p[0] == 3); - assert(p[1] == 2); - assert(p[2] == 1); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp deleted file mode 100644 index 47de8f66ed2..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.single/unique.ptr.single.observers/op_arrow.pass.cpp +++ /dev/null @@ -1,30 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// test op->() - -#include <memory> -#include <cassert> - -struct A -{ - int i_; - - A() : i_(7) {} -}; - -int main() -{ - std::unique_ptr<A> p(new A); - assert(p->i_ == 7); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp deleted file mode 100644 index 22ae217a61d..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.special/cmp_nullptr.pass.cpp +++ /dev/null @@ -1,69 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template <class T, class D> -// bool operator==(const unique_ptr<T, D>& x, nullptr_t) noexcept; -// template <class T, class D> -// bool operator==(nullptr_t, const unique_ptr<T, D>& y) noexcept; -// template <class T, class D> -// bool operator!=(const unique_ptr<T, D>& x, nullptr_t) noexcept; -// template <class T, class D> -// bool operator!=(nullptr_t, const unique_ptr<T, D>& y) noexcept; -// template <class T, class D> -// bool operator<(const unique_ptr<T, D>& x, nullptr_t) noexcept; -// template <class T, class D> -// bool operator<(nullptr_t, const unique_ptr<T, D>& y) noexcept; -// template <class T, class D> -// bool operator<=(const unique_ptr<T, D>& x, nullptr_t) noexcept; -// template <class T, class D> -// bool operator<=(nullptr_t, const unique_ptr<T, D>& y) noexcept; -// template <class T, class D> -// bool operator>(const unique_ptr<T, D>& x, nullptr_t) noexcept; -// template <class T, class D> -// bool operator>(nullptr_t, const unique_ptr<T, D>& y) noexcept; -// template <class T, class D> -// bool operator>=(const unique_ptr<T, D>& x, nullptr_t) noexcept; -// template <class T, class D> -// bool operator>=(nullptr_t, const unique_ptr<T, D>& y) noexcept; - -#include <memory> -#include <cassert> - -void do_nothing(int*) {} - -int main() -{ - const std::unique_ptr<int> p1(new int(1)); - assert(!(p1 == nullptr)); - assert(!(nullptr == p1)); - assert(!(p1 < nullptr)); - assert( (nullptr < p1)); - assert(!(p1 <= nullptr)); - assert( (nullptr <= p1)); - assert( (p1 > nullptr)); - assert(!(nullptr > p1)); - assert( (p1 >= nullptr)); - assert(!(nullptr >= p1)); - - const std::unique_ptr<int> p2; - assert( (p2 == nullptr)); - assert( (nullptr == p2)); - assert(!(p2 < nullptr)); - assert(!(nullptr < p2)); - assert( (p2 <= nullptr)); - assert( (nullptr <= p2)); - assert(!(p2 > nullptr)); - assert(!(nullptr > p2)); - assert( (p2 >= nullptr)); - assert( (nullptr >= p2)); -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp deleted file mode 100644 index 37886548e72..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.special/eq.pass.cpp +++ /dev/null @@ -1,86 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// template <class T1, class D1, class T2, class D2> -// bool -// operator==(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); - -// template <class T1, class D1, class T2, class D2> -// bool -// operator!=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); - -#include <memory> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<A, Deleter<A> > p1(new A); - const std::unique_ptr<A, Deleter<A> > p2(new A); - assert(!(p1 == p2)); - assert(p1 != p2); - } - { - const std::unique_ptr<A, Deleter<A> > p1(new A); - const std::unique_ptr<B, Deleter<B> > p2(new B); - assert(!(p1 == p2)); - assert(p1 != p2); - } - { - const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]); - const std::unique_ptr<A[], Deleter<A[]> > p2(new A[3]); - assert(!(p1 == p2)); - assert(p1 != p2); - } - { - const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]); - const std::unique_ptr<B[], Deleter<B[]> > p2(new B[3]); - assert(!(p1 == p2)); - assert(p1 != p2); - } - { - const std::unique_ptr<A, Deleter<A> > p1; - const std::unique_ptr<A, Deleter<A> > p2; - assert(p1 == p2); - assert(!(p1 != p2)); - } - { - const std::unique_ptr<A, Deleter<A> > p1; - const std::unique_ptr<B, Deleter<B> > p2; - assert(p1 == p2); - assert(!(p1 != p2)); - } -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp deleted file mode 100644 index 80653cf707c..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.special/rel.pass.cpp +++ /dev/null @@ -1,100 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// template <class T1, class D1, class T2, class D2> -// bool -// operator< (const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); - -// template <class T1, class D1, class T2, class D2> -// bool -// operator> (const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); - -// template <class T1, class D1, class T2, class D2> -// bool -// operator<=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); - -// template <class T1, class D1, class T2, class D2> -// bool -// operator>=(const unique_ptr<T1, D1>& x, const unique_ptr<T2, D2>& y); - -#include <memory> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - static int count; - A() {++count;} - A(const A&) {++count;} - virtual ~A() {--count;} -}; - -int A::count = 0; - -struct B - : public A -{ - static int count; - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -int main() -{ - { - const std::unique_ptr<A, Deleter<A> > p1(new A); - const std::unique_ptr<A, Deleter<A> > p2(new A); - assert((p1 < p2) == !(p1 > p2)); - assert((p1 < p2) == (p1 <= p2)); - assert((p1 < p2) == !(p1 >= p2)); - } - { - const std::unique_ptr<A, Deleter<A> > p1(new A); - const std::unique_ptr<B, Deleter<B> > p2(new B); - assert((p1 < p2) == !(p1 > p2)); - assert((p1 < p2) == (p1 <= p2)); - assert((p1 < p2) == !(p1 >= p2)); - } - { - const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]); - const std::unique_ptr<A[], Deleter<A[]> > p2(new A[3]); - assert((p1 < p2) == !(p1 > p2)); - assert((p1 < p2) == (p1 <= p2)); - assert((p1 < p2) == !(p1 >= p2)); - } - { - const std::unique_ptr<A[], Deleter<A[]> > p1(new A[3]); - const std::unique_ptr<B[], Deleter<B[]> > p2(new B[3]); - assert((p1 < p2) == !(p1 > p2)); - assert((p1 < p2) == (p1 <= p2)); - assert((p1 < p2) == !(p1 >= p2)); - } - { - const std::unique_ptr<A, Deleter<A> > p1; - const std::unique_ptr<A, Deleter<A> > p2; - assert((p1 < p2) == (p1 > p2)); - assert((p1 < p2) == !(p1 <= p2)); - assert((p1 < p2) == !(p1 >= p2)); - } - { - const std::unique_ptr<A, Deleter<A> > p1; - const std::unique_ptr<B, Deleter<B> > p2; - assert((p1 < p2) == (p1 > p2)); - assert((p1 < p2) == !(p1 <= p2)); - assert((p1 < p2) == !(p1 >= p2)); - } -} diff --git a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp b/libcxx/test/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp deleted file mode 100644 index 44b746fbcfd..00000000000 --- a/libcxx/test/utilities/memory/unique.ptr/unique.ptr.special/swap.pass.cpp +++ /dev/null @@ -1,77 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// unique_ptr - -// Test swap - -#include <memory> -#include <cassert> - -#include "../deleter.h" - -struct A -{ - int state_; - static int count; - A() : state_(0) {++count;} - explicit A(int i) : state_(i) {++count;} - A(const A& a) : state_(a.state_) {++count;} - A& operator=(const A& a) {state_ = a.state_; return *this;} - ~A() {--count;} - - friend bool operator==(const A& x, const A& y) - {return x.state_ == y.state_;} -}; - -int A::count = 0; - -int main() -{ - { - A* p1 = new A(1); - std::unique_ptr<A, Deleter<A> > s1(p1, Deleter<A>(1)); - A* p2 = new A(2); - std::unique_ptr<A, Deleter<A> > s2(p2, Deleter<A>(2)); - assert(s1.get() == p1); - assert(*s1 == A(1)); - assert(s1.get_deleter().state() == 1); - assert(s2.get() == p2); - assert(*s2 == A(2)); - assert(s2.get_deleter().state() == 2); - swap(s1, s2); - assert(s1.get() == p2); - assert(*s1 == A(2)); - assert(s1.get_deleter().state() == 2); - assert(s2.get() == p1); - assert(*s2 == A(1)); - assert(s2.get_deleter().state() == 1); - assert(A::count == 2); - } - assert(A::count == 0); - { - A* p1 = new A[3]; - std::unique_ptr<A[], Deleter<A[]> > s1(p1, Deleter<A[]>(1)); - A* p2 = new A[3]; - std::unique_ptr<A[], Deleter<A[]> > s2(p2, Deleter<A[]>(2)); - assert(s1.get() == p1); - assert(s1.get_deleter().state() == 1); - assert(s2.get() == p2); - assert(s2.get_deleter().state() == 2); - swap(s1, s2); - assert(s1.get() == p2); - assert(s1.get_deleter().state() == 2); - assert(s2.get() == p1); - assert(s2.get_deleter().state() == 1); - assert(A::count == 6); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp b/libcxx/test/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp deleted file mode 100644 index bbf4be20f8f..00000000000 --- a/libcxx/test/utilities/memory/util.dynamic.safety/declare_no_pointers.pass.cpp +++ /dev/null @@ -1,23 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// void declare_no_pointers(char* p, size_t n); -// void undeclare_no_pointers(char* p, size_t n); - -#include <memory> - -int main() -{ - char* p = new char[10]; - std::declare_no_pointers(p, 10); - std::undeclare_no_pointers(p, 10); - delete [] p; -} diff --git a/libcxx/test/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp b/libcxx/test/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp deleted file mode 100644 index 3f0bcead9be..00000000000 --- a/libcxx/test/utilities/memory/util.dynamic.safety/declare_reachable.pass.cpp +++ /dev/null @@ -1,24 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// void declare_reachable(void* p); -// template <class T> T* undeclare_reachable(T* p); - -#include <memory> -#include <cassert> - -int main() -{ - int* p = new int; - std::declare_reachable(p); - assert(std::undeclare_reachable(p) == p); - delete p; -} diff --git a/libcxx/test/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp b/libcxx/test/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp deleted file mode 100644 index 1f27b45e8ab..00000000000 --- a/libcxx/test/utilities/memory/util.dynamic.safety/get_pointer_safety.pass.cpp +++ /dev/null @@ -1,23 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// pointer_safety get_pointer_safety(); - -#include <memory> -#include <cassert> - -int main() -{ - std::pointer_safety r = std::get_pointer_safety(); - assert(r == std::pointer_safety::relaxed || - r == std::pointer_safety::preferred || - r == std::pointer_safety::strict); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/nothing_to_do.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/nothing_to_do.pass.cpp deleted file mode 100644 index b58f5c55b64..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/nothing_to_do.pass.cpp +++ /dev/null @@ -1,12 +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. -// -//===----------------------------------------------------------------------===// - -int main() -{ -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.pass.cpp deleted file mode 100644 index 58686d68c05..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.enab/enable_shared_from_this.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. -// -//===----------------------------------------------------------------------===// - -// template<class T> -// class enable_shared_from_this -// { -// protected: -// enable_shared_from_this(); -// enable_shared_from_this(enable_shared_from_this const&); -// enable_shared_from_this& operator=(enable_shared_from_this const&); -// ~enable_shared_from_this(); -// public: -// shared_ptr<T> shared_from_this(); -// shared_ptr<T const> shared_from_this() const; -// }; - -#include <memory> -#include <cassert> - -struct T - : public std::enable_shared_from_this<T> -{ -}; - -struct Y : T {}; - -struct Z : Y {}; - -int main() -{ - { - std::shared_ptr<Y> p(new Z); - std::shared_ptr<T> q = p->shared_from_this(); - assert(p == q); - assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share ownership - } - { - std::shared_ptr<Y> p = std::make_shared<Z>(); - std::shared_ptr<T> q = p->shared_from_this(); - assert(p == q); - assert(!p.owner_before(q) && !q.owner_before(p)); // p and q share ownership - } -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp deleted file mode 100644 index 990cb58722b..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.hash/hash_shared_ptr.pass.cpp +++ /dev/null @@ -1,30 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class T> -// struct hash<shared_ptr<T>> -// { -// typedef shared_ptr<T> argument_type; -// typedef size_t result_type; -// size_t operator()(const shared_ptr<T>& p) const; -// }; - -#include <memory> -#include <cassert> - -int main() -{ - int* ptr = new int; - std::shared_ptr<int> p(ptr); - std::hash<std::shared_ptr<int> > f; - std::size_t h = f(p); - assert(h == std::hash<int*>()(ptr)); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp deleted file mode 100644 index 5cd4ab1f83d..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.hash/hash_unique_ptr.pass.cpp +++ /dev/null @@ -1,30 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class T, class D> -// struct hash<unique_ptr<T, D>> -// { -// typedef unique_ptr<T, D> argument_type; -// typedef size_t result_type; -// size_t operator()(const unique_ptr<T, D>& p) const; -// }; - -#include <memory> -#include <cassert> - -int main() -{ - int* ptr = new int; - std::unique_ptr<int> p(ptr); - std::hash<std::unique_ptr<int> > f; - std::size_t h = f(p); - assert(h == std::hash<int*>()(ptr)); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.pass.cpp deleted file mode 100644 index cd79fdb0d04..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong.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. -// -//===----------------------------------------------------------------------===// -// -// UNSUPPORTED: libcpp-has-no-threads -// -// This test uses new symbols that were not defined in the libc++ shipped on -// darwin11 and darwin12: -// XFAIL: with_system_lib=x86_64-apple-darwin11 -// XFAIL: with_system_lib=x86_64-apple-darwin12 - -// <memory> - -// shared_ptr - -// template <class T> -// bool -// atomic_compare_exchange_strong(shared_ptr<T>* p, shared_ptr<T>* v, -// shared_ptr<T> w); - -#include <memory> -#include <cassert> - -int main() -{ -#if __has_feature(cxx_atomic) - { - std::shared_ptr<int> p(new int(4)); - std::shared_ptr<int> v(new int(3)); - std::shared_ptr<int> w(new int(2)); - bool b = std::atomic_compare_exchange_strong(&p, &v, w); - assert(b == false); - assert(*p == 4); - assert(*v == 4); - assert(*w == 2); - } - { - std::shared_ptr<int> p(new int(4)); - std::shared_ptr<int> v = p; - std::shared_ptr<int> w(new int(2)); - bool b = std::atomic_compare_exchange_strong(&p, &v, w); - assert(b == true); - assert(*p == 2); - assert(*v == 4); - assert(*w == 2); - } -#endif -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.pass.cpp deleted file mode 100644 index 2fd9d5a8fcb..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_strong_explicit.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. -// -//===----------------------------------------------------------------------===// -// -// UNSUPPORTED: libcpp-has-no-threads -// -// This test uses new symbols that were not defined in the libc++ shipped on -// darwin11 and darwin12: -// XFAIL: with_system_lib=x86_64-apple-darwin11 -// XFAIL: with_system_lib=x86_64-apple-darwin12 - -// <memory> - -// shared_ptr - -// template <class T> -// bool -// atomic_compare_exchange_strong_explicit(shared_ptr<T>* p, shared_ptr<T>* v, -// shared_ptr<T> w, memory_order success, -// memory_order failure); - -#include <memory> -#include <cassert> - -int main() -{ -#if __has_feature(cxx_atomic) - { - std::shared_ptr<int> p(new int(4)); - std::shared_ptr<int> v(new int(3)); - std::shared_ptr<int> w(new int(2)); - bool b = std::atomic_compare_exchange_strong_explicit(&p, &v, w, - std::memory_order_seq_cst, - std::memory_order_seq_cst); - assert(b == false); - assert(*p == 4); - assert(*v == 4); - assert(*w == 2); - } - { - std::shared_ptr<int> p(new int(4)); - std::shared_ptr<int> v = p; - std::shared_ptr<int> w(new int(2)); - bool b = std::atomic_compare_exchange_strong_explicit(&p, &v, w, - std::memory_order_seq_cst, - std::memory_order_seq_cst); - assert(b == true); - assert(*p == 2); - assert(*v == 4); - assert(*w == 2); - } -#endif -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.pass.cpp deleted file mode 100644 index 5c082cc279e..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak.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. -// -//===----------------------------------------------------------------------===// -// -// UNSUPPORTED: libcpp-has-no-threads -// -// This test uses new symbols that were not defined in the libc++ shipped on -// darwin11 and darwin12: -// XFAIL: with_system_lib=x86_64-apple-darwin11 -// XFAIL: with_system_lib=x86_64-apple-darwin12 - -// <memory> - -// shared_ptr - -// template <class T> -// bool -// atomic_compare_exchange_weak(shared_ptr<T>* p, shared_ptr<T>* v, -// shared_ptr<T> w); - -#include <memory> -#include <cassert> - -int main() -{ -#if __has_feature(cxx_atomic) - { - std::shared_ptr<int> p(new int(4)); - std::shared_ptr<int> v(new int(3)); - std::shared_ptr<int> w(new int(2)); - bool b = std::atomic_compare_exchange_weak(&p, &v, w); - assert(b == false); - assert(*p == 4); - assert(*v == 4); - assert(*w == 2); - } - { - std::shared_ptr<int> p(new int(4)); - std::shared_ptr<int> v = p; - std::shared_ptr<int> w(new int(2)); - bool b = std::atomic_compare_exchange_weak(&p, &v, w); - assert(b == true); - assert(*p == 2); - assert(*v == 4); - assert(*w == 2); - } -#endif -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.pass.cpp deleted file mode 100644 index f53f44256d5..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_compare_exchange_weak_explicit.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. -// -//===----------------------------------------------------------------------===// -// -// UNSUPPORTED: libcpp-has-no-threads -// -// This test uses new symbols that were not defined in the libc++ shipped on -// darwin11 and darwin12: -// XFAIL: with_system_lib=x86_64-apple-darwin11 -// XFAIL: with_system_lib=x86_64-apple-darwin12 - -// <memory> - -// shared_ptr - -// template <class T> -// bool -// atomic_compare_exchange_weak_explicit(shared_ptr<T>* p, shared_ptr<T>* v, -// shared_ptr<T> w, memory_order success, -// memory_order failure); - -#include <memory> -#include <cassert> - -int main() -{ -#if __has_feature(cxx_atomic) - { - std::shared_ptr<int> p(new int(4)); - std::shared_ptr<int> v(new int(3)); - std::shared_ptr<int> w(new int(2)); - bool b = std::atomic_compare_exchange_weak_explicit(&p, &v, w, - std::memory_order_seq_cst, - std::memory_order_seq_cst); - assert(b == false); - assert(*p == 4); - assert(*v == 4); - assert(*w == 2); - } - { - std::shared_ptr<int> p(new int(4)); - std::shared_ptr<int> v = p; - std::shared_ptr<int> w(new int(2)); - bool b = std::atomic_compare_exchange_weak_explicit(&p, &v, w, - std::memory_order_seq_cst, - std::memory_order_seq_cst); - assert(b == true); - assert(*p == 2); - assert(*v == 4); - assert(*w == 2); - } -#endif -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp deleted file mode 100644 index fc4c47a20d3..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange.pass.cpp +++ /dev/null @@ -1,39 +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. -// -//===----------------------------------------------------------------------===// -// -// UNSUPPORTED: libcpp-has-no-threads -// -// This test uses new symbols that were not defined in the libc++ shipped on -// darwin11 and darwin12: -// XFAIL: with_system_lib=x86_64-apple-darwin11 -// XFAIL: with_system_lib=x86_64-apple-darwin12 - -// <memory> - -// shared_ptr - -// template <class T> -// shared_ptr<T> -// atomic_exchange(shared_ptr<T>* p, shared_ptr<T> r) - -#include <memory> -#include <cassert> - -int main() -{ -#if __has_feature(cxx_atomic) - { - std::shared_ptr<int> p(new int(4)); - std::shared_ptr<int> r(new int(3)); - r = std::atomic_exchange(&p, r); - assert(*p == 3); - assert(*r == 4); - } -#endif -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp deleted file mode 100644 index 19482dc0ad5..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_exchange_explicit.pass.cpp +++ /dev/null @@ -1,39 +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. -// -//===----------------------------------------------------------------------===// -// -// UNSUPPORTED: libcpp-has-no-threads -// -// This test uses new symbols that were not defined in the libc++ shipped on -// darwin11 and darwin12: -// XFAIL: with_system_lib=x86_64-apple-darwin11 -// XFAIL: with_system_lib=x86_64-apple-darwin12 - -// <memory> - -// shared_ptr - -// template <class T> -// shared_ptr<T> -// atomic_exchange_explicit(shared_ptr<T>* p, shared_ptr<T> r) - -#include <memory> -#include <cassert> - -int main() -{ -#if __has_feature(cxx_atomic) - { - std::shared_ptr<int> p(new int(4)); - std::shared_ptr<int> r(new int(3)); - r = std::atomic_exchange_explicit(&p, r, std::memory_order_seq_cst); - assert(*p == 3); - assert(*r == 4); - } -#endif -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_is_lock_free.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_is_lock_free.pass.cpp deleted file mode 100644 index e3ac84a4fa5..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_is_lock_free.pass.cpp +++ /dev/null @@ -1,31 +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. -// -//===----------------------------------------------------------------------===// -// -// UNSUPPORTED: libcpp-has-no-threads - -// <memory> - -// shared_ptr - -// template<class T> -// bool -// atomic_is_lock_free(const shared_ptr<T>* p); - -#include <memory> -#include <cassert> - -int main() -{ -#if __has_feature(cxx_atomic) - { - const std::shared_ptr<int> p(new int(3)); - assert(std::atomic_is_lock_free(&p) == false); - } -#endif -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp deleted file mode 100644 index 566e95adec8..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load.pass.cpp +++ /dev/null @@ -1,37 +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. -// -//===----------------------------------------------------------------------===// -// -// UNSUPPORTED: libcpp-has-no-threads -// -// This test uses new symbols that were not defined in the libc++ shipped on -// darwin11 and darwin12: -// XFAIL: with_system_lib=x86_64-apple-darwin11 -// XFAIL: with_system_lib=x86_64-apple-darwin12 - -// <memory> - -// shared_ptr - -// template <class T> -// shared_ptr<T> -// atomic_load(const shared_ptr<T>* p) - -#include <memory> -#include <cassert> - -int main() -{ -#if __has_feature(cxx_atomic) - { - std::shared_ptr<int> p(new int(3)); - std::shared_ptr<int> q = std::atomic_load(&p); - assert(*q == *p); - } -#endif -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp deleted file mode 100644 index b423604463f..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_load_explicit.pass.cpp +++ /dev/null @@ -1,37 +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. -// -//===----------------------------------------------------------------------===// -// -// UNSUPPORTED: libcpp-has-no-threads -// -// This test uses new symbols that were not defined in the libc++ shipped on -// darwin11 and darwin12: -// XFAIL: with_system_lib=x86_64-apple-darwin11 -// XFAIL: with_system_lib=x86_64-apple-darwin12 - -// <memory> - -// shared_ptr - -// template <class T> -// shared_ptr<T> -// atomic_load_explicit(const shared_ptr<T>* p, memory_order mo) - -#include <memory> -#include <cassert> - -int main() -{ -#if __has_feature(cxx_atomic) - { - const std::shared_ptr<int> p(new int(3)); - std::shared_ptr<int> q = std::atomic_load_explicit(&p, std::memory_order_relaxed); - assert(*q == *p); - } -#endif -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp deleted file mode 100644 index f65f3ebf8c1..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store.pass.cpp +++ /dev/null @@ -1,38 +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. -// -//===----------------------------------------------------------------------===// -// -// UNSUPPORTED: libcpp-has-no-threads -// -// This test uses new symbols that were not defined in the libc++ shipped on -// darwin11 and darwin12: -// XFAIL: with_system_lib=x86_64-apple-darwin11 -// XFAIL: with_system_lib=x86_64-apple-darwin12 - -// <memory> - -// shared_ptr - -// template <class T> -// void -// atomic_store(shared_ptr<T>* p, shared_ptr<T> r) - -#include <memory> -#include <cassert> - -int main() -{ -#if __has_feature(cxx_atomic) - { - std::shared_ptr<int> p; - std::shared_ptr<int> r(new int(3)); - std::atomic_store(&p, r); - assert(*p == *r); - } -#endif -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp deleted file mode 100644 index 68642002d70..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared.atomic/atomic_store_explicit.pass.cpp +++ /dev/null @@ -1,38 +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. -// -//===----------------------------------------------------------------------===// -// -// UNSUPPORTED: libcpp-has-no-threads -// -// This test uses new symbols that were not defined in the libc++ shipped on -// darwin11 and darwin12: -// XFAIL: with_system_lib=x86_64-apple-darwin11 -// XFAIL: with_system_lib=x86_64-apple-darwin12 - -// <memory> - -// shared_ptr - -// template <class T> -// void -// atomic_store_explicit(shared_ptr<T>* p, shared_ptr<T> r, memory_order mo) - -#include <memory> -#include <cassert> - -int main() -{ -#if __has_feature(cxx_atomic) - { - std::shared_ptr<int> p; - std::shared_ptr<int> r(new int(3)); - std::atomic_store_explicit(&p, r, std::memory_order_seq_cst); - assert(*p == *r); - } -#endif -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h deleted file mode 100644 index 0263061b3a8..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/test_deleter.h +++ /dev/null @@ -1,68 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// Example move-only deleter - -#ifndef DELETER_H -#define DELETER_H - -#include <type_traits> -#include <cassert> - -#ifndef _LIBCPP_HAS_NO_DELETED_FUNCTIONS -#define DELETE_FUNCTION = delete -#else -#define DELETE_FUNCTION { assert(false); } -#endif - -struct test_deleter_base -{ - static int count; - static int dealloc_count; -}; - -int test_deleter_base::count = 0; -int test_deleter_base::dealloc_count = 0; - -template <class T> -class test_deleter - : public test_deleter_base -{ - int state_; - -public: - - test_deleter() : state_(0) {++count;} - explicit test_deleter(int s) : state_(s) {++count;} - test_deleter(const test_deleter& d) - : state_(d.state_) {++count;} - ~test_deleter() {assert(state_ >= 0); --count; state_ = -1;} - - int state() const {return state_;} - void set_state(int i) {state_ = i;} - - void operator()(T* p) {assert(state_ >= 0); ++dealloc_count; delete p;} - - test_deleter* operator&() const DELETE_FUNCTION; -}; - -template <class T> -void -swap(test_deleter<T>& x, test_deleter<T>& y) -{ - test_deleter<T> t(std::move(x)); - x = std::move(y); - y = std::move(t); -} - -#endif // DELETER_H diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/types.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/types.pass.cpp deleted file mode 100644 index 8175312334f..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/types.pass.cpp +++ /dev/null @@ -1,26 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template<class T> class shared_ptr -// { -// public: -// typedef T element_type; -// ... -// }; - -#include <memory> - -struct A; // purposefully incomplete - -int main() -{ - static_assert((std::is_same<std::shared_ptr<A>::element_type, A>::value), ""); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.pass.cpp deleted file mode 100644 index a6c62496fd6..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.getdeleter/get_deleter.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class D, class T> D* get_deleter(const shared_ptr<T>& p); - -#include <memory> -#include <cassert> -#include "../test_deleter.h" - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - { - A* ptr = new A; - std::shared_ptr<A> p(ptr, test_deleter<A>(3)); - test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p); - assert(test_deleter<A>::count == 1); - assert(test_deleter<A>::dealloc_count == 0); - assert(d); - assert(d->state() == 3); - } - assert(A::count == 0); - assert(test_deleter<A>::count == 0); - assert(test_deleter<A>::dealloc_count == 1); - } - test_deleter<A>::dealloc_count = 0; - { - { - std::shared_ptr<A> p(nullptr, test_deleter<A>(3)); - test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p); - assert(test_deleter<A>::count == 1); - assert(test_deleter<A>::dealloc_count == 0); - assert(d); - assert(d->state() == 3); - } - assert(A::count == 0); - assert(test_deleter<A>::count == 0); - assert(test_deleter<A>::dealloc_count == 1); - } - test_deleter<A>::dealloc_count = 0; - { - std::shared_ptr<A> p(nullptr, test_deleter<A>(3)); - std::default_delete<A>* d = std::get_deleter<std::default_delete<A> >(p); - assert(d == 0); - } -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp deleted file mode 100644 index 21cdf4a13e4..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/auto_ptr_Y.pass.cpp +++ /dev/null @@ -1,113 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class Y> shared_ptr& operator=(auto_ptr<Y>&& r); - -#include <memory> -#include <type_traits> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::auto_ptr<A> pA(new A); - A* ptrA = pA.get(); - { - std::shared_ptr<B> pB(new B); - pB = std::move(pA); - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 1); - assert(pA.get() == 0); - assert(pB.get() == ptrA); - } - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); - { - std::auto_ptr<A> pA; - A* ptrA = pA.get(); - { - std::shared_ptr<B> pB(new B); - pB = std::move(pA); - assert(B::count == 0); - assert(A::count == 0); - assert(pB.use_count() == 1); - assert(pA.get() == 0); - assert(pB.get() == ptrA); - } - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); - { - std::auto_ptr<A> pA(new A); - A* ptrA = pA.get(); - { - std::shared_ptr<B> pB; - pB = std::move(pA); - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 1); - assert(pA.get() == 0); - assert(pB.get() == ptrA); - } - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); - { - std::auto_ptr<A> pA; - A* ptrA = pA.get(); - { - std::shared_ptr<B> pB; - pB = std::move(pA); - assert(B::count == 0); - assert(A::count == 0); - assert(pB.use_count() == 1); - assert(pA.get() == 0); - assert(pB.get() == ptrA); - } - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr.pass.cpp deleted file mode 100644 index 5d27a8865f0..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr.pass.cpp +++ /dev/null @@ -1,121 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// shared_ptr& operator=(const shared_ptr& r); - -#include <memory> -#include <type_traits> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - const std::shared_ptr<A> pA(new A); - A* ptrA = pA.get(); - { - std::shared_ptr<A> pB(new A); - pB = pA; - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 2); - assert(pA.use_count() == 2); - assert(pA.get() == pB.get()); - assert(pB.get() == ptrA); - } - assert(pA.use_count() == 1); - assert(B::count == 1); - assert(A::count == 1); - } - assert(B::count == 0); - assert(A::count == 0); - { - const std::shared_ptr<A> pA; - A* ptrA = pA.get(); - { - std::shared_ptr<A> pB(new A); - pB = pA; - assert(B::count == 0); - assert(A::count == 0); - assert(pB.use_count() == 0); - assert(pA.use_count() == 0); - assert(pA.get() == pB.get()); - assert(pB.get() == ptrA); - } - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); - { - const std::shared_ptr<A> pA(new A); - A* ptrA = pA.get(); - { - std::shared_ptr<A> pB; - pB = pA; - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 2); - assert(pA.use_count() == 2); - assert(pA.get() == pB.get()); - assert(pB.get() == ptrA); - } - assert(pA.use_count() == 1); - assert(B::count == 1); - assert(A::count == 1); - } - assert(B::count == 0); - assert(A::count == 0); - { - const std::shared_ptr<A> pA; - A* ptrA = pA.get(); - { - std::shared_ptr<A> pB; - pB = pA; - assert(B::count == 0); - assert(A::count == 0); - assert(pB.use_count() == 0); - assert(pA.use_count() == 0); - assert(pA.get() == pB.get()); - assert(pB.get() == ptrA); - } - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp deleted file mode 100644 index abd3d378eb7..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y.pass.cpp +++ /dev/null @@ -1,121 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class Y> shared_ptr& operator=(const shared_ptr<Y>& r); - -#include <memory> -#include <type_traits> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - const std::shared_ptr<A> pA(new A); - A* ptrA = pA.get(); - { - std::shared_ptr<B> pB(new B); - pB = pA; - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 2); - assert(pA.use_count() == 2); - assert(pA.get() == pB.get()); - assert(pB.get() == ptrA); - } - assert(pA.use_count() == 1); - assert(B::count == 1); - assert(A::count == 1); - } - assert(B::count == 0); - assert(A::count == 0); - { - const std::shared_ptr<A> pA; - A* ptrA = pA.get(); - { - std::shared_ptr<B> pB(new B); - pB = pA; - assert(B::count == 0); - assert(A::count == 0); - assert(pB.use_count() == 0); - assert(pA.use_count() == 0); - assert(pA.get() == pB.get()); - assert(pB.get() == ptrA); - } - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); - { - const std::shared_ptr<A> pA(new A); - A* ptrA = pA.get(); - { - std::shared_ptr<B> pB; - pB = pA; - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 2); - assert(pA.use_count() == 2); - assert(pA.get() == pB.get()); - assert(pB.get() == ptrA); - } - assert(pA.use_count() == 1); - assert(B::count == 1); - assert(A::count == 1); - } - assert(B::count == 0); - assert(A::count == 0); - { - const std::shared_ptr<A> pA; - A* ptrA = pA.get(); - { - std::shared_ptr<B> pB; - pB = pA; - assert(B::count == 0); - assert(A::count == 0); - assert(pB.use_count() == 0); - assert(pA.use_count() == 0); - assert(pA.get() == pB.get()); - assert(pB.get() == ptrA); - } - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp deleted file mode 100644 index 93956bcae66..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_Y_rv.pass.cpp +++ /dev/null @@ -1,123 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class Y> shared_ptr& operator=(shared_ptr<Y>&& r); - -#include <memory> -#include <type_traits> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - { - std::shared_ptr<A> pA(new A); - A* ptrA = pA.get(); - { - std::shared_ptr<B> pB(new B); - pB = std::move(pA); - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 1); - assert(pA.use_count() == 0); - assert(pA.get() == 0); - assert(pB.get() == ptrA); - } - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); - { - std::shared_ptr<A> pA; - A* ptrA = pA.get(); - { - std::shared_ptr<B> pB(new B); - pB = std::move(pA); - assert(B::count == 0); - assert(A::count == 0); - assert(pB.use_count() == 0); - assert(pA.use_count() == 0); - assert(pA.get() == 0); - assert(pB.get() == ptrA); - } - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); - { - std::shared_ptr<A> pA(new A); - A* ptrA = pA.get(); - { - std::shared_ptr<B> pB; - pB = std::move(pA); - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 1); - assert(pA.use_count() == 0); - assert(pA.get() == 0); - assert(pB.get() == ptrA); - } - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); - { - std::shared_ptr<A> pA; - A* ptrA = pA.get(); - { - std::shared_ptr<B> pB; - pB = std::move(pA); - assert(B::count == 0); - assert(A::count == 0); - assert(pB.use_count() == 0); - assert(pA.use_count() == 0); - assert(pA.get() == 0); - assert(pB.get() == ptrA); - } - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp deleted file mode 100644 index 4194890dda2..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/shared_ptr_rv.pass.cpp +++ /dev/null @@ -1,123 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// shared_ptr& operator=(shared_ptr&& r); - -#include <memory> -#include <type_traits> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - { - std::shared_ptr<A> pA(new A); - A* ptrA = pA.get(); - { - std::shared_ptr<A> pB(new A); - pB = std::move(pA); - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 1); - assert(pA.use_count() == 0); - assert(pA.get() == 0); - assert(pB.get() == ptrA); - } - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); - { - std::shared_ptr<A> pA; - A* ptrA = pA.get(); - { - std::shared_ptr<A> pB(new A); - pB = std::move(pA); - assert(B::count == 0); - assert(A::count == 0); - assert(pB.use_count() == 0); - assert(pA.use_count() == 0); - assert(pA.get() == 0); - assert(pB.get() == ptrA); - } - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); - { - std::shared_ptr<A> pA(new A); - A* ptrA = pA.get(); - { - std::shared_ptr<A> pB; - pB = std::move(pA); - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 1); - assert(pA.use_count() == 0); - assert(pA.get() == 0); - assert(pB.get() == ptrA); - } - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); - { - std::shared_ptr<A> pA; - A* ptrA = pA.get(); - { - std::shared_ptr<A> pB; - pB = std::move(pA); - assert(B::count == 0); - assert(A::count == 0); - assert(pB.use_count() == 0); - assert(pA.use_count() == 0); - assert(pA.get() == 0); - assert(pB.get() == ptrA); - } - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); -#endif // _LIBCXX_HAS_NO_RVALUE_REFERENCES -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp deleted file mode 100644 index 742d8c1b2dd..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.assign/unique_ptr_Y.pass.cpp +++ /dev/null @@ -1,113 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template <class Y, class D> shared_ptr& operator=(unique_ptr<Y, D>&& r); - -#include <memory> -#include <type_traits> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::unique_ptr<A> pA(new A); - A* ptrA = pA.get(); - { - std::shared_ptr<B> pB(new B); - pB = std::move(pA); - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 1); - assert(pA.get() == 0); - assert(pB.get() == ptrA); - } - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); - { - std::unique_ptr<A> pA; - A* ptrA = pA.get(); - { - std::shared_ptr<B> pB(new B); - pB = std::move(pA); - assert(B::count == 0); - assert(A::count == 0); - assert(pB.use_count() == 1); - assert(pA.get() == 0); - assert(pB.get() == ptrA); - } - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); - { - std::unique_ptr<A> pA(new A); - A* ptrA = pA.get(); - { - std::shared_ptr<B> pB; - pB = std::move(pA); - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 1); - assert(pA.get() == 0); - assert(pB.get() == ptrA); - } - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); - { - std::unique_ptr<A> pA; - A* ptrA = pA.get(); - { - std::shared_ptr<B> pB; - pB = std::move(pA); - assert(B::count == 0); - assert(A::count == 0); - assert(pB.use_count() == 1); - assert(pA.get() == 0); - assert(pB.get() == ptrA); - } - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_pointer_cast.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_pointer_cast.pass.cpp deleted file mode 100644 index 7d771d03c71..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/const_pointer_cast.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class T, class U> shared_ptr<T> const_pointer_cast(const shared_ptr<U>& r); - -#include <memory> -#include <type_traits> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - const std::shared_ptr<const A> pA(new A); - std::shared_ptr<A> pB = std::const_pointer_cast<A>(pA); - assert(pB.get() == pA.get()); - assert(!pB.owner_before(pA) && !pA.owner_before(pB)); - } - { - const std::shared_ptr<const A> pA; - std::shared_ptr<A> pB = std::const_pointer_cast<A>(pA); - assert(pB.get() == pA.get()); - assert(!pB.owner_before(pA) && !pA.owner_before(pB)); - } -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.pass.cpp deleted file mode 100644 index 4f88a5c4351..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/dynamic_pointer_cast.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class T, class U> shared_ptr<T> dynamic_pointer_cast(const shared_ptr<U>& r); - -#include <memory> -#include <type_traits> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - const std::shared_ptr<B> pB(new A); - std::shared_ptr<A> pA = std::dynamic_pointer_cast<A>(pB); - assert(pA.get() == pB.get()); - assert(!pB.owner_before(pA) && !pA.owner_before(pB)); - } - { - const std::shared_ptr<B> pB(new B); - std::shared_ptr<A> pA = std::dynamic_pointer_cast<A>(pB); - assert(pA.get() == 0); - assert(pA.use_count() == 0); - } -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_pointer_cast.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_pointer_cast.pass.cpp deleted file mode 100644 index 98fa13801a8..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cast/static_pointer_cast.pass.cpp +++ /dev/null @@ -1,69 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class T, class U> shared_ptr<T> static_pointer_cast(const shared_ptr<U>& r); - -#include <memory> -#include <type_traits> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - const std::shared_ptr<A> pA(new A); - std::shared_ptr<B> pB = std::static_pointer_cast<B>(pA); - assert(pB.get() == pA.get()); - assert(!pB.owner_before(pA) && !pA.owner_before(pB)); - } - { - const std::shared_ptr<B> pA(new A); - std::shared_ptr<A> pB = std::static_pointer_cast<A>(pA); - assert(pB.get() == pA.get()); - assert(!pB.owner_before(pA) && !pA.owner_before(pB)); - } - { - const std::shared_ptr<A> pA; - std::shared_ptr<B> pB = std::static_pointer_cast<B>(pA); - assert(pB.get() == pA.get()); - assert(!pB.owner_before(pA) && !pA.owner_before(pB)); - } - { - const std::shared_ptr<B> pA; - std::shared_ptr<A> pB = std::static_pointer_cast<A>(pA); - assert(pB.get() == pA.get()); - assert(!pB.owner_before(pA) && !pA.owner_before(pB)); - } -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpp deleted file mode 100644 index f40cbc3d032..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/cmp_nullptr.pass.cpp +++ /dev/null @@ -1,69 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template <class T> -// bool operator==(const shared_ptr<T>& x, nullptr_t) noexcept; -// template <class T> -// bool operator==(nullptr_t, const shared_ptr<T>& y) noexcept; -// template <class T> -// bool operator!=(const shared_ptr<T>& x, nullptr_t) noexcept; -// template <class T> -// bool operator!=(nullptr_t, const shared_ptr<T>& y) noexcept; -// template <class T> -// bool operator<(const shared_ptr<T>& x, nullptr_t) noexcept; -// template <class T> -// bool operator<(nullptr_t, const shared_ptr<T>& y) noexcept; -// template <class T> -// bool operator<=(const shared_ptr<T>& x, nullptr_t) noexcept; -// template <class T> -// bool operator<=(nullptr_t, const shared_ptr<T>& y) noexcept; -// template <class T> -// bool operator>(const shared_ptr<T>& x, nullptr_t) noexcept; -// template <class T> -// bool operator>(nullptr_t, const shared_ptr<T>& y) noexcept; -// template <class T> -// bool operator>=(const shared_ptr<T>& x, nullptr_t) noexcept; -// template <class T> -// bool operator>=(nullptr_t, const shared_ptr<T>& y) noexcept; - -#include <memory> -#include <cassert> - -void do_nothing(int*) {} - -int main() -{ - const std::shared_ptr<int> p1(new int(1)); - assert(!(p1 == nullptr)); - assert(!(nullptr == p1)); - assert(!(p1 < nullptr)); - assert( (nullptr < p1)); - assert(!(p1 <= nullptr)); - assert( (nullptr <= p1)); - assert( (p1 > nullptr)); - assert(!(nullptr > p1)); - assert( (p1 >= nullptr)); - assert(!(nullptr >= p1)); - - const std::shared_ptr<int> p2; - assert( (p2 == nullptr)); - assert( (nullptr == p2)); - assert(!(p2 < nullptr)); - assert(!(nullptr < p2)); - assert( (p2 <= nullptr)); - assert( (nullptr <= p2)); - assert(!(p2 > nullptr)); - assert(!(nullptr > p2)); - assert( (p2 >= nullptr)); - assert( (nullptr >= p2)); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/eq.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/eq.pass.cpp deleted file mode 100644 index c4cd1693f49..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/eq.pass.cpp +++ /dev/null @@ -1,31 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class T, class U> bool operator==(const shared_ptr<T>& a, const shared_ptr<U>& b); -// template<class T, class U> bool operator!=(const shared_ptr<T>& a, const shared_ptr<U>& b); - -#include <memory> -#include <cassert> - -void do_nothing(int*) {} - -int main() -{ - int* ptr1(new int); - int* ptr2(new int); - const std::shared_ptr<int> p1(ptr1); - const std::shared_ptr<int> p2(ptr2); - const std::shared_ptr<int> p3(ptr2, do_nothing); - assert(p1 != p2); - assert(p2 == p3); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/lt.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/lt.pass.cpp deleted file mode 100644 index 5a90a9a325f..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.cmp/lt.pass.cpp +++ /dev/null @@ -1,30 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class T, class U> bool operator<(const shared_ptr<T>& a, const shared_ptr<U>& b); - -#include <memory> -#include <cassert> - -void do_nothing(int*) {} - -int main() -{ - int* ptr1(new int); - int* ptr2(new int); - const std::shared_ptr<int> p1(ptr1); - const std::shared_ptr<int> p2(ptr2); - const std::shared_ptr<int> p3(ptr2, do_nothing); - assert((p1 < p2) == (ptr1 < ptr2)); - assert(!(p2 < p3) && !(p3 < p2)); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp deleted file mode 100644 index 28e49d6ecc4..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/auto_ptr.pass.cpp +++ /dev/null @@ -1,104 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template<class Y> explicit shared_ptr(auto_ptr<Y>&& r); - -// UNSUPPORTED: asan, msan - -#include <memory> -#include <new> -#include <cstdlib> -#include <cassert> - -bool throw_next = false; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - if (throw_next) - throw std::bad_alloc(); - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - std::free(p); -} - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::auto_ptr<A> ptr(new A); - A* raw_ptr = ptr.get(); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - std::shared_ptr<B> p(std::move(ptr)); -#else - std::shared_ptr<B> p(ptr); -#endif - assert(A::count == 1); - assert(B::count == 1); - assert(p.use_count() == 1); - assert(p.get() == raw_ptr); - assert(ptr.get() == 0); - } - assert(A::count == 0); - { - std::auto_ptr<A> ptr(new A); - A* raw_ptr = ptr.get(); - throw_next = true; - try - { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - std::shared_ptr<B> p(std::move(ptr)); -#else - std::shared_ptr<B> p(ptr); -#endif - assert(false); - } - catch (...) - { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(A::count == 1); - assert(B::count == 1); - assert(ptr.get() == raw_ptr); -#else - // Without rvalue references, ptr got copied into - // the shared_ptr destructor and the copy was - // destroyed during unwinding. - assert(A::count == 0); - assert(B::count == 0); -#endif - } - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.pass.cpp deleted file mode 100644 index 9af5d7ea861..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/default.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr(); - -#include <memory> -#include <cassert> - -int main() -{ - std::shared_ptr<int> p; - assert(p.use_count() == 0); - assert(p.get() == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t.pass.cpp deleted file mode 100644 index 3a9b3a9ca1d..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr(nullptr_t) - -#include <memory> -#include <cassert> - -int main() -{ - std::shared_ptr<int> p(nullptr); - assert(p.use_count() == 0); - assert(p.get() == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp deleted file mode 100644 index 7d4dc38d4b9..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter.pass.cpp +++ /dev/null @@ -1,47 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class D> shared_ptr(nullptr_t, D d); - -#include <memory> -#include <cassert> -#include "../test_deleter.h" - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::shared_ptr<A> p(nullptr, test_deleter<A>(3)); - assert(A::count == 0); - assert(p.use_count() == 1); - assert(p.get() == 0); - test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p); - assert(test_deleter<A>::count == 1); - assert(test_deleter<A>::dealloc_count == 0); - assert(d); - assert(d->state() == 3); - } - assert(A::count == 0); - assert(test_deleter<A>::count == 0); - assert(test_deleter<A>::dealloc_count == 1); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp deleted file mode 100644 index b67f31ee45a..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator.pass.cpp +++ /dev/null @@ -1,85 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template<class D, class A> shared_ptr(nullptr_t, D d, A a); - -#include <memory> -#include <cassert> -#include "../test_deleter.h" -#include "test_allocator.h" -#include "min_allocator.h" - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::shared_ptr<A> p(nullptr, test_deleter<A>(3), test_allocator<A>(5)); - assert(A::count == 0); - assert(p.use_count() == 1); - assert(p.get() == 0); - test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p); - assert(test_deleter<A>::count == 1); - assert(test_deleter<A>::dealloc_count == 0); - assert(d); - assert(d->state() == 3); - assert(test_allocator<A>::count == 1); - assert(test_allocator<A>::alloc_count == 1); - } - assert(A::count == 0); - assert(test_deleter<A>::count == 0); - assert(test_deleter<A>::dealloc_count == 1); - assert(test_allocator<A>::count == 0); - assert(test_allocator<A>::alloc_count == 0); - test_deleter<A>::dealloc_count = 0; - // Test an allocator with a minimal interface - { - std::shared_ptr<A> p(nullptr, test_deleter<A>(1), bare_allocator<void>()); - assert(A::count == 0); - assert(p.use_count() == 1); - assert(p.get() == 0); - test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p); - assert(test_deleter<A>::count ==1); - assert(test_deleter<A>::dealloc_count == 0); - assert(d); - assert(d->state() == 1); - } - assert(A::count == 0); - assert(test_deleter<A>::count == 0); - assert(test_deleter<A>::dealloc_count == 1); - test_deleter<A>::dealloc_count = 0; -#if __cplusplus >= 201103L - // Test an allocator that returns class-type pointers - { - std::shared_ptr<A> p(nullptr, test_deleter<A>(1), min_allocator<void>()); - assert(A::count == 0); - assert(p.use_count() == 1); - assert(p.get() == 0); - test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p); - assert(test_deleter<A>::count ==1); - assert(test_deleter<A>::dealloc_count == 0); - assert(d); - assert(d->state() == 1); - } - assert(A::count == 0); - assert(test_deleter<A>::count == 0); - assert(test_deleter<A>::dealloc_count == 1); -#endif -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp deleted file mode 100644 index ab2c73e0c5f..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_allocator_throw.pass.cpp +++ /dev/null @@ -1,46 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template<class D, class A> shared_ptr(nullptr_t, D d, A a); - -#include <memory> -#include <cassert> -#include "../test_deleter.h" -#include "test_allocator.h" - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - try - { - test_allocator<A>::throw_after = 0; - std::shared_ptr<A> p(nullptr, test_deleter<A>(3), test_allocator<A>(5)); - assert(false); - } - catch (std::bad_alloc&) - { - assert(A::count == 0); - assert(test_deleter<A>::count == 0); - assert(test_deleter<A>::dealloc_count == 1); - assert(test_allocator<A>::count == 0); - assert(test_allocator<A>::alloc_count == 0); - } -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp deleted file mode 100644 index a8588cc6735..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/nullptr_t_deleter_throw.pass.cpp +++ /dev/null @@ -1,63 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class D> shared_ptr(nullptr_t, D d); - -// UNSUPPORTED: asan, msan - -#include <memory> -#include <cassert> -#include <new> -#include <cstdlib> -#include "../test_deleter.h" - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -bool throw_next = false; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - if (throw_next) - throw std::bad_alloc(); - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - std::free(p); -} - -int main() -{ - throw_next = true; - try - { - std::shared_ptr<A> p(nullptr, test_deleter<A>(3)); - assert(false); - } - catch (std::bad_alloc&) - { - assert(A::count == 0); - assert(test_deleter<A>::count == 0); - assert(test_deleter<A>::dealloc_count == 1); - } -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp deleted file mode 100644 index c9cffa1fe25..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer.pass.cpp +++ /dev/null @@ -1,46 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template<class Y> explicit shared_ptr(Y* p); - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - A* ptr = new A; - std::shared_ptr<A> p(ptr); - assert(A::count == 1); - assert(p.use_count() == 1); - assert(p.get() == ptr); - } - assert(A::count == 0); - { - A* ptr = new A; - std::shared_ptr<void> p(ptr); - assert(A::count == 1); - assert(p.use_count() == 1); - assert(p.get() == ptr); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp deleted file mode 100644 index 43eedee176c..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter.pass.cpp +++ /dev/null @@ -1,48 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class Y, class D> shared_ptr(Y* p, D d); - -#include <memory> -#include <cassert> -#include "../test_deleter.h" - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - A* ptr = new A; - std::shared_ptr<A> p(ptr, test_deleter<A>(3)); - assert(A::count == 1); - assert(p.use_count() == 1); - assert(p.get() == ptr); - test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p); - assert(test_deleter<A>::count == 1); - assert(test_deleter<A>::dealloc_count == 0); - assert(d); - assert(d->state() == 3); - } - assert(A::count == 0); - assert(test_deleter<A>::count == 0); - assert(test_deleter<A>::dealloc_count == 1); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp deleted file mode 100644 index 1a9c09cdb78..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator.pass.cpp +++ /dev/null @@ -1,89 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template<class Y, class D, class A> shared_ptr(Y* p, D d, A a); - -#include <memory> -#include <cassert> -#include "../test_deleter.h" -#include "test_allocator.h" -#include "min_allocator.h" - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - - -int main() -{ - { - A* ptr = new A; - std::shared_ptr<A> p(ptr, test_deleter<A>(3), test_allocator<A>(5)); - assert(A::count == 1); - assert(p.use_count() == 1); - assert(p.get() == ptr); - test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p); - assert(test_deleter<A>::count == 1); - assert(test_deleter<A>::dealloc_count == 0); - assert(d); - assert(d->state() == 3); - assert(test_allocator<A>::count == 1); - assert(test_allocator<A>::alloc_count == 1); - } - assert(A::count == 0); - assert(test_deleter<A>::count == 0); - assert(test_deleter<A>::dealloc_count == 1); - assert(test_allocator<A>::count == 0); - assert(test_allocator<A>::alloc_count == 0); - test_deleter<A>::dealloc_count = 0; - // Test an allocator with a minimal interface - { - A* ptr = new A; - std::shared_ptr<A> p(ptr, test_deleter<A>(3), bare_allocator<void>()); - assert(A::count == 1); - assert(p.use_count() == 1); - assert(p.get() == ptr); - test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p); - assert(test_deleter<A>::count == 1); - assert(test_deleter<A>::dealloc_count == 0); - assert(d); - assert(d->state() == 3); - } - assert(A::count == 0); - assert(test_deleter<A>::count == 0); - assert(test_deleter<A>::dealloc_count == 1); - test_deleter<A>::dealloc_count = 0; -#if __cplusplus >= 201103L - // Test an allocator that returns class-type pointers - { - A* ptr = new A; - std::shared_ptr<A> p(ptr, test_deleter<A>(3), min_allocator<void>()); - assert(A::count == 1); - assert(p.use_count() == 1); - assert(p.get() == ptr); - test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p); - assert(test_deleter<A>::count == 1); - assert(test_deleter<A>::dealloc_count == 0); - assert(d); - assert(d->state() == 3); - } - assert(A::count == 0); - assert(test_deleter<A>::count == 0); - assert(test_deleter<A>::dealloc_count == 1); -#endif -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp deleted file mode 100644 index 4220993a5fd..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_allocator_throw.pass.cpp +++ /dev/null @@ -1,47 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template<class Y, class D, class A> shared_ptr(Y* p, D d, A a); - -#include <memory> -#include <cassert> -#include "../test_deleter.h" -#include "test_allocator.h" - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - A* ptr = new A; - try - { - test_allocator<A>::throw_after = 0; - std::shared_ptr<A> p(ptr, test_deleter<A>(3), test_allocator<A>(5)); - assert(false); - } - catch (std::bad_alloc&) - { - assert(A::count == 0); - assert(test_deleter<A>::count == 0); - assert(test_deleter<A>::dealloc_count == 1); - assert(test_allocator<A>::count == 0); - assert(test_allocator<A>::alloc_count == 0); - } -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp deleted file mode 100644 index b024f7e15a5..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_deleter_throw.pass.cpp +++ /dev/null @@ -1,64 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class Y, class D> shared_ptr(Y* p, D d); - -// UNSUPPORTED: asan, msan - -#include <memory> -#include <cassert> -#include <new> -#include <cstdlib> -#include "../test_deleter.h" - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -bool throw_next = false; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - if (throw_next) - throw std::bad_alloc(); - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - std::free(p); -} - -int main() -{ - A* ptr = new A; - throw_next = true; - try - { - std::shared_ptr<A> p(ptr, test_deleter<A>(3)); - assert(false); - } - catch (std::bad_alloc&) - { - assert(A::count == 0); - assert(test_deleter<A>::count == 0); - assert(test_deleter<A>::dealloc_count == 1); - } -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp deleted file mode 100644 index 28fb8bfd91c..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/pointer_throw.pass.cpp +++ /dev/null @@ -1,62 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template<class Y> explicit shared_ptr(Y* p); - -// UNSUPPORTED: asan, msan - -#include <memory> -#include <new> -#include <cstdlib> -#include <cassert> - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -bool throw_next = false; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - if (throw_next) - throw std::bad_alloc(); - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - std::free(p); -} - -int main() -{ - { - A* ptr = new A; - throw_next = true; - assert(A::count == 1); - try - { - std::shared_ptr<A> p(ptr); - assert(false); - } - catch (std::bad_alloc&) - { - assert(A::count == 0); - } - } -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr.pass.cpp deleted file mode 100644 index e1dcdfc8165..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr.pass.cpp +++ /dev/null @@ -1,62 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// shared_ptr(const shared_ptr& r); - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::shared_ptr<A> pA(new A); - assert(pA.use_count() == 1); - assert(A::count == 1); - { - std::shared_ptr<A> pA2(pA); - assert(A::count == 1); - assert(pA.use_count() == 2); - assert(pA2.use_count() == 2); - assert(pA2.get() == pA.get()); - } - assert(pA.use_count() == 1); - assert(A::count == 1); - } - assert(A::count == 0); - { - std::shared_ptr<A> pA; - assert(pA.use_count() == 0); - assert(A::count == 0); - { - std::shared_ptr<A> pA2(pA); - assert(A::count == 0); - assert(pA.use_count() == 0); - assert(pA2.use_count() == 0); - assert(pA2.get() == pA.get()); - } - assert(pA.use_count() == 0); - assert(A::count == 0); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp deleted file mode 100644 index 8b5ffdc1475..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y.pass.cpp +++ /dev/null @@ -1,97 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class Y> shared_ptr(const shared_ptr<Y>& r); - -#include <memory> -#include <type_traits> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -struct C -{ - static int count; - - C() {++count;} - C(const C&) {++count;} - virtual ~C() {--count;} -}; - -int C::count = 0; - -int main() -{ - static_assert(( std::is_convertible<std::shared_ptr<A>, std::shared_ptr<B> >::value), ""); - static_assert((!std::is_convertible<std::shared_ptr<B>, std::shared_ptr<A> >::value), ""); - static_assert((!std::is_convertible<std::shared_ptr<A>, std::shared_ptr<C> >::value), ""); - { - const std::shared_ptr<A> pA(new A); - assert(pA.use_count() == 1); - assert(B::count == 1); - assert(A::count == 1); - { - std::shared_ptr<B> pB(pA); - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 2); - assert(pA.use_count() == 2); - assert(pA.get() == pB.get()); - } - assert(pA.use_count() == 1); - assert(B::count == 1); - assert(A::count == 1); - } - assert(B::count == 0); - assert(A::count == 0); - { - std::shared_ptr<A> pA; - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - { - std::shared_ptr<B> pB(pA); - assert(B::count == 0); - assert(A::count == 0); - assert(pB.use_count() == 0); - assert(pA.use_count() == 0); - assert(pA.get() == pB.get()); - } - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp deleted file mode 100644 index f041d9451a6..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_Y_rv.pass.cpp +++ /dev/null @@ -1,109 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class Y> shared_ptr(shared_ptr<Y>&& r); - -#include <memory> -#include <type_traits> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -struct C -{ - static int count; - - C() {++count;} - C(const C&) {++count;} - virtual ~C() {--count;} -}; - -int C::count = 0; - -int main() -{ - static_assert(( std::is_convertible<std::shared_ptr<A>, std::shared_ptr<B> >::value), ""); - static_assert((!std::is_convertible<std::shared_ptr<B>, std::shared_ptr<A> >::value), ""); - static_assert((!std::is_convertible<std::shared_ptr<A>, std::shared_ptr<C> >::value), ""); - { - std::shared_ptr<A> pA(new A); - assert(pA.use_count() == 1); - assert(B::count == 1); - assert(A::count == 1); - { - B* p = pA.get(); - std::shared_ptr<B> pB(std::move(pA)); - assert(B::count == 1); - assert(A::count == 1); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(pB.use_count() == 1); - assert(pA.use_count() == 0); -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(pB.use_count() == 2); - assert(pA.use_count() == 2); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(p == pB.get()); - } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(pA.use_count() == 1); - assert(B::count == 1); - assert(A::count == 1); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - } - assert(B::count == 0); - assert(A::count == 0); - { - std::shared_ptr<A> pA; - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - { - std::shared_ptr<B> pB(pA); - assert(B::count == 0); - assert(A::count == 0); - assert(pB.use_count() == 0); - assert(pA.use_count() == 0); - assert(pA.get() == pB.get()); - } - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_pointer.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_pointer.pass.cpp deleted file mode 100644 index fb5262f3b0e..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_pointer.pass.cpp +++ /dev/null @@ -1,61 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class Y> shared_ptr(const shared_ptr<Y>& r, T *p); - -#include <memory> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - ~B() {--count;} -}; - -int B::count = 0; - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::shared_ptr<A> pA(new A); - assert(pA.use_count() == 1); - { - B b; - std::shared_ptr<B> pB(pA, &b); - assert(A::count == 1); - assert(B::count == 1); - assert(pA.use_count() == 2); - assert(pB.use_count() == 2); - assert(pB.get() == &b); - } - assert(pA.use_count() == 1); - assert(A::count == 1); - assert(B::count == 0); - } - assert(A::count == 0); - assert(B::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp deleted file mode 100644 index b89178e201c..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/shared_ptr_rv.pass.cpp +++ /dev/null @@ -1,73 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// shared_ptr(shared_ptr&& r); - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::shared_ptr<A> pA(new A); - assert(pA.use_count() == 1); - assert(A::count == 1); - { - A* p = pA.get(); - std::shared_ptr<A> pA2(std::move(pA)); - assert(A::count == 1); -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(pA.use_count() == 0); - assert(pA2.use_count() == 1); -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(pA.use_count() == 2); - assert(pA2.use_count() == 2); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(pA2.get() == p); - } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(pA.use_count() == 0); - assert(A::count == 0); -#else // _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(pA.use_count() == 1); - assert(A::count == 1); -#endif // _LIBCPP_HAS_NO_RVALUE_REFERENCES - } - assert(A::count == 0); - { - std::shared_ptr<A> pA; - assert(pA.use_count() == 0); - assert(A::count == 0); - { - std::shared_ptr<A> pA2(std::move(pA)); - assert(A::count == 0); - assert(pA.use_count() == 0); - assert(pA2.use_count() == 0); - assert(pA2.get() == pA.get()); - } - assert(pA.use_count() == 0); - assert(A::count == 0); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp deleted file mode 100644 index dc2a6afef21..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/unique_ptr.pass.cpp +++ /dev/null @@ -1,103 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class Y, class D> explicit shared_ptr(unique_ptr<Y, D>&&r); - -// UNSUPPORTED: asan, msan - -#include <memory> -#include <new> -#include <cstdlib> -#include <cassert> - -bool throw_next = false; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - if (throw_next) - throw std::bad_alloc(); - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - std::free(p); -} - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -void fn ( const std::shared_ptr<int> &) {} -void fn ( const std::shared_ptr<B> &) { assert (false); } - -int main() -{ - { - std::unique_ptr<A> ptr(new A); - A* raw_ptr = ptr.get(); - std::shared_ptr<B> p(std::move(ptr)); - assert(A::count == 1); - assert(B::count == 1); - assert(p.use_count() == 1); - assert(p.get() == raw_ptr); - assert(ptr.get() == 0); - } - assert(A::count == 0); - { - std::unique_ptr<A> ptr(new A); - A* raw_ptr = ptr.get(); - throw_next = true; - try - { - std::shared_ptr<B> p(std::move(ptr)); - assert(false); - } - catch (...) - { -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - assert(A::count == 1); - assert(B::count == 1); - assert(ptr.get() == raw_ptr); -#else - assert(A::count == 0); - assert(B::count == 0); - assert(ptr.get() == 0); -#endif - } - } - assert(A::count == 0); - - // LWG 2399 - { - throw_next = false; - fn(std::unique_ptr<int>(new int)); - } -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp deleted file mode 100644 index a9d8aff145a..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.const/weak_ptr.pass.cpp +++ /dev/null @@ -1,79 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class Y> explicit shared_ptr(const weak_ptr<Y>& r); - -#include <memory> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::weak_ptr<A> wp; - try - { - std::shared_ptr<A> sp(wp); - assert(false); - } - catch (std::bad_weak_ptr&) - { - } - assert(A::count == 0); - } - { - std::shared_ptr<A> sp0(new A); - std::weak_ptr<A> wp(sp0); - std::shared_ptr<A> sp(wp); - assert(sp.use_count() == 2); - assert(sp.get() == sp0.get()); - assert(A::count == 1); - } - assert(A::count == 0); - { - std::shared_ptr<A> sp0(new A); - std::weak_ptr<A> wp(sp0); - sp0.reset(); - try - { - std::shared_ptr<A> sp(wp); - assert(false); - } - catch (std::bad_weak_ptr&) - { - } - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp deleted file mode 100644 index aa77dab5151..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared.pass.cpp +++ /dev/null @@ -1,78 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class T, class A, class... Args> -// shared_ptr<T> allocate_shared(const A& a, Args&&... args); - -#include <memory> -#include <new> -#include <cstdlib> -#include <cassert> -#include "test_allocator.h" -#include "min_allocator.h" - -int new_count = 0; - -struct A -{ - static int count; - - A(int i, char c) : int_(i), char_(c) {++count;} - A(const A& a) - : int_(a.int_), char_(a.char_) - {++count;} - ~A() {--count;} - - int get_int() const {return int_;} - char get_char() const {return char_;} -private: - int int_; - char char_; -}; - -int A::count = 0; - -int main() -{ - { - int i = 67; - char c = 'e'; - std::shared_ptr<A> p = std::allocate_shared<A>(test_allocator<A>(54), i, c); - assert(test_allocator<A>::alloc_count == 1); - assert(A::count == 1); - assert(p->get_int() == 67); - assert(p->get_char() == 'e'); - } - assert(A::count == 0); - assert(test_allocator<A>::alloc_count == 0); -#if __cplusplus >= 201103L - { - int i = 67; - char c = 'e'; - std::shared_ptr<A> p = std::allocate_shared<A>(min_allocator<void>(), i, c); - assert(A::count == 1); - assert(p->get_int() == 67); - assert(p->get_char() == 'e'); - } - assert(A::count == 0); - { - int i = 68; - char c = 'f'; - std::shared_ptr<A> p = std::allocate_shared<A>(bare_allocator<void>(), i, c); - assert(A::count == 1); - assert(p->get_int() == 68); - assert(p->get_char() == 'f'); - } - assert(A::count == 0); -#endif -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_no_variadics.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_no_variadics.pass.cpp deleted file mode 100644 index 8dcd50e4941..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/allocate_shared_no_variadics.pass.cpp +++ /dev/null @@ -1,118 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class T, class A, class... Args> -// shared_ptr<T> allocate_shared(const A& a, Args&&... args); - -#define _LIBCPP_HAS_NO_VARIADICS -#include <memory> -#include <new> -#include <cstdlib> -#include <cassert> -#include "test_allocator.h" -#include "min_allocator.h" - -struct Zero -{ - static int count; - Zero() {++count;} - Zero(Zero const &) {++count;} - ~Zero() {--count;} -}; - -int Zero::count = 0; - -struct One -{ - static int count; - int value; - explicit One(int v) : value(v) {++count;} - One(One const & o) : value(o.value) {++count;} - ~One() {--count;} -}; - -int One::count = 0; - - -struct Two -{ - static int count; - int value; - Two(int v, int) : value(v) {++count;} - Two(Two const & o) : value(o.value) {++count;} - ~Two() {--count;} -}; - -int Two::count = 0; - -struct Three -{ - static int count; - int value; - Three(int v, int, int) : value(v) {++count;} - Three(Three const & o) : value(o.value) {++count;} - ~Three() {--count;} -}; - -int Three::count = 0; - -template <class Alloc> -void test() -{ - int const bad = -1; - { - std::shared_ptr<Zero> p = std::allocate_shared<Zero>(Alloc()); - assert(Zero::count == 1); - } - assert(Zero::count == 0); - { - int const i = 42; - std::shared_ptr<One> p = std::allocate_shared<One>(Alloc(), i); - assert(One::count == 1); - assert(p->value == i); - } - assert(One::count == 0); - { - int const i = 42; - std::shared_ptr<Two> p = std::allocate_shared<Two>(Alloc(), i, bad); - assert(Two::count == 1); - assert(p->value == i); - } - assert(Two::count == 0); - { - int const i = 42; - std::shared_ptr<Three> p = std::allocate_shared<Three>(Alloc(), i, bad, bad); - assert(Three::count == 1); - assert(p->value == i); - } - assert(Three::count == 0); -} - -int main() -{ - { - int i = 67; - int const bad = -1; - std::shared_ptr<Two> p = std::allocate_shared<Two>(test_allocator<Two>(54), i, bad); - assert(test_allocator<Two>::alloc_count == 1); - assert(Two::count == 1); - assert(p->value == 67); - } - assert(Two::count == 0); - assert(test_allocator<Two>::alloc_count == 0); - - test<bare_allocator<void> >(); -#if __cplusplus >= 201103L - test<min_allocator<void> >(); -#endif -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp deleted file mode 100644 index 30a4984003b..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.create/make_shared.pass.cpp +++ /dev/null @@ -1,79 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class T, class... Args> shared_ptr<T> make_shared(Args&&... args); - -// UNSUPPORTED: asan, msan - -#include <memory> -#include <new> -#include <cstdlib> -#include <cassert> - -int new_count = 0; - -void* operator new(std::size_t s) throw(std::bad_alloc) -{ - ++new_count; - return std::malloc(s); -} - -void operator delete(void* p) throw() -{ - std::free(p); -} - -struct A -{ - static int count; - - A(int i, char c) : int_(i), char_(c) {++count;} - A(const A& a) - : int_(a.int_), char_(a.char_) - {++count;} - ~A() {--count;} - - int get_int() const {return int_;} - char get_char() const {return char_;} -private: - int int_; - char char_; -}; - -int A::count = 0; - -int main() -{ - int nc = new_count; - { - int i = 67; - char c = 'e'; - std::shared_ptr<A> p = std::make_shared<A>(i, c); - assert(new_count == nc+1); - assert(A::count == 1); - assert(p->get_int() == 67); - assert(p->get_char() == 'e'); - } -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - nc = new_count; - { - char c = 'e'; - std::shared_ptr<A> p = std::make_shared<A>(67, c); - assert(new_count == nc+1); - assert(A::count == 1); - assert(p->get_int() == 67); - assert(p->get_char() == 'e'); - } -#endif - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_elsewhere.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_elsewhere.pass.cpp deleted file mode 100644 index b58f5c55b64..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.dest/tested_elsewhere.pass.cpp +++ /dev/null @@ -1,12 +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. -// -//===----------------------------------------------------------------------===// - -int main() -{ -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/io.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/io.pass.cpp deleted file mode 100644 index b627ac1ccbc..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.io/io.pass.cpp +++ /dev/null @@ -1,29 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class CharT, class Traits, class Y> -// basic_ostream<CharT, Traits>& -// operator<<(basic_ostream<CharT, Traits>& os, shared_ptr<Y> const& p); - -#include <memory> -#include <sstream> -#include <cassert> - -int main() -{ - std::shared_ptr<int> p(new int(3)); - std::ostringstream os; - assert(os.str().empty()); - os << p; - assert(!os.str().empty()); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.cpp deleted file mode 100644 index 7bffc06993f..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset.pass.cpp +++ /dev/null @@ -1,62 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// void reset(); - -#include <memory> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::shared_ptr<B> p(new B); - p.reset(); - assert(A::count == 0); - assert(B::count == 0); - assert(p.use_count() == 0); - assert(p.get() == 0); - } - assert(A::count == 0); - { - std::shared_ptr<B> p; - p.reset(); - assert(A::count == 0); - assert(B::count == 0); - assert(p.use_count() == 0); - assert(p.get() == 0); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp deleted file mode 100644 index 85a64d0f1b0..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer.pass.cpp +++ /dev/null @@ -1,64 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class Y> void reset(Y* p); - -#include <memory> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::shared_ptr<B> p(new B); - A* ptr = new A; - p.reset(ptr); - assert(A::count == 1); - assert(B::count == 1); - assert(p.use_count() == 1); - assert(p.get() == ptr); - } - assert(A::count == 0); - { - std::shared_ptr<B> p; - A* ptr = new A; - p.reset(ptr); - assert(A::count == 1); - assert(B::count == 1); - assert(p.use_count() == 1); - assert(p.get() == ptr); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp deleted file mode 100644 index 33965dfeb33..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter.pass.cpp +++ /dev/null @@ -1,79 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class Y, class D> void reset(Y* p, D d); - -#include <memory> -#include <cassert> -#include "../test_deleter.h" - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::shared_ptr<B> p(new B); - A* ptr = new A; - p.reset(ptr, test_deleter<A>(3)); - assert(A::count == 1); - assert(B::count == 1); - assert(p.use_count() == 1); - assert(p.get() == ptr); - test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p); - assert(test_deleter<A>::count == 1); - assert(test_deleter<A>::dealloc_count == 0); - assert(d); - assert(d->state() == 3); - } - assert(A::count == 0); - assert(test_deleter<A>::count == 0); - assert(test_deleter<A>::dealloc_count == 1); - { - std::shared_ptr<B> p; - A* ptr = new A; - p.reset(ptr, test_deleter<A>(3)); - assert(A::count == 1); - assert(B::count == 1); - assert(p.use_count() == 1); - assert(p.get() == ptr); - test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p); - assert(test_deleter<A>::count == 1); - assert(test_deleter<A>::dealloc_count == 1); - assert(d); - assert(d->state() == 3); - } - assert(A::count == 0); - assert(test_deleter<A>::count == 0); - assert(test_deleter<A>::dealloc_count == 2); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp deleted file mode 100644 index 09070e2c059..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/reset_pointer_deleter_allocator.pass.cpp +++ /dev/null @@ -1,88 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class Y, class D, class A> void reset(Y* p, D d, A a); - -#include <memory> -#include <cassert> -#include "../test_deleter.h" -#include "test_allocator.h" - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::shared_ptr<B> p(new B); - A* ptr = new A; - p.reset(ptr, test_deleter<A>(3), test_allocator<A>(4)); - assert(A::count == 1); - assert(B::count == 1); - assert(p.use_count() == 1); - assert(p.get() == ptr); - test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p); - assert(test_deleter<A>::count == 1); - assert(test_deleter<A>::dealloc_count == 0); - assert(d); - assert(d->state() == 3); - assert(test_allocator<A>::count == 1); - assert(test_allocator<A>::alloc_count == 1); - } - assert(A::count == 0); - assert(test_deleter<A>::count == 0); - assert(test_deleter<A>::dealloc_count == 1); - assert(test_allocator<A>::count == 0); - assert(test_allocator<A>::alloc_count == 0); - { - std::shared_ptr<B> p; - A* ptr = new A; - p.reset(ptr, test_deleter<A>(3), test_allocator<A>(4)); - assert(A::count == 1); - assert(B::count == 1); - assert(p.use_count() == 1); - assert(p.get() == ptr); - test_deleter<A>* d = std::get_deleter<test_deleter<A> >(p); - assert(test_deleter<A>::count == 1); - assert(test_deleter<A>::dealloc_count == 1); - assert(d); - assert(d->state() == 3); - assert(test_allocator<A>::count == 1); - assert(test_allocator<A>::alloc_count == 1); - } - assert(A::count == 0); - assert(test_deleter<A>::count == 0); - assert(test_deleter<A>::dealloc_count == 2); - assert(test_allocator<A>::count == 0); - assert(test_allocator<A>::alloc_count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.cpp deleted file mode 100644 index 6d28a5043ca..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.mod/swap.pass.cpp +++ /dev/null @@ -1,104 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// void swap(shared_ptr& r); - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - A* ptr1 = new A; - A* ptr2 = new A; - std::shared_ptr<A> p1(ptr1); - { - std::shared_ptr<A> p2(ptr2); - p1.swap(p2); - assert(p1.use_count() == 1); - assert(p1.get() == ptr2); - assert(p2.use_count() == 1); - assert(p2.get() == ptr1); - assert(A::count == 2); - } - assert(p1.use_count() == 1); - assert(p1.get() == ptr2); - assert(A::count == 1); - } - assert(A::count == 0); - { - A* ptr1 = new A; - A* ptr2 = 0; - std::shared_ptr<A> p1(ptr1); - { - std::shared_ptr<A> p2; - p1.swap(p2); - assert(p1.use_count() == 0); - assert(p1.get() == ptr2); - assert(p2.use_count() == 1); - assert(p2.get() == ptr1); - assert(A::count == 1); - } - assert(p1.use_count() == 0); - assert(p1.get() == ptr2); - assert(A::count == 0); - } - assert(A::count == 0); - { - A* ptr1 = 0; - A* ptr2 = new A; - std::shared_ptr<A> p1; - { - std::shared_ptr<A> p2(ptr2); - p1.swap(p2); - assert(p1.use_count() == 1); - assert(p1.get() == ptr2); - assert(p2.use_count() == 0); - assert(p2.get() == ptr1); - assert(A::count == 1); - } - assert(p1.use_count() == 1); - assert(p1.get() == ptr2); - assert(A::count == 1); - } - assert(A::count == 0); - { - A* ptr1 = 0; - A* ptr2 = 0; - std::shared_ptr<A> p1; - { - std::shared_ptr<A> p2; - p1.swap(p2); - assert(p1.use_count() == 0); - assert(p1.get() == ptr2); - assert(p2.use_count() == 0); - assert(p2.get() == ptr1); - assert(A::count == 0); - } - assert(p1.use_count() == 0); - assert(p1.get() == ptr2); - assert(A::count == 0); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.pass.cpp deleted file mode 100644 index 00281687521..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/arrow.pass.cpp +++ /dev/null @@ -1,29 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// T* operator->() const; - -#include <memory> -#include <utility> -#include <cassert> - -int main() -{ - const std::shared_ptr<std::pair<int, int> > p(new std::pair<int, int>(3, 4)); - assert(p->first == 3); - assert(p->second == 4); - p->first = 5; - p->second = 6; - assert(p->first == 5); - assert(p->second == 6); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference.pass.cpp deleted file mode 100644 index 378cd0514ca..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/dereference.pass.cpp +++ /dev/null @@ -1,25 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// T& operator*() const; - -#include <memory> -#include <cassert> - -int main() -{ - const std::shared_ptr<int> p(new int(32)); - assert(*p == 32); - *p = 3; - assert(*p == 3); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pass.cpp deleted file mode 100644 index 1b79d497005..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/op_bool.pass.cpp +++ /dev/null @@ -1,29 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// explicit operator bool() const; - -#include <memory> -#include <cassert> - -int main() -{ - { - const std::shared_ptr<int> p(new int(32)); - assert(p); - } - { - const std::shared_ptr<int> p; - assert(!p); - } -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp deleted file mode 100644 index 3acd2f8c6f2..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_shared_ptr.pass.cpp +++ /dev/null @@ -1,28 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template <class U> bool owner_before(shared_ptr<U> const& b) const; - -#include <memory> -#include <cassert> - -int main() -{ - const std::shared_ptr<int> p1(new int); - const std::shared_ptr<int> p2 = p1; - const std::shared_ptr<int> p3(new int); - assert(!p1.owner_before(p2)); - assert(!p2.owner_before(p1)); - assert(p1.owner_before(p3) || p3.owner_before(p1)); - assert(p3.owner_before(p1) == p3.owner_before(p2)); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp deleted file mode 100644 index 33447ba7da0..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/owner_before_weak_ptr.pass.cpp +++ /dev/null @@ -1,31 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template <class U> bool owner_before(weak_ptr<U> const& b) const; - -#include <memory> -#include <cassert> - -int main() -{ - const std::shared_ptr<int> p1(new int); - const std::shared_ptr<int> p2 = p1; - const std::shared_ptr<int> p3(new int); - const std::weak_ptr<int> w1(p1); - const std::weak_ptr<int> w2(p2); - const std::weak_ptr<int> w3(p3); - assert(!p1.owner_before(w2)); - assert(!p2.owner_before(w1)); - assert(p1.owner_before(w3) || p3.owner_before(w1)); - assert(p3.owner_before(w1) == p3.owner_before(w2)); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass.cpp deleted file mode 100644 index 50ff692f9d4..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.obs/unique.pass.cpp +++ /dev/null @@ -1,28 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// bool unique() const; - -#include <memory> -#include <cassert> - -int main() -{ - const std::shared_ptr<int> p(new int(32)); - assert(p.unique()); - { - std::shared_ptr<int> p2 = p; - assert(!p.unique()); - } - assert(p.unique()); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.cpp deleted file mode 100644 index b40e4705acf..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.shared/util.smartptr.shared.spec/swap.pass.cpp +++ /dev/null @@ -1,104 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// shared_ptr - -// template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b); - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - A* ptr1 = new A; - A* ptr2 = new A; - std::shared_ptr<A> p1(ptr1); - { - std::shared_ptr<A> p2(ptr2); - swap(p1, p2); - assert(p1.use_count() == 1); - assert(p1.get() == ptr2); - assert(p2.use_count() == 1); - assert(p2.get() == ptr1); - assert(A::count == 2); - } - assert(p1.use_count() == 1); - assert(p1.get() == ptr2); - assert(A::count == 1); - } - assert(A::count == 0); - { - A* ptr1 = new A; - A* ptr2 = 0; - std::shared_ptr<A> p1(ptr1); - { - std::shared_ptr<A> p2; - swap(p1, p2); - assert(p1.use_count() == 0); - assert(p1.get() == ptr2); - assert(p2.use_count() == 1); - assert(p2.get() == ptr1); - assert(A::count == 1); - } - assert(p1.use_count() == 0); - assert(p1.get() == ptr2); - assert(A::count == 0); - } - assert(A::count == 0); - { - A* ptr1 = 0; - A* ptr2 = new A; - std::shared_ptr<A> p1; - { - std::shared_ptr<A> p2(ptr2); - swap(p1, p2); - assert(p1.use_count() == 1); - assert(p1.get() == ptr2); - assert(p2.use_count() == 0); - assert(p2.get() == ptr1); - assert(A::count == 1); - } - assert(p1.use_count() == 1); - assert(p1.get() == ptr2); - assert(A::count == 1); - } - assert(A::count == 0); - { - A* ptr1 = 0; - A* ptr2 = 0; - std::shared_ptr<A> p1; - { - std::shared_ptr<A> p2; - swap(p1, p2); - assert(p1.use_count() == 0); - assert(p1.get() == ptr2); - assert(p2.use_count() == 0); - assert(p2.get() == ptr1); - assert(A::count == 0); - } - assert(p1.use_count() == 0); - assert(p1.get() == ptr2); - assert(A::count == 0); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/types.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/types.pass.cpp deleted file mode 100644 index 45748d7db6f..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/types.pass.cpp +++ /dev/null @@ -1,26 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template<class T> class weak_ptr -// { -// public: -// typedef T element_type; -// ... -// }; - -#include <memory> - -struct A; // purposefully incomplete - -int main() -{ - static_assert((std::is_same<std::weak_ptr<A>::element_type, A>::value), ""); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp deleted file mode 100644 index db2ed3bb35a..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.ownerless/owner_less.pass.cpp +++ /dev/null @@ -1,74 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class T> struct owner_less; -// -// template <class T> -// struct owner_less<shared_ptr<T> > -// : binary_function<shared_ptr<T>, shared_ptr<T>, bool> -// { -// typedef bool result_type; -// bool operator()(shared_ptr<T> const&, shared_ptr<T> const&) const; -// bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const; -// bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const; -// }; -// -// template <class T> -// struct owner_less<weak_ptr<T> > -// : binary_function<weak_ptr<T>, weak_ptr<T>, bool> -// { -// typedef bool result_type; -// bool operator()(weak_ptr<T> const&, weak_ptr<T> const&) const; -// bool operator()(shared_ptr<T> const&, weak_ptr<T> const&) const; -// bool operator()(weak_ptr<T> const&, shared_ptr<T> const&) const; -// }; - -#include <memory> -#include <cassert> - -int main() -{ - const std::shared_ptr<int> p1(new int); - const std::shared_ptr<int> p2 = p1; - const std::shared_ptr<int> p3(new int); - const std::weak_ptr<int> w1(p1); - const std::weak_ptr<int> w2(p2); - const std::weak_ptr<int> w3(p3); - - { - typedef std::owner_less<std::shared_ptr<int> > CS; - CS cs; - - assert(!cs(p1, p2)); - assert(!cs(p2, p1)); - assert(cs(p1 ,p3) || cs(p3, p1)); - assert(cs(p3, p1) == cs(p3, p2)); - - assert(!cs(p1, w2)); - assert(!cs(p2, w1)); - assert(cs(p1, w3) || cs(p3, w1)); - assert(cs(p3, w1) == cs(p3, w2)); - } - { - typedef std::owner_less<std::weak_ptr<int> > CS; - CS cs; - - assert(!cs(w1, w2)); - assert(!cs(w2, w1)); - assert(cs(w1, w3) || cs(w3, w1)); - assert(cs(w3, w1) == cs(w3, w2)); - - assert(!cs(w1, p2)); - assert(!cs(w2, p1)); - assert(cs(w1, p3) || cs(w3, p1)); - assert(cs(w3, p1) == cs(w3, p2)); - } -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y.pass.cpp deleted file mode 100644 index 6b32079c71b..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/shared_ptr_Y.pass.cpp +++ /dev/null @@ -1,61 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// weak_ptr - -// template<class Y> weak_ptr& operator=(const shared_ptr<Y>& r); - -#include <memory> -#include <type_traits> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - const std::shared_ptr<A> pA(new A); - { - std::weak_ptr<B> pB; - pB = pA; - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 1); - assert(pA.use_count() == 1); - } - assert(pA.use_count() == 1); - assert(B::count == 1); - assert(A::count == 1); - } - assert(B::count == 0); - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp deleted file mode 100644 index e5713f37521..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr.pass.cpp +++ /dev/null @@ -1,78 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// weak_ptr - -// weak_ptr& operator=(const weak_ptr& r); - -#include <memory> -#include <type_traits> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - const std::shared_ptr<A> ps(new A); - const std::weak_ptr<A> pA(ps); - { - std::weak_ptr<A> pB; - pB = pA; - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 1); - assert(pA.use_count() == 1); - } - assert(pA.use_count() == 1); - assert(B::count == 1); - assert(A::count == 1); - } - assert(B::count == 0); - assert(A::count == 0); - - { - const std::shared_ptr<A> ps(new A); - std::weak_ptr<A> pA(ps); - { - std::weak_ptr<A> pB; - pB = std::move(pA); - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 1); - } - assert(B::count == 1); - assert(A::count == 1); - } - assert(B::count == 0); - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp deleted file mode 100644 index 5a03d926f7d..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.assign/weak_ptr_Y.pass.cpp +++ /dev/null @@ -1,78 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// weak_ptr - -// template<class Y> weak_ptr& operator=(const weak_ptr<Y>& r); - -#include <memory> -#include <type_traits> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - const std::shared_ptr<A> ps(new A); - const std::weak_ptr<A> pA(ps); - { - std::weak_ptr<B> pB; - pB = pA; - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 1); - assert(pA.use_count() == 1); - } - assert(pA.use_count() == 1); - assert(B::count == 1); - assert(A::count == 1); - } - assert(B::count == 0); - assert(A::count == 0); - - { - const std::shared_ptr<A> ps(new A); - std::weak_ptr<A> pA(ps); - { - std::weak_ptr<B> pB; - pB = std::move(pA); - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 1); - } - assert(B::count == 1); - assert(A::count == 1); - } - assert(B::count == 0); - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.pass.cpp deleted file mode 100644 index 28358db6a44..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/default.pass.cpp +++ /dev/null @@ -1,25 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template<class T> class weak_ptr - -// weak_ptr(); - -#include <memory> -#include <cassert> - -struct A; - -int main() -{ - std::weak_ptr<A> p; - assert(p.use_count() == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.pass.cpp deleted file mode 100644 index d70adb940eb..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/shared_ptr_Y.pass.cpp +++ /dev/null @@ -1,95 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// weak_ptr - -// template<class Y> weak_ptr(const shared_ptr<Y>& r); - -#include <memory> -#include <type_traits> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -struct C -{ - static int count; - - C() {++count;} - C(const C&) {++count;} - virtual ~C() {--count;} -}; - -int C::count = 0; - -int main() -{ - static_assert(( std::is_convertible<std::shared_ptr<A>, std::weak_ptr<B> >::value), ""); - static_assert((!std::is_convertible<std::weak_ptr<B>, std::shared_ptr<A> >::value), ""); - static_assert((!std::is_convertible<std::shared_ptr<A>, std::weak_ptr<C> >::value), ""); - { - const std::shared_ptr<A> pA(new A); - assert(pA.use_count() == 1); - assert(B::count == 1); - assert(A::count == 1); - { - std::weak_ptr<B> pB(pA); - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 1); - assert(pA.use_count() == 1); - } - assert(pA.use_count() == 1); - assert(B::count == 1); - assert(A::count == 1); - } - assert(B::count == 0); - assert(A::count == 0); - { - std::shared_ptr<A> pA; - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - { - std::weak_ptr<B> pB(pA); - assert(B::count == 0); - assert(A::count == 0); - assert(pB.use_count() == 0); - assert(pA.use_count() == 0); - } - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp deleted file mode 100644 index 75bf3df90aa..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr.pass.cpp +++ /dev/null @@ -1,114 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// weak_ptr - -// weak_ptr(const weak_ptr& r); -// weak_ptr(weak_ptr &&r) - -#include <memory> -#include <type_traits> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -struct C -{ - static int count; - - C() {++count;} - C(const C&) {++count;} - virtual ~C() {--count;} -}; - -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 -template <class T> -void sink (std::weak_ptr<T> &&) {} -#endif - -int main() -{ - { - const std::shared_ptr<A> ps(new A); - const std::weak_ptr<A> pA(ps); - assert(pA.use_count() == 1); - assert(B::count == 1); - assert(A::count == 1); - { - std::weak_ptr<A> pB(pA); - assert(B::count == 1); - assert(A::count == 1); - assert(pB.use_count() == 1); - assert(pA.use_count() == 1); - } - assert(pA.use_count() == 1); - assert(B::count == 1); - assert(A::count == 1); - } - assert(B::count == 0); - assert(A::count == 0); - { - std::weak_ptr<A> pA; - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - { - std::weak_ptr<A> pB(pA); - assert(B::count == 0); - assert(A::count == 0); - assert(pB.use_count() == 0); - assert(pA.use_count() == 0); - } - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); - -#ifndef _LIBCPP_HAS_NO_RVALUE_REFERENCES - { - std::shared_ptr<A> ps(new A); - std::weak_ptr<A> pA = source(ps); - assert(pA.use_count() == 1); - assert(A::count == 1); - sink(std::move(pA)); // kill off the weak pointer - } - assert(B::count == 0); - assert(A::count == 0); -#endif -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp deleted file mode 100644 index 51a8fa5ae81..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.const/weak_ptr_Y.pass.cpp +++ /dev/null @@ -1,108 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// weak_ptr - -// template<class Y> weak_ptr(const weak_ptr<Y>& r); -// template<class Y> weak_ptr(weak_ptr<Y> &&r); - -#include <memory> -#include <type_traits> -#include <cassert> - -struct B -{ - static int count; - - B() {++count;} - B(const B&) {++count;} - virtual ~B() {--count;} -}; - -int B::count = 0; - -struct A - : public B -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -struct C -{ - static int count; - - C() {++count;} - C(const C&) {++count;} - virtual ~C() {--count;} -}; - -int C::count = 0; - -template <class T> -std::weak_ptr<T> source (std::shared_ptr<T> p) { return std::weak_ptr<T>(p); } - -int main() -{ - static_assert(( std::is_convertible<std::weak_ptr<A>, std::weak_ptr<B> >::value), ""); - static_assert((!std::is_convertible<std::weak_ptr<B>, std::weak_ptr<A> >::value), ""); - static_assert((!std::is_convertible<std::weak_ptr<A>, std::weak_ptr<C> >::value), ""); - { - const std::weak_ptr<A> pA(std::shared_ptr<A>(new A)); - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - { - std::weak_ptr<B> pB(pA); - assert(B::count == 0); - assert(A::count == 0); - assert(pB.use_count() == 0); - assert(pA.use_count() == 0); - } - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); - { - std::weak_ptr<A> pA; - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - { - std::weak_ptr<B> pB(pA); - assert(B::count == 0); - assert(A::count == 0); - assert(pB.use_count() == 0); - assert(pA.use_count() == 0); - } - assert(pA.use_count() == 0); - assert(B::count == 0); - assert(A::count == 0); - } - assert(B::count == 0); - assert(A::count == 0); - - { - std::shared_ptr<A> ps(new A); - std::weak_ptr<A> pA = source(ps); - std::weak_ptr<B> pB(std::move(pA)); - assert(pB.use_count() == 1); - } - assert(B::count == 0); - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhere.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhere.pass.cpp deleted file mode 100644 index b58f5c55b64..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.dest/tested_elsewhere.pass.cpp +++ /dev/null @@ -1,12 +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. -// -//===----------------------------------------------------------------------===// - -int main() -{ -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/reset.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/reset.pass.cpp deleted file mode 100644 index fa496d4bda5..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/reset.pass.cpp +++ /dev/null @@ -1,41 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// weak_ptr - -// void swap(weak_ptr& r); - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::shared_ptr<A> p1(new A); - std::weak_ptr<A> w1(p1); - assert(w1.use_count() == 1); - w1.reset(); - assert(w1.use_count() == 0); - assert(p1.use_count() == 1); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/swap.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/swap.pass.cpp deleted file mode 100644 index 4001efb737e..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.mod/swap.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// weak_ptr - -// void swap(weak_ptr& r); - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - A* ptr1 = new A; - A* ptr2 = new A; - std::shared_ptr<A> p1(ptr1); - std::weak_ptr<A> w1(p1); - { - std::shared_ptr<A> p2(ptr2); - std::weak_ptr<A> w2(p2); - w1.swap(w2); - assert(w1.use_count() == 1); - assert(w1.lock().get() == ptr2); - assert(w2.use_count() == 1); - assert(w2.lock().get() == ptr1); - assert(A::count == 2); - } - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cpp deleted file mode 100644 index d61ac51afc6..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/expired.pass.cpp +++ /dev/null @@ -1,46 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// weak_ptr - -// bool expired() const; - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::weak_ptr<A> wp; - assert(wp.use_count() == 0); - assert(wp.expired() == (wp.use_count() == 0)); - } - { - std::shared_ptr<A> sp0(new A); - std::weak_ptr<A> wp(sp0); - assert(wp.use_count() == 1); - assert(wp.expired() == (wp.use_count() == 0)); - sp0.reset(); - assert(wp.use_count() == 0); - assert(wp.expired() == (wp.use_count() == 0)); - } -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/lock.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/lock.pass.cpp deleted file mode 100644 index 956884b5c5c..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/lock.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// weak_ptr - -// shared_ptr<T> lock() const; - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - std::weak_ptr<A> wp; - std::shared_ptr<A> sp = wp.lock(); - assert(sp.use_count() == 0); - assert(sp.get() == 0); - assert(A::count == 0); - } - { - std::shared_ptr<A> sp0(new A); - std::weak_ptr<A> wp(sp0); - std::shared_ptr<A> sp = wp.lock(); - assert(sp.use_count() == 2); - assert(sp.get() == sp0.get()); - assert(A::count == 1); - } - assert(A::count == 0); - { - std::shared_ptr<A> sp0(new A); - std::weak_ptr<A> wp(sp0); - sp0.reset(); - std::shared_ptr<A> sp = wp.lock(); - assert(sp.use_count() == 0); - assert(sp.get() == 0); - assert(A::count == 0); - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.fail.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.fail.cpp deleted file mode 100644 index ccffc2a66fb..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/not_less_than.fail.cpp +++ /dev/null @@ -1,27 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// template <class T> class weak_ptr; -// -// not less than comparable - -#include <memory> -#include <cassert> - -int main() -{ - const std::shared_ptr<int> p1(new int); - const std::shared_ptr<int> p2(new int); - const std::weak_ptr<int> w1(p1); - const std::weak_ptr<int> w2(p2); - - bool b = w1 < w2; -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp deleted file mode 100644 index 4aa49cfe8a2..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_shared_ptr.pass.cpp +++ /dev/null @@ -1,31 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// weak_ptr - -// template<class U> bool owner_before(const shared_ptr<U>& b); - -#include <memory> -#include <cassert> - -int main() -{ - const std::shared_ptr<int> p1(new int); - const std::shared_ptr<int> p2 = p1; - const std::shared_ptr<int> p3(new int); - const std::weak_ptr<int> w1(p1); - const std::weak_ptr<int> w2(p2); - const std::weak_ptr<int> w3(p3); - assert(!w1.owner_before(p2)); - assert(!w2.owner_before(p1)); - assert(w1.owner_before(p3) || w3.owner_before(p1)); - assert(w3.owner_before(p1) == w3.owner_before(p2)); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp deleted file mode 100644 index 9fe2b6e3903..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.obs/owner_before_weak_ptr.pass.cpp +++ /dev/null @@ -1,31 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// weak_ptr - -// template<class U> bool owner_before(const weak_ptr<U>& b); - -#include <memory> -#include <cassert> - -int main() -{ - const std::shared_ptr<int> p1(new int); - const std::shared_ptr<int> p2 = p1; - const std::shared_ptr<int> p3(new int); - const std::weak_ptr<int> w1(p1); - const std::weak_ptr<int> w2(p2); - const std::weak_ptr<int> w3(p3); - assert(!w1.owner_before(w2)); - assert(!w2.owner_before(w1)); - assert(w1.owner_before(w3) || w3.owner_before(w1)); - assert(w3.owner_before(w1) == w3.owner_before(w2)); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/swap.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/swap.pass.cpp deleted file mode 100644 index e13d5aeaf63..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weak/util.smartptr.weak.spec/swap.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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// weak_ptr - -// template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b) - -#include <memory> -#include <cassert> - -struct A -{ - static int count; - - A() {++count;} - A(const A&) {++count;} - ~A() {--count;} -}; - -int A::count = 0; - -int main() -{ - { - A* ptr1 = new A; - A* ptr2 = new A; - std::shared_ptr<A> p1(ptr1); - std::weak_ptr<A> w1(p1); - { - std::shared_ptr<A> p2(ptr2); - std::weak_ptr<A> w2(p2); - swap(w1, w2); - assert(w1.use_count() == 1); - assert(w1.lock().get() == ptr2); - assert(w2.use_count() == 1); - assert(w2.lock().get() == ptr1); - assert(A::count == 2); - } - } - assert(A::count == 0); -} diff --git a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weakptr/bad_weak_ptr.pass.cpp b/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weakptr/bad_weak_ptr.pass.cpp deleted file mode 100644 index cb895cd2bbf..00000000000 --- a/libcxx/test/utilities/memory/util.smartptr/util.smartptr.weakptr/bad_weak_ptr.pass.cpp +++ /dev/null @@ -1,31 +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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -// class bad_weak_ptr -// : public std::exception -// { -// public: -// bad_weak_ptr(); -// }; - -#include <memory> -#include <type_traits> -#include <cassert> -#include <cstring> - -int main() -{ - static_assert((std::is_base_of<std::exception, std::bad_weak_ptr>::value), ""); - std::bad_weak_ptr e; - std::bad_weak_ptr e2 = e; - e2 = e; - assert(std::strcmp(e.what(), "bad_weak_ptr") == 0); -} diff --git a/libcxx/test/utilities/memory/version.pass.cpp b/libcxx/test/utilities/memory/version.pass.cpp deleted file mode 100644 index 790c08a3bd2..00000000000 --- a/libcxx/test/utilities/memory/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. -// -//===----------------------------------------------------------------------===// - -// <memory> - -#include <memory> - -#ifndef _LIBCPP_VERSION -#error _LIBCPP_VERSION not defined -#endif - -int main() -{ -} |

