summaryrefslogtreecommitdiffstats
path: root/libcxx/test/utilities/memory/allocator.traits
diff options
context:
space:
mode:
Diffstat (limited to 'libcxx/test/utilities/memory/allocator.traits')
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/allocate.pass.cpp39
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/allocate_hint.pass.cpp61
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/construct.pass.cpp144
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/deallocate.pass.cpp43
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/destroy.pass.cpp81
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/max_size.pass.cpp65
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/allocator.traits.members/select_on_container_copy_construction.pass.cpp69
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/const_pointer.pass.cpp56
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/const_void_pointer.pass.cpp56
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/difference_type.pass.cpp41
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/pointer.pass.cpp43
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_copy_assignment.pass.cpp41
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_move_assignment.pass.cpp41
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/propagate_on_container_swap.pass.cpp41
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/rebind_alloc.pass.cpp80
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/size_type.pass.cpp40
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/allocator.traits.types/void_pointer.pass.cpp56
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/allocator_type.pass.cpp32
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/rebind_traits.pass.cpp80
-rw-r--r--libcxx/test/utilities/memory/allocator.traits/value_type.pass.cpp32
20 files changed, 1121 insertions, 20 deletions
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
index c797b1020bc..ebbfa15d7c5 100644
--- 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
@@ -1 +1,38 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. 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); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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
index 9847c2a6053..527f51b1e59 100644
--- 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
@@ -1 +1,60 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. 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 B<int> b; assert(std::allocator_traits<B<int> >::allocate(b, 11, nullptr) == (int*)0xFEADBEEF); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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
index 4dda58f8c7a..e2d510e1ef5 100644
--- 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
@@ -1 +1,143 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. 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 }; 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 } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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
index b4bd79a96e3..33ea63cc164 100644
--- 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
@@ -1 +1,42 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. 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); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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
index 7996ea42033..d9e8de55e2a 100644
--- 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
@@ -1 +1,80 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. 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 } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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
index c021ea8c108..1a03f735762 100644
--- 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
@@ -1 +1,64 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <memory> // template <class Alloc> // struct allocator_traits // { // static size_type max_size(const allocator_type& a); // ... // }; #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 { 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); } } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// static size_type max_size(const allocator_type& a);
+// ...
+// };
+
+#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);
+ }
+}
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
index 8fe2365bc10..358017bc520 100644
--- 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
@@ -1 +1,68 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. 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 } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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
index 680583ac3a8..5573fcbfb1b 100644
--- 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
@@ -1 +1,55 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. 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), ""); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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
index afa0cf29d1e..2c881016a3b 100644
--- 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
@@ -1 +1,55 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. 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), ""); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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
index 7eab2fc5af5..460f47804c0 100644
--- 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
@@ -1 +1,40 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <memory> // template <class Alloc> // struct allocator_traits // { // typedef Alloc::difference_type // | ptrdiff_t 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; }; 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), ""); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. See LICENSE.TXT for details.
+//
+//===----------------------------------------------------------------------===//
+
+// <memory>
+
+// template <class Alloc>
+// struct allocator_traits
+// {
+// typedef Alloc::difference_type
+// | ptrdiff_t 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;
+};
+
+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), "");
+}
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
index 6b479cee2a7..a41eabf82ed 100644
--- 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
@@ -1 +1,42 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. 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), ""); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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
index 8340b582373..0e9a64c148e 100644
--- 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
@@ -1 +1,40 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. 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), ""); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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
index 827201625cd..d389f17e790 100644
--- 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
@@ -1 +1,40 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. 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), ""); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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
index 7c4d36afe0a..193dedde825 100644
--- 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
@@ -1 +1,40 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. 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), ""); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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
index 443ce269725..82fcb71f153 100644
--- 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
@@ -1 +1,79 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. 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 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 } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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
index 2eef5d435c7..148daacb547 100644
--- 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
@@ -1 +1,39 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. 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; }; 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::size_t>::value), ""); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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;
+};
+
+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::size_t>::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
index e08dd388b4f..f5ed6a398dd 100644
--- 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
@@ -1 +1,55 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. 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), ""); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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
index df2539a3a33..3df8b01ff92 100644
--- a/libcxx/test/utilities/memory/allocator.traits/allocator_type.pass.cpp
+++ b/libcxx/test/utilities/memory/allocator.traits/allocator_type.pass.cpp
@@ -1 +1,31 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. 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), ""); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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
index 6a4dd13df80..8e99e7f923b 100644
--- a/libcxx/test/utilities/memory/allocator.traits/rebind_traits.pass.cpp
+++ b/libcxx/test/utilities/memory/allocator.traits/rebind_traits.pass.cpp
@@ -1 +1,79 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. 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 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 } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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
index 20015088451..b91467faf3b 100644
--- a/libcxx/test/utilities/memory/allocator.traits/value_type.pass.cpp
+++ b/libcxx/test/utilities/memory/allocator.traits/value_type.pass.cpp
@@ -1 +1,31 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. 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), ""); } \ No newline at end of file
+//===----------------------------------------------------------------------===//
+//
+// The LLVM Compiler Infrastructure
+//
+// This file is distributed under the University of Illinois Open Source
+// License. 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