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