1 // PR c++/49181
2 // { dg-do compile { target c++11 } }
3 
4 namespace 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;
value_typeintegral_constant17       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 
39 struct bad_alloc { };
40 }
41 
42 void* operator new(std::size_t)
43 #if __cplusplus <= 201402L
44 throw (std::bad_alloc)			// { dg-warning "deprecated" "" { target { ! c++17 } } }
45 #endif
46 ;
47 
48 namespace std
49 {
50 
51   template<typename _Tp>
52     class allocator
53     {
54     public:
55       typedef _Tp* pointer;
56       typedef _Tp value_type;
57 
58       pointer
59       allocate(size_t, const void* = 0);
60     };
61 
62   template<typename _Alloc>
63     struct allocator_traits
64     {
65       typedef typename _Alloc::value_type value_type;
66 
67       template<typename _Tp> static typename _Tp::pointer
68 _S_pointer_helper(_Tp*);
69       static value_type* _S_pointer_helper(...);
70       typedef decltype(_S_pointer_helper((_Alloc*)0)) __pointer;
71 
72       typedef __pointer pointer;
73 
74       typedef const void* const_void_pointer;
75 
76       private:
77       template<typename _Alloc2>
78     struct __allocate_helper
79     {
80       template<typename _Alloc3,
81         typename = decltype(std::declval<_Alloc3*>()->allocate(
82           std::declval<size_t>(),
83           std::declval<const_void_pointer>()))>
84           static true_type __test(int);
85 
86       template<typename>
87         static false_type __test(...);
88 
89       typedef decltype(__test<_Alloc>(0)) type;
90       static const bool value = type::value;
91     };
92 
93       template<typename _Alloc2>
94     static typename
95     enable_if<__allocate_helper<_Alloc2>::value, pointer>::type
96     _S_allocate(_Alloc2& __a, size_t __n, const_void_pointer __hint)
97     { return __a.allocate(__n, __hint); }
98 
99       public:
100       static pointer
101     allocate(_Alloc& __a, size_t __n, const_void_pointer __hint)
102     { return _S_allocate(__a, __n, __hint); }
103     };
104 
105 }
106 
107 namespace std
108 {
109   typedef short test_type;
110   template struct allocator_traits<allocator<test_type>>;
111 }
112