summaryrefslogtreecommitdiffstats
path: root/libcxx/test/utilities/memory/pointer.traits
diff options
context:
space:
mode:
authorHoward Hinnant <hhinnant@apple.com>2010-08-22 00:59:46 +0000
committerHoward Hinnant <hhinnant@apple.com>2010-08-22 00:59:46 +0000
commit94b2dd0998230c758abd92c99d3700c971f7a31a (patch)
tree1b9f66ba0b4f8fd99fc02a112d4b7a30c4afe0f6 /libcxx/test/utilities/memory/pointer.traits
parentd9c6c0b583ac1f1efeec3db571a1028a3c9b7a99 (diff)
downloadbcm5719-llvm-94b2dd0998230c758abd92c99d3700c971f7a31a.tar.gz
bcm5719-llvm-94b2dd0998230c758abd92c99d3700c971f7a31a.zip
Fixing whitespace problems
llvm-svn: 111767
Diffstat (limited to 'libcxx/test/utilities/memory/pointer.traits')
-rw-r--r--libcxx/test/utilities/memory/pointer.traits/difference_type.pass.cpp26
-rw-r--r--libcxx/test/utilities/memory/pointer.traits/element_type.pass.cpp26
-rw-r--r--libcxx/test/utilities/memory/pointer.traits/pointer.pass.cpp33
-rw-r--r--libcxx/test/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp49
-rw-r--r--libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp49
-rw-r--r--libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp50
-rw-r--r--libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp70
-rw-r--r--libcxx/test/utilities/memory/pointer.traits/pointer_to.pass.cpp33
-rw-r--r--libcxx/test/utilities/memory/pointer.traits/rebind.pass.cpp30
9 files changed, 357 insertions, 9 deletions
diff --git a/libcxx/test/utilities/memory/pointer.traits/difference_type.pass.cpp b/libcxx/test/utilities/memory/pointer.traits/difference_type.pass.cpp
index f28e42f28bd..820b75f6439 100644
--- a/libcxx/test/utilities/memory/pointer.traits/difference_type.pass.cpp
+++ b/libcxx/test/utilities/memory/pointer.traits/difference_type.pass.cpp
@@ -1 +1,25 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <memory> // template <class T> // struct pointer_traits<T*> // { // typedef ptrdiff_t difference_type; // ... // }; #include <memory> #include <type_traits> int main() { static_assert((std::is_same<std::pointer_traits<double*>::difference_type, std::ptrdiff_t>::value), ""); } \ 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 T>
+// struct pointer_traits<T*>
+// {
+// typedef ptrdiff_t difference_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::pointer_traits<double*>::difference_type, std::ptrdiff_t>::value), "");
+}
diff --git a/libcxx/test/utilities/memory/pointer.traits/element_type.pass.cpp b/libcxx/test/utilities/memory/pointer.traits/element_type.pass.cpp
index e944dc8ff35..cf1ddd865c3 100644
--- a/libcxx/test/utilities/memory/pointer.traits/element_type.pass.cpp
+++ b/libcxx/test/utilities/memory/pointer.traits/element_type.pass.cpp
@@ -1 +1,25 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <memory> // template <class T> // struct pointer_traits<T*> // { // typedef T element_type; // ... // }; #include <memory> #include <type_traits> int main() { static_assert((std::is_same<std::pointer_traits<const short*>::element_type, const short>::value), ""); } \ 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 T>
+// struct pointer_traits<T*>
+// {
+// typedef T element_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+int main()
+{
+ static_assert((std::is_same<std::pointer_traits<const short*>::element_type, const short>::value), "");
+}
diff --git a/libcxx/test/utilities/memory/pointer.traits/pointer.pass.cpp b/libcxx/test/utilities/memory/pointer.traits/pointer.pass.cpp
index 34fa69454ab..13d15b53d8d 100644
--- a/libcxx/test/utilities/memory/pointer.traits/pointer.pass.cpp
+++ b/libcxx/test/utilities/memory/pointer.traits/pointer.pass.cpp
@@ -1 +1,32 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <memory> // template <class Ptr> // struct pointer_traits // { // typedef Ptr pointer; // ... // }; #include <memory> #include <type_traits> struct A { typedef short element_type; typedef char difference_type; }; int main() { static_assert((std::is_same<std::pointer_traits<A>::pointer, A>::value), ""); static_assert((std::is_same<std::pointer_traits<int*>::pointer, int*>::value), ""); } \ 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 Ptr>
+// struct pointer_traits
+// {
+// typedef Ptr pointer;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+struct A
+{
+ typedef short element_type;
+ typedef char difference_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::pointer_traits<A>::pointer, A>::value), "");
+ static_assert((std::is_same<std::pointer_traits<int*>::pointer, int*>::value), "");
+}
diff --git a/libcxx/test/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp b/libcxx/test/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp
index 8ed66297f31..10cdb897002 100644
--- a/libcxx/test/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp
+++ b/libcxx/test/utilities/memory/pointer.traits/pointer.traits.functions/pointer_to.pass.cpp
@@ -1 +1,48 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <memory> // template <class Ptr> // struct pointer_traits // { // static pointer pointer_to(<details>); // ... // }; #include <memory> #include <cassert> template <class T> struct A { private: struct nat {}; public: typedef T element_type; element_type* t_; A(element_type* t) : t_(t) {} static A pointer_to(typename std::conditional<std::is_void<element_type>::value, nat, element_type>::type& et) {return A(&et);} }; int main() { { int i = 0; A<int> a = std::pointer_traits<A<int> >::pointer_to(i); assert(a.t_ = &i); } { (std::pointer_traits<A<void> >::element_type)0; } } \ 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 Ptr>
+// struct pointer_traits
+// {
+// static pointer pointer_to(<details>);
+// ...
+// };
+
+#include <memory>
+#include <cassert>
+
+template <class T>
+struct A
+{
+private:
+ struct nat {};
+public:
+ typedef T element_type;
+ element_type* t_;
+
+ A(element_type* t) : t_(t) {}
+
+ static A pointer_to(typename std::conditional<std::is_void<element_type>::value,
+ nat, element_type>::type& et)
+ {return A(&et);}
+};
+
+int main()
+{
+ {
+ int i = 0;
+ A<int> a = std::pointer_traits<A<int> >::pointer_to(i);
+ assert(a.t_ = &i);
+ }
+ {
+ (std::pointer_traits<A<void> >::element_type)0;
+ }
+}
diff --git a/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp b/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp
index e2a78d1ddfa..49439dd3701 100644
--- a/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp
+++ b/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp
@@ -1 +1,48 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <memory> // template <class Ptr> // struct pointer_traits // { // typedef <details> difference_type; // ... // }; #include <memory> #include <type_traits> struct A { typedef short element_type; typedef char difference_type; }; struct B { typedef short element_type; }; template <class T> struct C {}; template <class T> struct D { typedef char difference_type; }; int main() { static_assert((std::is_same<std::pointer_traits<A>::difference_type, char>::value), ""); static_assert((std::is_same<std::pointer_traits<B>::difference_type, std::ptrdiff_t>::value), ""); static_assert((std::is_same<std::pointer_traits<C<double> >::difference_type, std::ptrdiff_t>::value), ""); static_assert((std::is_same<std::pointer_traits<D<int> >::difference_type, char>::value), ""); } \ 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 Ptr>
+// struct pointer_traits
+// {
+// typedef <details> difference_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+struct A
+{
+ typedef short element_type;
+ typedef char difference_type;
+};
+
+struct B
+{
+ typedef short element_type;
+};
+
+template <class T>
+struct C {};
+
+template <class T>
+struct D
+{
+ typedef char difference_type;
+};
+
+int main()
+{
+ static_assert((std::is_same<std::pointer_traits<A>::difference_type, char>::value), "");
+ static_assert((std::is_same<std::pointer_traits<B>::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<std::pointer_traits<C<double> >::difference_type, std::ptrdiff_t>::value), "");
+ static_assert((std::is_same<std::pointer_traits<D<int> >::difference_type, char>::value), "");
+}
diff --git a/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp b/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp
index ca464370c6e..eb48fa26de4 100644
--- a/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp
+++ b/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp
@@ -1 +1,49 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <memory> // template <class Ptr> // struct pointer_traits // { // typedef <details> element_type; // ... // }; #include <memory> #include <type_traits> struct A { typedef char element_type; }; template <class T> struct B { typedef char element_type; }; template <class T> struct C { }; template <class T, class U> struct D { }; int main() { static_assert((std::is_same<std::pointer_traits<A>::element_type, char>::value), ""); static_assert((std::is_same<std::pointer_traits<B<int> >::element_type, char>::value), ""); static_assert((std::is_same<std::pointer_traits<C<int> >::element_type, int>::value), ""); static_assert((std::is_same<std::pointer_traits<D<double, int> >::element_type, double>::value), ""); } \ 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 Ptr>
+// struct pointer_traits
+// {
+// typedef <details> element_type;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+struct A
+{
+ typedef char element_type;
+};
+
+template <class T>
+struct B
+{
+ typedef char element_type;
+};
+
+template <class T>
+struct C
+{
+};
+
+template <class T, class U>
+struct D
+{
+};
+
+int main()
+{
+ static_assert((std::is_same<std::pointer_traits<A>::element_type, char>::value), "");
+ static_assert((std::is_same<std::pointer_traits<B<int> >::element_type, char>::value), "");
+ static_assert((std::is_same<std::pointer_traits<C<int> >::element_type, int>::value), "");
+ static_assert((std::is_same<std::pointer_traits<D<double, int> >::element_type, double>::value), "");
+}
diff --git a/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp b/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp
index ca8a3a27629..4095754c255 100644
--- a/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp
+++ b/libcxx/test/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp
@@ -1 +1,69 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <memory> // template <class Ptr> // struct pointer_traits // { // template <class U> using rebind = <details>; // ... // }; #include <memory> #include <type_traits> template <class T> struct A { }; template <class T> struct B1 {}; template <class T> struct B { #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES template <class U> using rebind = B1<U>; #else template <class U> struct rebind {typedef B1<U> other;}; #endif }; template <class T, class U> struct C { }; template <class T, class U> struct D1 {}; template <class T, class U> struct D { #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES template <class V> using rebind = D1<V, U>; #else template <class V> struct rebind {typedef D1<V, U> other;}; #endif }; int main() { #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES static_assert((std::is_same<std::pointer_traits<A<int*> >::rebind<double*>, A<double*> >::value), ""); static_assert((std::is_same<std::pointer_traits<B<int> >::rebind<double>, B1<double> >::value), ""); static_assert((std::is_same<std::pointer_traits<C<char, int> >::rebind<double>, C<double, int> >::value), ""); static_assert((std::is_same<std::pointer_traits<D<char, int> >::rebind<double>, D1<double, int> >::value), ""); #else static_assert((std::is_same<std::pointer_traits<A<int*> >::rebind<double*>::other, A<double*> >::value), ""); static_assert((std::is_same<std::pointer_traits<B<int> >::rebind<double>::other, B1<double> >::value), ""); static_assert((std::is_same<std::pointer_traits<C<char, int> >::rebind<double>::other, C<double, int> >::value), ""); static_assert((std::is_same<std::pointer_traits<D<char, int> >::rebind<double>::other, D1<double, int> >::value), ""); #endif } \ 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 Ptr>
+// struct pointer_traits
+// {
+// template <class U> using rebind = <details>;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+template <class T>
+struct A
+{
+};
+
+template <class T> struct B1 {};
+
+template <class T>
+struct B
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ template <class U> using rebind = B1<U>;
+#else
+ template <class U> struct rebind {typedef B1<U> other;};
+#endif
+};
+
+template <class T, class U>
+struct C
+{
+};
+
+template <class T, class U> struct D1 {};
+
+template <class T, class U>
+struct D
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ template <class V> using rebind = D1<V, U>;
+#else
+ template <class V> struct rebind {typedef D1<V, U> other;};
+#endif
+};
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ static_assert((std::is_same<std::pointer_traits<A<int*> >::rebind<double*>, A<double*> >::value), "");
+ static_assert((std::is_same<std::pointer_traits<B<int> >::rebind<double>, B1<double> >::value), "");
+ static_assert((std::is_same<std::pointer_traits<C<char, int> >::rebind<double>, C<double, int> >::value), "");
+ static_assert((std::is_same<std::pointer_traits<D<char, int> >::rebind<double>, D1<double, int> >::value), "");
+#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ static_assert((std::is_same<std::pointer_traits<A<int*> >::rebind<double*>::other, A<double*> >::value), "");
+ static_assert((std::is_same<std::pointer_traits<B<int> >::rebind<double>::other, B1<double> >::value), "");
+ static_assert((std::is_same<std::pointer_traits<C<char, int> >::rebind<double>::other, C<double, int> >::value), "");
+ static_assert((std::is_same<std::pointer_traits<D<char, int> >::rebind<double>::other, D1<double, int> >::value), "");
+#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+}
diff --git a/libcxx/test/utilities/memory/pointer.traits/pointer_to.pass.cpp b/libcxx/test/utilities/memory/pointer.traits/pointer_to.pass.cpp
index 42fd9300b7d..557bf36b976 100644
--- a/libcxx/test/utilities/memory/pointer.traits/pointer_to.pass.cpp
+++ b/libcxx/test/utilities/memory/pointer.traits/pointer_to.pass.cpp
@@ -1 +1,32 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <memory> // template <class T> // struct pointer_traits<T*> // { // static pointer pointer_to(<details>); // ... // }; #include <memory> #include <cassert> int main() { { int i = 0; int* a = std::pointer_traits<int*>::pointer_to(i); assert(a = &i); } { (std::pointer_traits<void*>::element_type)0; } } \ 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 T>
+// struct pointer_traits<T*>
+// {
+// static pointer pointer_to(<details>);
+// ...
+// };
+
+#include <memory>
+#include <cassert>
+
+int main()
+{
+ {
+ int i = 0;
+ int* a = std::pointer_traits<int*>::pointer_to(i);
+ assert(a = &i);
+ }
+ {
+ (std::pointer_traits<void*>::element_type)0;
+ }
+}
diff --git a/libcxx/test/utilities/memory/pointer.traits/rebind.pass.cpp b/libcxx/test/utilities/memory/pointer.traits/rebind.pass.cpp
index f63c03521a0..d3a4d794f90 100644
--- a/libcxx/test/utilities/memory/pointer.traits/rebind.pass.cpp
+++ b/libcxx/test/utilities/memory/pointer.traits/rebind.pass.cpp
@@ -1 +1,29 @@
-//===----------------------------------------------------------------------===// // // The LLVM Compiler Infrastructure // // This file is distributed under the University of Illinois Open Source // License. See LICENSE.TXT for details. // //===----------------------------------------------------------------------===// // <memory> // template <class T> // struct pointer_traits<T*> // { // template <class U> using rebind = U*; // ... // }; #include <memory> #include <type_traits> int main() { #ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES static_assert((std::is_same<std::pointer_traits<int*>::rebind<double>, double*>::value), ""); #else static_assert((std::is_same<std::pointer_traits<int*>::rebind<double>::other, double*>::value), ""); #endif } \ 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 T>
+// struct pointer_traits<T*>
+// {
+// template <class U> using rebind = U*;
+// ...
+// };
+
+#include <memory>
+#include <type_traits>
+
+int main()
+{
+#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
+ static_assert((std::is_same<std::pointer_traits<int*>::rebind<double>, double*>::value), "");
+#else
+ static_assert((std::is_same<std::pointer_traits<int*>::rebind<double>::other, double*>::value), "");
+#endif
+}
OpenPOWER on IntegriCloud