1 //===----------------------------------------------------------------------===//
2 //
3 //                     The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9 
10 // <memory>
11 
12 // template <class Alloc>
13 // struct allocator_traits
14 // {
15 //     typedef Alloc::void_pointer
16 //           | pointer_traits<pointer>::rebind<void>
17 //                                          void_pointer;
18 //     ...
19 // };
20 
21 #include <memory>
22 #include <type_traits>
23 
24 template <class T>
25 struct Ptr {};
26 
27 template <class T>
28 struct A
29 {
30     typedef T value_type;
31     typedef Ptr<T> pointer;
32 };
33 
34 template <class T>
35 struct B
36 {
37     typedef T value_type;
38 };
39 
40 template <class T>
41 struct CPtr {};
42 
43 template <class T>
44 struct C
45 {
46     typedef T value_type;
47     typedef CPtr<void> void_pointer;
48 };
49 
main()50 int main()
51 {
52     static_assert((std::is_same<std::allocator_traits<A<char> >::void_pointer, Ptr<void> >::value), "");
53     static_assert((std::is_same<std::allocator_traits<B<char> >::void_pointer, void*>::value), "");
54     static_assert((std::is_same<std::allocator_traits<C<char> >::void_pointer, CPtr<void> >::value), "");
55 }
56