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/pointer.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/pointer.traits')
3 files changed, 76 insertions, 5 deletions
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 <memory> #include <type_traits> +#include "test_macros.h" + struct A { typedef short element_type; @@ -39,10 +41,26 @@ struct D typedef char difference_type; }; +template <class T> +struct E +{ + static int difference_type; +}; + +template <class T> +struct F { +private: + typedef int 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), ""); + static_assert((std::is_same<std::pointer_traits<E<int> >::difference_type, std::ptrdiff_t>::value), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same<std::pointer_traits<F<int>>::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 <class T, class U> +struct E +{ + static int element_type; +}; + +template <class T> +struct F { +private: + typedef int element_type; +}; + 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), ""); + static_assert((std::is_same<std::pointer_traits<E<double, int> >::element_type, double>::value), ""); +#if TEST_STD_VER >= 11 + static_assert((std::is_same<std::pointer_traits<F<double>>::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 <memory> #include <type_traits> +#include "test_macros.h" + template <class T> struct A { @@ -29,7 +31,7 @@ template <class T> struct B1 {}; template <class T> struct B { -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#if TEST_STD_VER >= 11 template <class U> using rebind = B1<U>; #else template <class U> struct rebind {typedef B1<U> other;}; @@ -46,24 +48,58 @@ template <class T, class U> struct D1 {}; template <class T, class U> struct D { -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#if TEST_STD_VER >= 11 template <class V> using rebind = D1<V, U>; #else template <class V> struct rebind {typedef D1<V, U> other;}; #endif }; +template <class T, class U> +struct E +{ + template <class> + void rebind() {} +}; + + +#if TEST_STD_VER >= 11 +template <class T, class U> +struct F { +private: + template <class> + using rebind = void; +}; +#endif + +#if TEST_STD_VER >= 14 +template <class T, class U> +struct G +{ + template <class> + static constexpr int rebind = 42; +}; +#endif + + int main() { -#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES +#if TEST_STD_VER >= 11 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<E<char, int> >::rebind<double>, E<double, int> >::value), ""); + static_assert((std::is_same<std::pointer_traits<F<char, int> >::rebind<double>, F<double, int> >::value), ""); + +#if TEST_STD_VER >= 14 + static_assert((std::is_same<std::pointer_traits<G<char, int> >::rebind<double>, G<double, int> >::value), ""); +#endif +#else // TEST_STD_VER < 11 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 + static_assert((std::is_same<std::pointer_traits<E<char, int> >::rebind<double>::other, E<double, int> >::value), ""); +#endif } |