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::const_pointer
16//           | pointer_traits<pointer>::rebind<const value_type>
17//     ...
18// };
19
20#include <memory>
21#include <type_traits>
22
23#include "test_macros.h"
24
25template <class T>
26struct Ptr {};
27
28template <class T>
29struct A
30{
31    typedef T value_type;
32    typedef Ptr<T> pointer;
33};
34
35template <class T>
36struct B
37{
38    typedef T value_type;
39};
40
41template <class T>
42struct CPtr {};
43
44template <class T>
45struct C
46{
47    typedef T value_type;
48    typedef CPtr<T> pointer;
49    typedef CPtr<const T> const_pointer;
50};
51
52template <class T>
53struct D {
54  typedef T value_type;
55private:
56  typedef void const_pointer;
57};
58
59int main()
60{
61    static_assert((std::is_same<std::allocator_traits<A<char> >::const_pointer, Ptr<const char> >::value), "");
62    static_assert((std::is_same<std::allocator_traits<B<char> >::const_pointer, const char*>::value), "");
63    static_assert((std::is_same<std::allocator_traits<C<char> >::const_pointer, CPtr<const char> >::value), "");
64#if TEST_STD_VER >= 11
65    static_assert((std::is_same<std::allocator_traits<D<char> >::const_pointer, const char*>::value), "");
66#endif
67}
68