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 25 template <class T> 26 struct Ptr {}; 27 28 template <class T> 29 struct A 30 { 31 typedef T value_type; 32 typedef Ptr<T> pointer; 33 }; 34 35 template <class T> 36 struct B 37 { 38 typedef T value_type; 39 }; 40 41 template <class T> 42 struct CPtr {}; 43 44 template <class T> 45 struct C 46 { 47 typedef T value_type; 48 typedef CPtr<T> pointer; 49 typedef CPtr<const T> const_pointer; 50 }; 51 52 template <class T> 53 struct D { 54 typedef T value_type; 55 private: 56 typedef void const_pointer; 57 }; 58 59 int 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