blob: e9c175fe86a54ec16eff4a22fff580ab3d1ae953 [file] [log] [blame]
Howard Hinnantc52f43e2010-08-22 00:59:46 +00001//===----------------------------------------------------------------------===//
2//
3// The LLVM Compiler Infrastructure
4//
Howard Hinnantb64f8b02010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnantc52f43e2010-08-22 00:59:46 +00007//
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
22template <class T>
23struct A
24{
25 typedef T value_type;
26 typedef unsigned short size_type;
27};
28
29template <class T>
30struct B
31{
32 typedef T value_type;
33};
34
Howard Hinnant47761072010-11-18 01:40:00 +000035template <class T>
36struct 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
45namespace std
46{
47
48template <>
49struct pointer_traits<C<char>::pointer>
50{
51 typedef signed char difference_type;
52};
53
54}
55
Howard Hinnantc52f43e2010-08-22 00:59:46 +000056int main()
57{
58 static_assert((std::is_same<std::allocator_traits<A<char> >::size_type, unsigned short>::value), "");
Howard Hinnant47761072010-11-18 01:40:00 +000059 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), "");
Howard Hinnantc52f43e2010-08-22 00:59:46 +000063}