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::size_type | size_t size_type; 16 // ... 17 // }; 18 19 #include <memory> 20 #include <type_traits> 21 22 template <class T> 23 struct A 24 { 25 typedef T value_type; 26 typedef unsigned short size_type; 27 }; 28 29 template <class T> 30 struct B 31 { 32 typedef T value_type; 33 }; 34 35 template <class T> 36 struct C 37 { 38 typedef T value_type; 39 struct pointer {}; 40 struct const_pointer {}; 41 struct void_pointer {}; 42 struct const_void_pointer {}; 43 }; 44 45 namespace std 46 { 47 48 template <> 49 struct pointer_traits<C<char>::pointer> 50 { 51 typedef signed char difference_type; 52 }; 53 54 } 55 main()56int main() 57 { 58 static_assert((std::is_same<std::allocator_traits<A<char> >::size_type, unsigned short>::value), ""); 59 static_assert((std::is_same<std::allocator_traits<B<char> >::size_type, 60 std::make_unsigned<std::ptrdiff_t>::type>::value), ""); 61 static_assert((std::is_same<std::allocator_traits<C<char> >::size_type, 62 unsigned char>::value), ""); 63 } 64