From 40fde4d33ebda7788f2e96a49d14d0fe117e9ab5 Mon Sep 17 00:00:00 2001 From: Eric Fiselier Date: Mon, 18 Apr 2016 02:31:05 +0000 Subject: Add tests for LWG issue 2361 llvm-svn: 266586 --- .../allocator.traits.types/const_pointer.pass.cpp | 12 ++++++ .../const_void_pointer.pass.cpp | 14 +++++++ .../difference_type.pass.cpp | 14 +++++++ .../allocator.traits.types/pointer.pass.cpp | 12 ++++++ ...propagate_on_container_copy_assignment.pass.cpp | 14 +++++++ ...propagate_on_container_move_assignment.pass.cpp | 15 +++++++ .../propagate_on_container_swap.pass.cpp | 13 ++++++ .../allocator.traits.types/rebind_alloc.pass.cpp | 28 +++++++++++-- .../allocator.traits.types/size_type.pass.cpp | 13 ++++++ .../allocator.traits.types/void_pointer.pass.cpp | 13 ++++++ .../allocator.uses.trait/uses_allocator.pass.cpp | 20 ++++++++++ .../pointer.traits.types/difference_type.pass.cpp | 18 +++++++++ .../pointer.traits.types/element_type.pass.cpp | 17 ++++++++ .../pointer.traits.types/rebind.pass.cpp | 46 +++++++++++++++++++--- .../unique.ptr.single/pointer_type.pass.cpp | 21 ++++++++++ 15 files changed, 262 insertions(+), 8 deletions(-) (limited to 'libcxx/test/std/utilities/memory') 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 #include +#include "test_macros.h" + template struct Ptr {}; @@ -47,9 +49,19 @@ struct C typedef CPtr const_pointer; }; +template +struct D { + typedef T value_type; +private: + typedef void const_pointer; +}; + int main() { static_assert((std::is_same >::const_pointer, Ptr >::value), ""); static_assert((std::is_same >::const_pointer, const char*>::value), ""); static_assert((std::is_same >::const_pointer, CPtr >::value), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same >::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 #include +#include "test_macros.h" + template struct Ptr {}; @@ -47,9 +49,21 @@ struct C typedef CPtr const_void_pointer; }; + +template +struct D +{ + typedef T value_type; +private: + typedef int const_void_pointer; +}; + int main() { static_assert((std::is_same >::const_void_pointer, Ptr >::value), ""); static_assert((std::is_same >::const_void_pointer, const void*>::value), ""); static_assert((std::is_same >::const_void_pointer, CPtr >::value), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same >::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 #include +#include "test_macros.h" + template struct A { @@ -43,6 +45,15 @@ struct C struct const_void_pointer {}; }; + +template +struct D +{ + typedef T value_type; +private: + typedef void difference_type; +}; + namespace std { @@ -59,4 +70,7 @@ int main() static_assert((std::is_same >::difference_type, short>::value), ""); static_assert((std::is_same >::difference_type, std::ptrdiff_t>::value), ""); static_assert((std::is_same >::difference_type, signed char>::value), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same >::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 #include +#include "test_macros.h" + template struct Ptr {}; @@ -35,8 +37,18 @@ struct B typedef T value_type; }; +template +struct C { + typedef T value_type; +private: + typedef void pointer; +}; + int main() { static_assert((std::is_same >::pointer, Ptr >::value), ""); static_assert((std::is_same >::pointer, char*>::value), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same >::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 #include +#include "test_macros.h" + template struct A { @@ -33,8 +35,20 @@ struct B typedef T value_type; }; + +template +struct C +{ + typedef T value_type; +private: + typedef std::true_type propagate_on_container_copy_assignment; +}; + int main() { static_assert((std::is_same >::propagate_on_container_copy_assignment, std::true_type>::value), ""); static_assert((std::is_same >::propagate_on_container_copy_assignment, std::false_type>::value), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same >::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 #include +#include "test_macros.h" + template struct A { @@ -33,8 +35,21 @@ struct B typedef T value_type; }; + +template +struct C +{ + typedef T value_type; +private: + typedef std::true_type propagate_on_container_move_assignment; +}; + + int main() { static_assert((std::is_same >::propagate_on_container_move_assignment, std::true_type>::value), ""); static_assert((std::is_same >::propagate_on_container_move_assignment, std::false_type>::value), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same >::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 #include +#include "test_macros.h" + template struct A { @@ -33,8 +35,19 @@ struct B typedef T value_type; }; +template +struct C +{ + typedef T value_type; +private: + typedef std::true_type propagate_on_container_swap; +}; + int main() { static_assert((std::is_same >::propagate_on_container_swap, std::true_type>::value), ""); static_assert((std::is_same >::propagate_on_container_swap, std::false_type>::value), ""); + #if TEST_STD_VER >= 11 + static_assert((std::is_same >::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 #include +#include "test_macros.h" + template struct ReboundA {}; @@ -61,19 +63,39 @@ struct E template struct rebind {typedef ReboundA otter;}; }; +template +struct F { + typedef T value_type; +private: + template + struct rebind { typedef void other; }; +}; + +template +struct G { + typedef T value_type; + template + struct rebind { + private: + typedef void other; + }; +}; + int main() { -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#if TEST_STD_VER >= 11 static_assert((std::is_same >::rebind_alloc, ReboundA >::value), ""); static_assert((std::is_same >::rebind_alloc, ReboundB >::value), ""); static_assert((std::is_same >::rebind_alloc, C >::value), ""); static_assert((std::is_same >::rebind_alloc, D >::value), ""); static_assert((std::is_same >::rebind_alloc, E >::value), ""); -#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES + static_assert((std::is_same >::rebind_alloc, F >::value), ""); + static_assert((std::is_same >::rebind_alloc, G >::value), ""); +#else static_assert((std::is_same >::rebind_alloc::other, ReboundA >::value), ""); static_assert((std::is_same >::rebind_alloc::other, ReboundB >::value), ""); static_assert((std::is_same >::rebind_alloc::other, C >::value), ""); static_assert((std::is_same >::rebind_alloc::other, D >::value), ""); static_assert((std::is_same >::rebind_alloc::other, E >::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 #include +#include "test_macros.h" + template struct A { @@ -42,6 +44,14 @@ struct C struct const_void_pointer {}; }; +template +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::type>::value), ""); static_assert((std::is_same >::size_type, unsigned char>::value), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same >::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 #include +#include "test_macros.h" template struct Ptr {}; @@ -47,9 +48,21 @@ struct C typedef CPtr void_pointer; }; + +template +struct D +{ + typedef T value_type; +private: + typedef void void_pointer; +}; + int main() { static_assert((std::is_same >::void_pointer, Ptr >::value), ""); static_assert((std::is_same >::void_pointer, void*>::value), ""); static_assert((std::is_same >::void_pointer, CPtr >::value), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same >::void_pointer, void*>::value), ""); +#endif } diff --git a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp index 0477d9912e6..2fab34b90cf 100644 --- a/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp +++ b/libcxx/test/std/utilities/memory/allocator.uses/allocator.uses.trait/uses_allocator.pass.cpp @@ -14,6 +14,8 @@ #include #include +#include "test_macros.h" + struct A { }; @@ -23,6 +25,19 @@ struct B typedef int allocator_type; }; +struct C { + static int allocator_type; +}; + +struct D { + static int allocator_type() {} +}; + +struct E { +private: + typedef int allocator_type; +}; + int main() { static_assert((!std::uses_allocator >::value), ""); @@ -30,4 +45,9 @@ int main() static_assert((!std::uses_allocator >::value), ""); static_assert((!std::uses_allocator >::value), ""); static_assert(( std::uses_allocator::value), ""); + static_assert((!std::uses_allocator::value), ""); + static_assert((!std::uses_allocator::value), ""); +#if TEST_STD_VER >= 11 + static_assert((!std::uses_allocator::value), ""); +#endif } diff --git a/libcxx/test/std/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp b/libcxx/test/std/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp index 4efe6134242..27b2d08b006 100644 --- a/libcxx/test/std/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp +++ b/libcxx/test/std/utilities/memory/pointer.traits/pointer.traits.types/difference_type.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "test_macros.h" + struct A { typedef short element_type; @@ -39,10 +41,26 @@ struct D typedef char difference_type; }; +template +struct E +{ + static int difference_type; +}; + +template +struct F { +private: + typedef int difference_type; +}; + int main() { static_assert((std::is_same::difference_type, char>::value), ""); static_assert((std::is_same::difference_type, std::ptrdiff_t>::value), ""); static_assert((std::is_same >::difference_type, std::ptrdiff_t>::value), ""); static_assert((std::is_same >::difference_type, char>::value), ""); + static_assert((std::is_same >::difference_type, std::ptrdiff_t>::value), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same>::difference_type, std::ptrdiff_t>::value), ""); +#endif } diff --git a/libcxx/test/std/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp b/libcxx/test/std/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp index 0ee1e8c93a6..afa9f7f06dd 100644 --- a/libcxx/test/std/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp +++ b/libcxx/test/std/utilities/memory/pointer.traits/pointer.traits.types/element_type.pass.cpp @@ -40,10 +40,27 @@ struct D { }; +template +struct E +{ + static int element_type; +}; + +template +struct F { +private: + typedef int element_type; +}; + int main() { static_assert((std::is_same::element_type, char>::value), ""); static_assert((std::is_same >::element_type, char>::value), ""); static_assert((std::is_same >::element_type, int>::value), ""); static_assert((std::is_same >::element_type, double>::value), ""); + static_assert((std::is_same >::element_type, double>::value), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same>::element_type, double>::value), ""); +#endif + } diff --git a/libcxx/test/std/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp b/libcxx/test/std/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp index 4a1455c53ef..74c12490121 100644 --- a/libcxx/test/std/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp +++ b/libcxx/test/std/utilities/memory/pointer.traits/pointer.traits.types/rebind.pass.cpp @@ -19,6 +19,8 @@ #include #include +#include "test_macros.h" + template struct A { @@ -29,7 +31,7 @@ template struct B1 {}; template struct B { -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#if TEST_STD_VER >= 11 template using rebind = B1; #else template struct rebind {typedef B1 other;}; @@ -46,24 +48,58 @@ template struct D1 {}; template struct D { -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#if TEST_STD_VER >= 11 template using rebind = D1; #else template struct rebind {typedef D1 other;}; #endif }; +template +struct E +{ + template + void rebind() {} +}; + + +#if TEST_STD_VER >= 11 +template +struct F { +private: + template + using rebind = void; +}; +#endif + +#if TEST_STD_VER >= 14 +template +struct G +{ + template + static constexpr int rebind = 42; +}; +#endif + + int main() { -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#if TEST_STD_VER >= 11 static_assert((std::is_same >::rebind, A >::value), ""); static_assert((std::is_same >::rebind, B1 >::value), ""); static_assert((std::is_same >::rebind, C >::value), ""); static_assert((std::is_same >::rebind, D1 >::value), ""); -#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES + static_assert((std::is_same >::rebind, E >::value), ""); + static_assert((std::is_same >::rebind, F >::value), ""); + +#if TEST_STD_VER >= 14 + static_assert((std::is_same >::rebind, G >::value), ""); +#endif +#else // TEST_STD_VER < 11 static_assert((std::is_same >::rebind::other, A >::value), ""); static_assert((std::is_same >::rebind::other, B1 >::value), ""); static_assert((std::is_same >::rebind::other, C >::value), ""); static_assert((std::is_same >::rebind::other, D1 >::value), ""); -#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES + static_assert((std::is_same >::rebind::other, E >::value), ""); +#endif } diff --git a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp index 8721062c6d0..566b058b878 100644 --- a/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp +++ b/libcxx/test/std/utilities/memory/unique.ptr/unique.ptr.single/pointer_type.pass.cpp @@ -16,11 +16,22 @@ #include #include +#include "test_macros.h" + struct Deleter { struct pointer {}; }; +struct D2 { +private: + typedef void pointer; +}; + +struct D3 { + static long pointer; +}; + int main() { { @@ -31,4 +42,14 @@ int main() typedef std::unique_ptr P; static_assert((std::is_same::value), ""); } +#if TEST_STD_VER >= 11 + { + typedef std::unique_ptr P; + static_assert(std::is_same::value, ""); + + { + typedef std::unique_ptr P; + static_assert(std::is_same::value, ""); + }} +#endif } -- cgit v1.2.3