Skip to content

Commit 722e150

Browse files
authored
Do not deduce the return type of unique,remove[_if] of [forward_]list (#4975)
1 parent 97e52d1 commit 722e150

File tree

3 files changed

+14
-8
lines changed

3 files changed

+14
-8
lines changed

stl/inc/forward_list

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1208,12 +1208,12 @@ public:
12081208
_Nodeptr* _Tail;
12091209
};
12101210

1211-
auto remove(const _Ty& _Val) { // erase each element matching _Val
1211+
_LIST_REMOVE_RETURN remove(const _Ty& _Val) { // erase each element matching _Val
12121212
return remove_if([&](const _Ty& _Other) -> bool { return _Other == _Val; });
12131213
}
12141214

12151215
template <class _Pr1>
1216-
auto remove_if(_Pr1 _Pred) { // erase each element satisfying _Pr1
1216+
_LIST_REMOVE_RETURN remove_if(_Pr1 _Pred) { // erase each element satisfying _Pr1
12171217
_Flist_node_remove_op _Op(*this);
12181218
auto _Firstb = _Unchecked_before_begin();
12191219
size_type _Removed = 0;
@@ -1235,12 +1235,12 @@ public:
12351235
#endif
12361236
}
12371237

1238-
auto unique() { // erase each element matching previous
1238+
_LIST_REMOVE_RETURN unique() { // erase each element matching previous
12391239
return unique(equal_to<>{});
12401240
}
12411241

12421242
template <class _Pr2>
1243-
auto unique(_Pr2 _Pred) { // erase each element satisfying _Pred with previous
1243+
_LIST_REMOVE_RETURN unique(_Pr2 _Pred) { // erase each element satisfying _Pred with previous
12441244
_Flist_node_remove_op _Op(*this);
12451245
auto _First = _Unchecked_begin();
12461246
size_type _Removed = 0;

stl/inc/list

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1662,12 +1662,12 @@ public:
16621662
_Nodeptr* _Tail;
16631663
};
16641664

1665-
auto remove(const _Ty& _Val) { // erase each element matching _Val
1665+
_LIST_REMOVE_RETURN remove(const _Ty& _Val) { // erase each element matching _Val
16661666
return remove_if([&](const _Ty& _Other) -> bool { return _Other == _Val; });
16671667
}
16681668

16691669
template <class _Pr1>
1670-
auto remove_if(_Pr1 _Pred) { // erase each element satisfying _Pred
1670+
_LIST_REMOVE_RETURN remove_if(_Pr1 _Pred) { // erase each element satisfying _Pred
16711671
auto& _My_data = _Mypair._Myval2;
16721672
_List_node_remove_op _Op(*this);
16731673
const auto _Last = _My_data._Myhead;
@@ -1688,12 +1688,12 @@ public:
16881688
#endif
16891689
}
16901690

1691-
auto unique() { // erase each element matching previous
1691+
_LIST_REMOVE_RETURN unique() { // erase each element matching previous
16921692
return unique(equal_to<>{});
16931693
}
16941694

16951695
template <class _Pr2>
1696-
auto unique(_Pr2 _Pred) { // erase each element satisfying _Pred with previous
1696+
_LIST_REMOVE_RETURN unique(_Pr2 _Pred) { // erase each element satisfying _Pred with previous
16971697
_List_node_remove_op _Op(*this);
16981698
const _Nodeptr _Phead = _Mypair._Myval2._Myhead;
16991699
_Nodeptr _Pprev = _Phead->_Next;

stl/inc/xmemory

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2649,6 +2649,12 @@ _STD_END
26492649
#define _CONTAINER_EMPLACE_RETURN void
26502650
#endif // ^^^ !_HAS_CXX17 ^^^
26512651

2652+
#if _HAS_CXX20
2653+
#define _LIST_REMOVE_RETURN size_type
2654+
#else // ^^^ _HAS_CXX20 ^^^ / vvv !_HAS_CXX20 vvv
2655+
#define _LIST_REMOVE_RETURN void
2656+
#endif // ^^^ !_HAS_CXX20 ^^^
2657+
26522658
#pragma pop_macro("new")
26532659
_STL_RESTORE_CLANG_WARNINGS
26542660
#pragma warning(pop)

0 commit comments

Comments
 (0)