| 1 |
// PR tree-optimization/97609 |
| 2 |
// { dg-do compile { target c++11 } } |
| 3 |
// { dg-options "-O2 -fno-tree-fre -fnon-call-exceptions" } |
| 4 |
|
| 5 |
struct _Fwd_list_node_base { |
| 6 |
_Fwd_list_node_base *_M_next; |
| 7 |
void _M_transfer_after() { _Fwd_list_node_base *__keep = _M_next = __keep; } |
| 8 |
}; |
| 9 |
struct _Fwd_list_const_iterator { |
| 10 |
_Fwd_list_const_iterator(_Fwd_list_node_base *__n) : _M_node(__n) {} |
| 11 |
_Fwd_list_const_iterator(int); |
| 12 |
_Fwd_list_node_base *_M_node; |
| 13 |
}; |
| 14 |
template <typename, typename> struct forward_list { |
| 15 |
_Fwd_list_node_base _M_head; |
| 16 |
template <typename _InputIterator> |
| 17 |
forward_list(_InputIterator, _InputIterator); |
| 18 |
forward_list(int); |
| 19 |
_Fwd_list_const_iterator cbefore_begin() { return &_M_head; } |
| 20 |
void splice_after(_Fwd_list_const_iterator) noexcept; |
| 21 |
void splice_after(_Fwd_list_const_iterator __pos, forward_list &) { |
| 22 |
splice_after(__pos, 0); |
| 23 |
} |
| 24 |
using __remove_return_type = void; |
| 25 |
__remove_return_type unique() { unique(0); } |
| 26 |
template <typename _BinPred> __remove_return_type unique(_BinPred); |
| 27 |
}; |
| 28 |
template <typename _Tp, typename _Alloc> |
| 29 |
void forward_list<_Tp, _Alloc>::splice_after(_Fwd_list_const_iterator __pos) |
| 30 |
noexcept { |
| 31 |
__pos._M_node->_M_transfer_after(); |
| 32 |
} |
| 33 |
template <typename _Tp, typename _Alloc> |
| 34 |
template <typename _BinPred> |
| 35 |
auto forward_list<_Tp, _Alloc>::unique(_BinPred) -> __remove_return_type { |
| 36 |
forward_list __to_destroy(0); |
| 37 |
splice_after(__to_destroy.cbefore_begin()); |
| 38 |
} |
| 39 |
|
| 40 |
void |
| 41 |
foo () |
| 42 |
{ |
| 43 |
forward_list<int, int> c1 (0, 0); |
| 44 |
c1.unique (); |
| 45 |
} |
| 46 |
|