diff options
author | Eric Fiselier <eric@efcs.ca> | 2016-04-18 02:31:05 +0000 |
---|---|---|
committer | Eric Fiselier <eric@efcs.ca> | 2016-04-18 02:31:05 +0000 |
commit | 40fde4d33ebda7788f2e96a49d14d0fe117e9ab5 (patch) | |
tree | 1f1c07cd2349efbd0ba720cf26612b2f431547d1 /libcxx/test/std/utilities/memory/allocator.traits | |
parent | 7a9f500fcb8de2ec6cd88f3447db78ac6294f95f (diff) | |
download | bcm5719-llvm-40fde4d33ebda7788f2e96a49d14d0fe117e9ab5.tar.gz bcm5719-llvm-40fde4d33ebda7788f2e96a49d14d0fe117e9ab5.zip |
Add tests for LWG issue 2361
llvm-svn: 266586
Diffstat (limited to 'libcxx/test/std/utilities/memory/allocator.traits')
10 files changed, 145 insertions, 3 deletions
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 index 20348d20c10..10fbfe141ae 100644 --- 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 @@ -20,6 +20,8 @@ #include <memory> #include <type_traits> +#include "test_macros.h" + template <class T> struct Ptr {}; @@ -47,9 +49,19 @@ struct C typedef CPtr<const T> const_pointer; }; +template <class T> +struct D { + typedef T value_type; +private: + typedef void 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), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same<std::allocator_traits<D<char> >::const_pointer, const char*>::value), ""); +#endif } 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 index 4b4045a51ba..8365d22613e 100644 --- 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 @@ -21,6 +21,8 @@ #include <memory> #include <type_traits> +#include "test_macros.h" + template <class T> struct Ptr {}; @@ -47,9 +49,21 @@ struct C typedef CPtr<const void> const_void_pointer; }; + +template <class T> +struct D +{ + typedef T value_type; +private: + typedef int 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), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same<std::allocator_traits<D<char> >::const_void_pointer, const void*>::value), ""); +#endif } 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 index 085c911b070..dc7a65e52b3 100644 --- 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 @@ -20,6 +20,8 @@ #include <memory> #include <type_traits> +#include "test_macros.h" + template <class T> struct A { @@ -43,6 +45,15 @@ struct C struct const_void_pointer {}; }; + +template <class T> +struct D +{ + typedef T value_type; +private: + typedef void difference_type; +}; + namespace std { @@ -59,4 +70,7 @@ 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), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same<std::allocator_traits<D<char> >::difference_type, std::ptrdiff_t>::value), ""); +#endif } 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 index 60ba0949934..ff1ae2c051b 100644 --- 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 @@ -19,6 +19,8 @@ #include <memory> #include <type_traits> +#include "test_macros.h" + template <class T> struct Ptr {}; @@ -35,8 +37,18 @@ struct B typedef T value_type; }; +template <class T> +struct C { + typedef T value_type; +private: + typedef void pointer; +}; + 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), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same<std::allocator_traits<C<char> >::pointer, char*>::value), ""); +#endif } 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 index 604e890efaa..0112ab371a8 100644 --- 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 @@ -20,6 +20,8 @@ #include <memory> #include <type_traits> +#include "test_macros.h" + template <class T> struct A { @@ -33,8 +35,20 @@ struct B typedef T value_type; }; + +template <class T> +struct C +{ + typedef T value_type; +private: + typedef std::true_type propagate_on_container_copy_assignment; +}; + 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), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same<std::allocator_traits<C<char> >::propagate_on_container_copy_assignment, std::false_type>::value), ""); +#endif } 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 index 1d2b18686d0..64de15c2cd4 100644 --- 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 @@ -20,6 +20,8 @@ #include <memory> #include <type_traits> +#include "test_macros.h" + template <class T> struct A { @@ -33,8 +35,21 @@ struct B typedef T value_type; }; + +template <class T> +struct C +{ + typedef T value_type; +private: + typedef std::true_type propagate_on_container_move_assignment; +}; + + 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), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same<std::allocator_traits<C<char> >::propagate_on_container_move_assignment, std::false_type>::value), ""); +#endif } 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 index 6730d1ae261..a62336fa6cb 100644 --- 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 @@ -20,6 +20,8 @@ #include <memory> #include <type_traits> +#include "test_macros.h" + template <class T> struct A { @@ -33,8 +35,19 @@ struct B typedef T value_type; }; +template <class T> +struct C +{ + typedef T value_type; +private: + typedef std::true_type propagate_on_container_swap; +}; + 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), ""); + #if TEST_STD_VER >= 11 + static_assert((std::is_same<std::allocator_traits<C<char> >::propagate_on_container_swap, std::false_type>::value), ""); +#endif } 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 index 50611b99da9..8097a66fc9d 100644 --- 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 @@ -19,6 +19,8 @@ #include <memory> #include <type_traits> +#include "test_macros.h" + template <class T> struct ReboundA {}; @@ -61,19 +63,39 @@ struct E template <class U> struct rebind {typedef ReboundA<U> otter;}; }; +template <class T> +struct F { + typedef T value_type; +private: + template <class> + struct rebind { typedef void other; }; +}; + +template <class T> +struct G { + typedef T value_type; + template <class> + struct rebind { + private: + typedef void other; + }; +}; + int main() { -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#if TEST_STD_VER >= 11 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<F<char> >::rebind_alloc<double>, F<double> >::value), ""); + static_assert((std::is_same<std::allocator_traits<G<char> >::rebind_alloc<double>, G<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 // _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#endif } 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 index e9c175fe86a..00ed50727c9 100644 --- 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 @@ -19,6 +19,8 @@ #include <memory> #include <type_traits> +#include "test_macros.h" + template <class T> struct A { @@ -42,6 +44,14 @@ struct C struct const_void_pointer {}; }; +template <class T> +struct D { + typedef T value_type; + typedef short difference_type; +private: + typedef void size_type; +}; + namespace std { @@ -60,4 +70,7 @@ int main() std::make_unsigned<std::ptrdiff_t>::type>::value), ""); static_assert((std::is_same<std::allocator_traits<C<char> >::size_type, unsigned char>::value), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same<std::allocator_traits<D<char> >::size_type, unsigned short>::value), ""); +#endif } 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 index 74cd3475f66..2c3623793db 100644 --- 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 @@ -20,6 +20,7 @@ #include <memory> #include <type_traits> +#include "test_macros.h" template <class T> struct Ptr {}; @@ -47,9 +48,21 @@ struct C typedef CPtr<void> void_pointer; }; + +template <class T> +struct D +{ + typedef T value_type; +private: + typedef 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), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same<std::allocator_traits<D<char> >::void_pointer, void*>::value), ""); +#endif } |