summaryrefslogtreecommitdiffstats
path: root/libcxx/test/std/utilities/memory/allocator.traits
diff options
context:
space:
mode:
authorEric Fiselier <eric@efcs.ca>2014-12-20 01:40:03 +0000
committerEric Fiselier <eric@efcs.ca>2014-12-20 01:40:03 +0000
commit5a83710e371fe68a06e6e3876c6a2c8b820a8976 (patch)
treeafde4c82ad6704681781c5cd49baa3fbd05c85db /libcxx/test/std/utilities/memory/allocator.traits
parentf11e8eab527fba316c64112f6e05de1a79693a3e (diff)
downloadbcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.tar.gz
bcm5719-llvm-5a83710e371fe68a06e6e3876c6a2c8b820a8976.zip
Move test into test/std subdirectory.
llvm-svn: 224658
Diffstat (limited to 'libcxx/test/std/utilities/memory/allocator.traits')
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp38
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp60
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp143
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp42
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp80
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp70
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp68
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp55
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp55
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp62
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp42
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp40
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp40
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp40
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp79
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp63
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp55
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/allocator_type.pass.cpp31
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp79
-rw-r--r--libcxx/test/std/utilities/memory/allocator.traits/value_type.pass.cpp31
20 files changed, 1173 insertions, 0 deletions
diff --git a/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp
new file mode 100644
index 00000000000..490fdf5d332
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp
@@ -0,0 +1,38 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp
new file mode 100644
index 00000000000..079db3526ac
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp
@@ -0,0 +1,60 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM 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/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp
new file mode 100644
index 00000000000..634019758e7
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp
@@ -0,0 +1,143 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM 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/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp
new file mode 100644
index 00000000000..b137dc6d36c
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM 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/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
new file mode 100644
index 00000000000..54726c929ef
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp
@@ -0,0 +1,80 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM 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/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp
new file mode 100644
index 00000000000..1fa7291203e
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp
@@ -0,0 +1,70 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM 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/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp
new file mode 100644
index 00000000000..29fe2be126f
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp
@@ -0,0 +1,68 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM 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/std/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp
new file mode 100644
index 00000000000..20348d20c10
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM 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/std/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp
new file mode 100644
index 00000000000..4b4045a51ba
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM 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/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp
new file mode 100644
index 00000000000..085c911b070
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp
@@ -0,0 +1,62 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM 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/std/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp
new file mode 100644
index 00000000000..60ba0949934
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp
@@ -0,0 +1,42 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM 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/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp
new file mode 100644
index 00000000000..604e890efaa
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM 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/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp
new file mode 100644
index 00000000000..1d2b18686d0
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM 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/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp
new file mode 100644
index 00000000000..6730d1ae261
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp
@@ -0,0 +1,40 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM 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/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp
new file mode 100644
index 00000000000..50611b99da9
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM 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/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp
new file mode 100644
index 00000000000..e9c175fe86a
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp
@@ -0,0 +1,63 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM 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/std/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp
new file mode 100644
index 00000000000..74cd3475f66
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp
@@ -0,0 +1,55 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM 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/std/utilities/memory/allocator.traits/allocator_type.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/allocator_type.pass.cpp
new file mode 100644
index 00000000000..fe35ae48757
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/allocator_type.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp
new file mode 100644
index 00000000000..87da9a0a85d
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/rebind_traits.pass.cpp
@@ -0,0 +1,79 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM 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/std/utilities/memory/allocator.traits/value_type.pass.cpp b/libcxx/test/std/utilities/memory/allocator.traits/value_type.pass.cpp
new file mode 100644
index 00000000000..d0c3d2c09a1
--- /dev/null
+++ b/libcxx/test/std/utilities/memory/allocator.traits/value_type.pass.cpp
@@ -0,0 +1,31 @@
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is dual licensed under the MIT and the University of Illinois Open
+// Source Licenses. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <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), "");
+}
OpenPOWER on IntegriCloud