| 1 |
/* { dg-do compile } */ |
| 2 |
/* { dg-options "-g -dA -std=gnu++11" } */ |
| 3 |
namespace std |
| 4 |
{ |
| 5 |
template <typename _Tp> struct integral_constant |
| 6 |
{ |
| 7 |
static constexpr _Tp value = 0; |
| 8 |
}; |
| 9 |
template <int> using __bool_constant = integral_constant<int>; |
| 10 |
struct __not_ : integral_constant<int> |
| 11 |
{ |
| 12 |
}; |
| 13 |
template <typename, typename, template <typename...> class _Op, |
| 14 |
typename... _Args> |
| 15 |
struct __detector |
| 16 |
{ |
| 17 |
using type = _Op<_Args...>; |
| 18 |
}; |
| 19 |
template <typename _Default, template <typename...> class _Op, |
| 20 |
typename... _Args> |
| 21 |
using __detected_or = __detector<_Default, void, _Op, _Args...>; |
| 22 |
template <typename _Default, template <typename...> class _Op, |
| 23 |
typename... _Args> |
| 24 |
using __detected_or_t = typename __detected_or<_Default, _Op, _Args...>::type; |
| 25 |
template <template <typename...> class _Default, |
| 26 |
template <typename...> class _Op, typename... _Args> |
| 27 |
using __detected_or_t_ = __detected_or_t<_Default<_Args...>, _Op, _Args...>; |
| 28 |
template <typename, typename> struct pair; |
| 29 |
template <typename, typename> using __replace_first_arg_t = int; |
| 30 |
} |
| 31 |
class new_allocator |
| 32 |
{ |
| 33 |
}; |
| 34 |
namespace std |
| 35 |
{ |
| 36 |
template <typename> using __allocator_base = new_allocator; |
| 37 |
template <typename> class allocator : __allocator_base<int> |
| 38 |
{ |
| 39 |
}; |
| 40 |
template <typename> struct equal_to; |
| 41 |
struct __allocator_traits_base |
| 42 |
{ |
| 43 |
template <typename _Alloc, typename _Up> |
| 44 |
using __rebind = typename _Alloc::template rebind<_Up>::other; |
| 45 |
}; |
| 46 |
template <typename _Alloc, typename _Up> |
| 47 |
using __alloc_rebind |
| 48 |
= __detected_or_t_<__replace_first_arg_t, |
| 49 |
__allocator_traits_base::__rebind, _Alloc, _Up>; |
| 50 |
} |
| 51 |
struct __alloc_traits |
| 52 |
{ |
| 53 |
static int _S_select_on_copy; |
| 54 |
}; |
| 55 |
namespace std |
| 56 |
{ |
| 57 |
template <typename> struct hash; |
| 58 |
namespace __detail |
| 59 |
{ |
| 60 |
struct _Select1st; |
| 61 |
struct _Hashtable_traits |
| 62 |
{ |
| 63 |
using __hash_cached = __bool_constant<0>; |
| 64 |
}; |
| 65 |
template <typename, int> struct _Hash_node; |
| 66 |
template <typename _Value> struct _Hash_node<_Value, 0> |
| 67 |
{ |
| 68 |
int &_M_v (); |
| 69 |
}; |
| 70 |
struct _Mod_range_hashing; |
| 71 |
struct _Default_ranged_hash; |
| 72 |
struct _Prime_rehash_policy |
| 73 |
{ |
| 74 |
using __has_load_factor = integral_constant<int>; |
| 75 |
}; |
| 76 |
struct _Map_base |
| 77 |
{ |
| 78 |
}; |
| 79 |
struct _Insert |
| 80 |
{ |
| 81 |
}; |
| 82 |
template <typename _Policy> |
| 83 |
using __has_load_factor = typename _Policy::__has_load_factor; |
| 84 |
template <typename _RehashPolicy, typename, |
| 85 |
typename = __detected_or_t<integral_constant<bool>, |
| 86 |
__has_load_factor, _RehashPolicy> > |
| 87 |
struct _Rehash_base; |
| 88 |
template <typename _RehashPolicy, typename _Traits> |
| 89 |
struct _Rehash_base<_RehashPolicy, _Traits, integral_constant<int> > {}; |
| 90 |
struct _Hashtable_ebo_helper { template <typename _OtherTp> _Hashtable_ebo_helper (_OtherTp); }; |
| 91 |
struct _Hashtable_base {}; |
| 92 |
struct _Equality {}; |
| 93 |
template <typename _NodeAlloc> struct _Hashtable_alloc : _Hashtable_ebo_helper |
| 94 |
{ |
| 95 |
using __ebo_node_alloc = _Hashtable_ebo_helper; |
| 96 |
using __node_type = typename _NodeAlloc::value_type; |
| 97 |
using __node_alloc_traits = __alloc_traits; |
| 98 |
template <typename _Alloc> _Hashtable_alloc (_Alloc) : __ebo_node_alloc (0) {} |
| 99 |
template <typename... _Args> __node_type *_M_allocate_node (...); |
| 100 |
}; |
| 101 |
} |
| 102 |
template <typename, typename> using __cache_default = __not_; |
| 103 |
template <typename _Key, typename _Value, typename _Alloc, typename _ExtractKey, typename _Equal, typename _H1, typename _H2, |
| 104 |
typename _Hash, typename _RehashPolicy, typename _Traits> |
| 105 |
struct _Hashtable : __detail::_Hashtable_base, __detail::_Map_base, __detail::_Insert, __detail::_Rehash_base<_RehashPolicy, int>, |
| 106 |
__detail::_Equality, __detail:: _Hashtable_alloc<__alloc_rebind<_Alloc, __detail::_Hash_node<_Value, _Traits::__hash_cached::value> > > |
| 107 |
{ |
| 108 |
using __traits_type = _Traits; |
| 109 |
using __hash_cached = typename __traits_type::__hash_cached; |
| 110 |
using __node_type = __detail::_Hash_node<_Value, __hash_cached::value>; |
| 111 |
using __node_alloc_type = __alloc_rebind<_Alloc, __node_type>; |
| 112 |
using __hashtable_alloc = __detail::_Hashtable_alloc<__node_alloc_type>; |
| 113 |
using typename __hashtable_alloc::__node_alloc_traits; |
| 114 |
_Key key_type; |
| 115 |
_RehashPolicy _M_rehash_policy; |
| 116 |
template <typename _NodeGenerator> |
| 117 |
void _M_assign (const _Hashtable &, const _NodeGenerator &); |
| 118 |
_Hashtable (); |
| 119 |
_Hashtable (const _Hashtable &); |
| 120 |
}; |
| 121 |
template <typename _Key, typename _Value, typename _Alloc, typename _ExtractKey, typename _Equal, typename _H1, typename _H2, |
| 122 |
typename _Hash, typename _RehashPolicy, typename _Traits> |
| 123 |
template <typename _NodeGenerator> |
| 124 |
void _Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, |
| 125 |
_Traits>::_M_assign (const _Hashtable &__ht, const _NodeGenerator &__node_gen) try { |
| 126 |
__node_type *__this_n = __node_gen (0); } catch (...) {} |
| 127 |
template <typename _Key, typename _Value, typename _Alloc, typename _ExtractKey, typename _Equal, typename _H1, typename _H2, |
| 128 |
typename _Hash, typename _RehashPolicy, typename _Traits> |
| 129 |
_Hashtable<_Key, _Value, _Alloc, _ExtractKey, _Equal, _H1, _H2, _Hash, _RehashPolicy, _Traits>::_Hashtable (const _Hashtable &__ht) |
| 130 |
: __hashtable_alloc (__node_alloc_traits::_S_select_on_copy), _M_rehash_policy () |
| 131 |
{ |
| 132 |
_M_assign (__ht, [this](__node_type *__n) { return this->_M_allocate_node (__n->_M_v ()); }); |
| 133 |
} |
| 134 |
template <bool _Cache> using __umap_traits = __detail::_Hashtable_traits; |
| 135 |
template <typename _Key, typename _Tp, typename _Hash = hash<_Key>, typename _Pred = std::equal_to<_Key>, |
| 136 |
typename _Alloc = std::allocator<std::pair<const _Key, _Tp> >, |
| 137 |
typename _Tr = __umap_traits<__cache_default<_Key, _Hash>::value> > |
| 138 |
using __umap_hashtable = _Hashtable<_Key, std::pair<const _Key, _Tp>, _Alloc, __detail::_Select1st, _Pred, _Hash, |
| 139 |
__detail::_Mod_range_hashing, __detail::_Default_ranged_hash, __detail::_Prime_rehash_policy, _Tr>; |
| 140 |
template <class _Key, class _Tp, class _Hash = hash<_Key>, class _Pred = std::equal_to<_Key>, |
| 141 |
class _Alloc = std::allocator<std::pair<const _Key, _Tp> > > |
| 142 |
struct unordered_map |
| 143 |
{ |
| 144 |
typedef __umap_hashtable<_Key, _Tp, _Hash, _Pred, _Alloc> _Hashtable; |
| 145 |
_Hashtable _M_h; |
| 146 |
unordered_map (const int &__a) : _M_h () {} |
| 147 |
}; |
| 148 |
} |
| 149 |
struct uneq_allocator_base {}; |
| 150 |
template <typename Tp> struct uneq_allocator : uneq_allocator_base { typedef Tp value_type; }; |
| 151 |
template <typename Tp, typename Alloc = std::allocator<Tp> > |
| 152 |
struct Trans_NS___gnu_test_propagating_allocator : public uneq_allocator<Tp> |
| 153 |
{ |
| 154 |
template <typename Up> struct rebind { typedef Trans_NS___gnu_test_propagating_allocator<Up, int> other; }; |
| 155 |
}; |
| 156 |
void fn1 () |
| 157 |
{ |
| 158 |
std::unordered_map<int, int, int, int, Trans_NS___gnu_test_propagating_allocator<int> > v1 (0); |
| 159 |
std::unordered_map<int, int, int, int, Trans_NS___gnu_test_propagating_allocator<int> > v2 (v1); |
| 160 |
} |