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 --- .../pointer.traits.types/difference_type.pass.cpp | 18 +++++++++ .../pointer.traits.types/element_type.pass.cpp | 17 ++++++++ .../pointer.traits.types/rebind.pass.cpp | 46 +++++++++++++++++++--- 3 files changed, 76 insertions(+), 5 deletions(-) (limited to 'libcxx/test/std/utilities/memory/pointer.traits') 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 } -- cgit v1.2.3