1// PR c++/49181
2// { dg-do compile { target c++11 } }
3
4namespace std
5{
6  typedef __SIZE_TYPE__ size_t;
7
8  template<typename _Tp, _Tp>
9    struct integral_constant;
10
11  template<typename _Tp, _Tp __v>
12    struct integral_constant
13    {
14      static constexpr _Tp value = __v;
15      typedef _Tp value_type;
16      typedef integral_constant<_Tp, __v> type;
17      constexpr operator value_type() { return value; }
18    };
19
20  typedef integral_constant<bool, true> true_type;
21
22  typedef integral_constant<bool, false> false_type;
23
24  template<typename _Tp, _Tp __v>
25    constexpr _Tp integral_constant<_Tp, __v>::value;
26
27  template<bool, typename _Tp = void>
28    struct enable_if
29    { };
30
31  template<typename _Tp>
32    struct enable_if<true, _Tp>
33    { typedef _Tp type; };
34
35  template<typename _Tp>
36    inline _Tp
37    declval();
38
39struct bad_alloc { };
40}
41
42void* operator new(std::size_t) throw (std::bad_alloc);
43
44namespace std
45{
46
47  template<typename _Tp>
48    class allocator
49    {
50    public:
51      typedef _Tp* pointer;
52      typedef _Tp value_type;
53
54      pointer
55      allocate(size_t, const void* = 0);
56    };
57
58  template<typename _Alloc>
59    struct allocator_traits
60    {
61      typedef typename _Alloc::value_type value_type;
62
63      template<typename _Tp> static typename _Tp::pointer
64_S_pointer_helper(_Tp*);
65      static value_type* _S_pointer_helper(...);
66      typedef decltype(_S_pointer_helper((_Alloc*)0)) __pointer;
67
68      typedef __pointer pointer;
69
70      typedef const void* const_void_pointer;
71
72      private:
73      template<typename _Alloc2>
74    struct __allocate_helper
75    {
76      template<typename _Alloc3,
77        typename = decltype(std::declval<_Alloc3*>()->allocate(
78          std::declval<size_t>(),
79          std::declval<const_void_pointer>()))>
80          static true_type __test(int);
81
82      template<typename>
83        static false_type __test(...);
84
85      typedef decltype(__test<_Alloc>(0)) type;
86      static const bool value = type::value;
87    };
88
89      template<typename _Alloc2>
90    static typename
91    enable_if<__allocate_helper<_Alloc2>::value, pointer>::type
92    _S_allocate(_Alloc2& __a, size_t __n, const_void_pointer __hint)
93    { return __a.allocate(__n, __hint); }
94
95      public:
96      static pointer
97    allocate(_Alloc& __a, size_t __n, const_void_pointer __hint)
98    { return _S_allocate(__a, __n, __hint); }
99    };
100
101}
102
103namespace std
104{
105  typedef short test_type;
106  template struct allocator_traits<allocator<test_type>>;
107}
108