blob: 4a1455c53ef6fcc20a0016ce336ce80c4ac1cfea [file] [log] [blame]
Howard Hinnantc52f43e2010-08-22 00:59:46 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantc52f43e2010-08-22 00:59:46 +00007//
8//===----------------------------------------------------------------------===//
9
10// <memory>
11
12// template <class Ptr>
13// struct pointer_traits
14// {
15// template <class U> using rebind = <details>;
16// ...
17// };
18
19#include <memory>
20#include <type_traits>
21
22template <class T>
23struct A
24{
25};
26
27template <class T> struct B1 {};
28
29template <class T>
30struct B
31{
Dan Albert1d4a1ed2016-05-25 22:36:09 -070032#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
Howard Hinnantc52f43e2010-08-22 00:59:46 +000033 template <class U> using rebind = B1<U>;
34#else
35 template <class U> struct rebind {typedef B1<U> other;};
36#endif
37};
38
39template <class T, class U>
40struct C
41{
42};
43
44template <class T, class U> struct D1 {};
45
46template <class T, class U>
47struct D
48{
Dan Albert1d4a1ed2016-05-25 22:36:09 -070049#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
Howard Hinnantc52f43e2010-08-22 00:59:46 +000050 template <class V> using rebind = D1<V, U>;
51#else
52 template <class V> struct rebind {typedef D1<V, U> other;};
53#endif
54};
55
56int main()
57{
Dan Albert1d4a1ed2016-05-25 22:36:09 -070058#ifndef _LIBCPP_HAS_NO_TEMPLATE_ALIASES
Howard Hinnantc52f43e2010-08-22 00:59:46 +000059 static_assert((std::is_same<std::pointer_traits<A<int*> >::rebind<double*>, A<double*> >::value), "");
60 static_assert((std::is_same<std::pointer_traits<B<int> >::rebind<double>, B1<double> >::value), "");
61 static_assert((std::is_same<std::pointer_traits<C<char, int> >::rebind<double>, C<double, int> >::value), "");
62 static_assert((std::is_same<std::pointer_traits<D<char, int> >::rebind<double>, D1<double, int> >::value), "");
Dan Albert1d4a1ed2016-05-25 22:36:09 -070063#else // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
Howard Hinnantc52f43e2010-08-22 00:59:46 +000064 static_assert((std::is_same<std::pointer_traits<A<int*> >::rebind<double*>::other, A<double*> >::value), "");
65 static_assert((std::is_same<std::pointer_traits<B<int> >::rebind<double>::other, B1<double> >::value), "");
66 static_assert((std::is_same<std::pointer_traits<C<char, int> >::rebind<double>::other, C<double, int> >::value), "");
67 static_assert((std::is_same<std::pointer_traits<D<char, int> >::rebind<double>::other, D1<double, int> >::value), "");
Dan Albert1d4a1ed2016-05-25 22:36:09 -070068#endif // _LIBCPP_HAS_NO_TEMPLATE_ALIASES
Howard Hinnantc52f43e2010-08-22 00:59:46 +000069}