Skip to content

Commit ad1ad15

Browse files
authored
Merge 2018-06 LWG Motion 26
Fixes #2143
2 parents d06f8bc + 690c0e0 commit ad1ad15

File tree

2 files changed

+40
-16
lines changed

2 files changed

+40
-16
lines changed

source/compatibility.tex

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2001,6 +2001,18 @@
20012001
Valid \CppXVII{} code that \tcode{\#include}{s} headers with these names may be
20022002
invalid in this International Standard.
20032003

2004+
\rSec2[diff.cpp17.containers]{\ref{containers}: containers library}
2005+
2006+
\diffrefs{forwardlist}{list}
2007+
\change
2008+
Return types of \tcode{remove}, \tcode{remove_if}, and \tcode{unique}
2009+
changed from \tcode{void} to \tcode{container::size_type}.
2010+
\rationale Improve efficiency and convenience of finding number of removed elements.
2011+
\effect
2012+
Code that depends on the return types might have different semantics in this International Standard.
2013+
Translation units compiled against this version of \Cpp{} may be incompatible with
2014+
translation units compiled against \CppXVII{}, either failing to link or having undefined behavior.
2015+
20042016
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
20052017
\rSec1[diff.library]{C standard library}
20062018
\indextext{library!C standard}%

source/containers.tex

Lines changed: 28 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -3883,11 +3883,11 @@
38833883
void splice_after(const_iterator position, forward_list&& x,
38843884
const_iterator first, const_iterator last);
38853885

3886-
void remove(const T& value);
3887-
template<class Predicate> void remove_if(Predicate pred);
3886+
size_type remove(const T& value);
3887+
template<class Predicate> size_type remove_if(Predicate pred);
38883888

3889-
void unique();
3890-
template<class BinaryPredicate> void unique(BinaryPredicate binary_pred);
3889+
size_type unique();
3890+
template<class BinaryPredicate> size_type unique(BinaryPredicate binary_pred);
38913891

38923892
void merge(forward_list& x);
38933893
void merge(forward_list&& x);
@@ -4328,8 +4328,8 @@
43284328
\indexlibrarymember{remove}{forward_list}%
43294329
\indexlibrarymember{remove_if}{forward_list}%
43304330
\begin{itemdecl}
4331-
void remove(const T& value);
4332-
template<class Predicate> void remove_if(Predicate pred);
4331+
size_type remove(const T& value);
4332+
template<class Predicate> size_type remove_if(Predicate pred);
43334333
\end{itemdecl}
43344334

43354335
\begin{itemdescr}
@@ -4339,6 +4339,9 @@
43394339
\tcode{pred(*i)} is \tcode{true} (for \tcode{remove_if()}).
43404340
Invalidates only the iterators and references to the erased elements.
43414341

4342+
\pnum
4343+
\returns The number of elements erased.
4344+
43424345
\pnum
43434346
\throws Nothing unless an exception is thrown by the equality comparison or the
43444347
predicate.
@@ -4353,8 +4356,8 @@
43534356

43544357
\indexlibrarymember{unique}{forward_list}%
43554358
\begin{itemdecl}
4356-
void unique();
4357-
template<class BinaryPredicate> void unique(BinaryPredicate pred);
4359+
size_type unique();
4360+
template<class BinaryPredicate> size_type unique(BinaryPredicate pred);
43584361
\end{itemdecl}
43594362

43604363
\begin{itemdescr}
@@ -4365,6 +4368,9 @@
43654368
*(i - 1))} (for the version with a predicate argument) holds.
43664369
Invalidates only the iterators and references to the erased elements.
43674370

4371+
\pnum
4372+
\returns The number of elements erased.
4373+
43684374
\pnum
43694375
\throws Nothing unless an exception is thrown by the equality comparison or the predicate.
43704376

@@ -4574,12 +4580,12 @@
45744580
void splice(const_iterator position, list& x, const_iterator first, const_iterator last);
45754581
void splice(const_iterator position, list&& x, const_iterator first, const_iterator last);
45764582

4577-
void remove(const T& value);
4578-
template<class Predicate> void remove_if(Predicate pred);
4583+
size_type remove(const T& value);
4584+
template<class Predicate> size_type remove_if(Predicate pred);
45794585

4580-
void unique();
4586+
size_type unique();
45814587
template<class BinaryPredicate>
4582-
void unique(BinaryPredicate binary_pred);
4588+
size_type unique(BinaryPredicate binary_pred);
45834589

45844590
void merge(list& x);
45854591
void merge(list&& x);
@@ -4961,8 +4967,8 @@
49614967

49624968
\indexlibrary{\idxcode{remove}!\idxcode{list}}%
49634969
\begin{itemdecl}
4964-
void remove(const T& value);
4965-
template<class Predicate> void remove_if(Predicate pred);
4970+
size_type remove(const T& value);
4971+
template<class Predicate> size_type remove_if(Predicate pred);
49664972
\end{itemdecl}
49674973

49684974
\begin{itemdescr}
@@ -4972,6 +4978,9 @@
49724978
following conditions hold: \tcode{*i == value}, \tcode{pred(*i) != false}.
49734979
Invalidates only the iterators and references to the erased elements.
49744980

4981+
\pnum
4982+
\returns The number of elements erased.
4983+
49754984
\pnum
49764985
\throws
49774986
Nothing unless an exception is thrown by
@@ -4991,8 +5000,8 @@
49915000

49925001
\indexlibrary{\idxcode{unique}!\idxcode{list}}%
49935002
\begin{itemdecl}
4994-
void unique();
4995-
template<class BinaryPredicate> void unique(BinaryPredicate binary_pred);
5003+
size_type unique();
5004+
template<class BinaryPredicate> size_type unique(BinaryPredicate binary_pred);
49965005
\end{itemdecl}
49975006

49985007
\begin{itemdescr}
@@ -5005,6 +5014,9 @@
50055014
\tcode{unique} with a predicate argument) holds.
50065015
Invalidates only the iterators and references to the erased elements.
50075016

5017+
\pnum
5018+
\returns The number of elements erased.
5019+
50085020
\pnum
50095021
\throws
50105022
Nothing unless an exception is thrown by

0 commit comments

Comments
 (0)