1 // PR ipa/63587
2 // { dg-do compile { target c++11 } }
3 // { dg-options "-O2 -fno-strict-aliasing" }
4
5 template <class> struct A
6 {
7 };
8 template <typename> struct B
9 {
10 template <typename> struct C;
11 };
12 class D;
13 template <typename> class F;
14 struct G
15 {
16 void operator()(const D &, D);
17 };
18 class D
19 {
20 public:
21 D (int);
22 };
23 struct H
24 {
25 H (int);
26 };
27 template <typename _Key, typename, typename, typename _Compare, typename>
28 class I
29 {
30 typedef _Key key_type;
31 template <typename _Key_compare> struct J
32 {
33 _Key_compare _M_key_compare;
34 };
35 J<_Compare> _M_impl;
36
37 public:
38 A<int> _M_get_insert_unique_pos (const key_type &);
39 A<int> _M_get_insert_hint_unique_pos (H &);
40 template <typename... _Args> int _M_emplace_hint_unique (H, _Args &&...);
41 };
42 template <typename _Key, typename _Tp, typename _Compare = G,
43 typename _Alloc = F<A<_Tp> > >
44 class K
45 {
46 typedef _Key key_type;
47 typedef _Key value_type;
48 typedef typename B<_Alloc>::template C<value_type> _Pair_alloc_type;
49 I<key_type, value_type, int, _Compare, _Pair_alloc_type> _M_t;
50
51 public:
52 void operator[](key_type)
53 {
54 _M_t._M_emplace_hint_unique (0);
55 }
56 };
57 template <typename _Key, typename _Val, typename _KeyOfValue,
58 typename _Compare, typename _Alloc>
59 A<int>
_M_get_insert_unique_pos(const key_type & p1)60 I<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_unique_pos (
61 const key_type &p1)
62 {
63 _M_impl._M_key_compare (p1, 0);
64 }
65 template <typename _Key, typename _Val, typename _KeyOfValue,
66 typename _Compare, typename _Alloc>
67 A<int>
_M_get_insert_hint_unique_pos(H &)68 I<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_get_insert_hint_unique_pos (
69 H &)
70 {
71 _M_get_insert_unique_pos (0);
72 }
73 template <typename _Key, typename _Val, typename _KeyOfValue,
74 typename _Compare, typename _Alloc>
75 template <typename... _Args>
76 int
_M_emplace_hint_unique(H p1,_Args &&...)77 I<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_emplace_hint_unique (
78 H p1, _Args &&...)
79 {
80 _M_get_insert_hint_unique_pos (p1);
81 }
82 namespace {
83 struct L;
84 }
85 void
fn1()86 fn1 ()
87 {
88 K<D, L> a;
89 a[0];
90 K<D, int> b;
91 b[0];
92 }
93