difference_type.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::difference_type
16//           | ptrdiff_t                    difference_type;
17//     ...
18// };
19
20#include <memory>
21#include <type_traits>
22
23template <class T>
24struct A
25{
26    typedef T value_type;
27    typedef short difference_type;
28};
29
30template <class T>
31struct B
32{
33    typedef T value_type;
34};
35
36int main()
37{
38    static_assert((std::is_same<std::allocator_traits<A<char> >::difference_type, short>::value), "");
39    static_assert((std::is_same<std::allocator_traits<B<char> >::difference_type, std::ptrdiff_t>::value), "");
40}
41