Skip to content

Commit cb67ff1

Browse files
authored
Merge 2019-02 LWG Motion 2
P1457R0 C++ Standard Library Issues (Kona 2019) Fixes #2711.
2 parents 3395660 + 4753486 commit cb67ff1

File tree

10 files changed

+98
-98
lines changed

10 files changed

+98
-98
lines changed

source/algorithms.tex

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2662,13 +2662,16 @@
26622662
ForwardIterator first, ForwardIterator last, Compare comp);
26632663

26642664
namespace ranges {
2665+
template<class I>
2666+
using minmax_element_result = minmax_result<I>;
2667+
26652668
template<ForwardIterator I, Sentinel<I> S, class Proj = identity,
26662669
IndirectStrictWeakOrder<projected<I, Proj>> Comp = ranges::less<>>
2667-
constexpr minmax_result<I>
2670+
constexpr minmax_element_result<I>
26682671
minmax_element(I first, S last, Comp comp = {}, Proj proj = {});
26692672
template<ForwardRange R, class Proj = identity,
26702673
IndirectStrictWeakOrder<projected<iterator_t<R>, Proj>> Comp = ranges::less<>>
2671-
constexpr minmax_result<safe_iterator_t<R>>
2674+
constexpr minmax_element_result<safe_iterator_t<R>>
26722675
minmax_element(R&& r, Comp comp = {}, Proj proj = {});
26732676
}
26742677

source/atomics.tex

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1350,8 +1350,18 @@
13501350

13511351
\indexlibrary{\idxcode{atomic}}%
13521352
\pnum
1353-
The template argument for
1354-
\tcode{T} shall be trivially copyable\iref{basic.types}. \begin{note} Type arguments that are
1353+
The template argument for \tcode{T} shall meet the
1354+
\oldconcept{CopyConstructible} and \oldconcept{CopyAssignable} requirements.
1355+
The program is ill-formed if any of
1356+
\begin{itemize}
1357+
\item \tcode{is_trivially_copyable_v<T>},
1358+
\item \tcode{is_copy_constructible_v<T>},
1359+
\item \tcode{is_move_constructible_v<T>},
1360+
\item \tcode{is_copy_assignable_v<T>}, or
1361+
\item \tcode{is_move_assignable_v<T>}
1362+
\end{itemize}
1363+
is \tcode{false}.
1364+
\begin{note} Type arguments that are
13551365
not also statically initializable may be difficult to use. \end{note}
13561366

13571367
\pnum

source/concepts.tex

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,13 +273,18 @@
273273
\indexlibrary{\idxcode{Same}}%
274274
\begin{itemdecl}
275275
template<class T, class U>
276-
concept Same = is_same_v<T, U>;
276+
concept @\placeholdernc{same-impl}@ = is_same_v<T, U>; // \expos
277+
278+
template<class T, class U>
279+
concept Same = @\placeholdernc{same-impl}@<T, U> && @\placeholdernc{same-impl}@<U, T>;
277280
\end{itemdecl}
278281

279282
\begin{itemdescr}
280283
\pnum
284+
\begin{note}
281285
\tcode{\libconcept{Same}<T, U>} subsumes \tcode{\libconcept{Same}<U, T>} and
282286
vice versa.
287+
\end{note}
283288
\end{itemdescr}
284289

285290
\rSec2[concept.derivedfrom]{Concept \libconcept{DerivedFrom}}

source/containers.tex

Lines changed: 40 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3790,15 +3790,23 @@
37903790
but does not change the size of the sequence.
37913791
\begin{note} The request is non-binding to allow latitude for
37923792
implementation-specific optimizations. \end{note}
3793-
If an exception is thrown other than by the move constructor
3794-
of a non-\oldconcept{CopyInsertable} \tcode{T} there are no effects.
3793+
If the size is equal to the old capacity, or
3794+
if an exception is thrown other than by the move constructor
3795+
of a non-\oldconcept{CopyInsertable} \tcode{T},
3796+
then there are no effects.
37953797

37963798
\pnum
3797-
\complexity Linear in the size of the sequence.
3799+
\complexity
3800+
If the size is not equal to the old capacity,
3801+
linear in the size of the sequence;
3802+
otherwise constant.
37983803

37993804
\pnum
3800-
\remarks \tcode{shrink_to_fit} invalidates all the references, pointers, and iterators
3801-
referring to the elements in the sequence as well as the past-the-end iterator.
3805+
\remarks
3806+
If the size is not equal to the old capacity,
3807+
then invalidates all the references, pointers, and iterators
3808+
referring to the elements in the sequence,
3809+
as well as the past-the-end iterator.
38023810
\end{itemdescr}
38033811

38043812
\rSec3[deque.modifiers]{Modifiers}
@@ -5141,7 +5149,7 @@
51415149
\pnum
51425150
\complexity
51435151
Constant time if
5144-
\tcode{\&x == this};
5152+
\tcode{addressof(x) == this};
51455153
otherwise, linear time.
51465154
\end{itemdescr}
51475155

@@ -5620,13 +5628,14 @@
56205628
\pnum
56215629
\remarks
56225630
Reallocation invalidates all the references, pointers, and iterators
5623-
referring to the elements in the sequence.
5631+
referring to the elements in the sequence, as well as the past-the-end iterator.
5632+
\begin{note}
5633+
If no reallocation happens, they remain valid.
5634+
\end{note}
56245635
No reallocation shall take place during insertions that happen
5625-
after a call to
5626-
\tcode{reserve()}
5627-
until the time when an insertion would make the size of the vector
5628-
greater than the value of
5629-
\tcode{capacity()}.
5636+
after a call to \tcode{reserve()}
5637+
until an insertion would make the size of the vector
5638+
greater than the value of \tcode{capacity()}.
56305639
\end{itemdescr}
56315640

56325641
\indexlibrary{\idxcode{shrink_to_fit}!\idxcode{vector}}%
@@ -5649,12 +5658,16 @@
56495658
of a non-\oldconcept{CopyInsertable} \tcode{T} there are no effects.
56505659

56515660
\pnum
5652-
\complexity Linear in the size of the sequence.
5661+
\complexity
5662+
If reallocation happens,
5663+
linear in the size of the sequence.
56535664

56545665
\pnum
56555666
\remarks Reallocation invalidates all the references, pointers, and iterators
56565667
referring to the elements in the sequence as well as the past-the-end iterator.
5668+
\begin{note}
56575669
If no reallocation happens, they remain valid.
5670+
\end{note}
56585671
\end{itemdescr}
56595672

56605673
\indexlibrary{\idxcode{swap}!\idxcode{vector}}%
@@ -5758,8 +5771,13 @@
57585771
\remarks
57595772
Causes reallocation if the new size is greater than the old capacity.
57605773
Reallocation invalidates all the references, pointers, and iterators
5761-
referring to the elements in the sequence.
5762-
If no reallocation happens, all the iterators and references before the insertion point remain valid.
5774+
referring to the elements in the sequence, as well as the past-the-end iterator.
5775+
If no reallocation happens, then
5776+
references, pointers, and iterators
5777+
before the insertion point remain valid
5778+
but those at or after the insertion point,
5779+
including the past-the-end iterator,
5780+
are invalidated.
57635781
If an exception is thrown other than by
57645782
the copy constructor, move constructor,
57655783
assignment operator, or move assignment operator of
@@ -5773,7 +5791,10 @@
57735791

57745792
\pnum
57755793
\complexity
5776-
The complexity is linear in the number of elements inserted plus the distance
5794+
If reallocation happens,
5795+
linear in the number of elements of the resulting vector;
5796+
otherwise,
5797+
linear in the number of elements inserted plus the distance
57775798
to the end of the vector.
57785799
\end{itemdescr}
57795800

@@ -10306,7 +10327,9 @@
1030610327
using index_type = ptrdiff_t;
1030710328
using difference_type = ptrdiff_t;
1030810329
using pointer = element_type*;
10330+
using const_pointer = const element_type*;
1030910331
using reference = element_type&;
10332+
using const_reference = const element_type&;
1031010333
using iterator = @\impdefx{type of \tcode{span::iterator}}@;
1031110334
using const_iterator = @\impdefx{type of \tcode{span::const_iterator}}@;
1031210335
using reverse_iterator = std::reverse_iterator<iterator>;
@@ -10494,8 +10517,6 @@
1049410517
\pnum
1049510518
\requires
1049610519
\range{data(cont)}{data(cont) + size(cont)} shall be a valid range.
10497-
If \tcode{extent} is not equal to \tcode{dynamic_extent},
10498-
then \tcode{size(cont)} shall be equal to \tcode{extent}.
1049910520

1050010521
\pnum
1050110522
\effects
@@ -10513,6 +10534,7 @@
1051310534
\remarks
1051410535
These constructors shall not participate in overload resolution unless:
1051510536
\begin{itemize}
10537+
\item \tcode{extent == dynamic_extent} is \tcode{true},
1051610538
\item \tcode{Container} is not a specialization of \tcode{span},
1051710539
\item \tcode{Container} is not a specialization of \tcode{array},
1051810540
\item \tcode{is_array_v<Container>} is \tcode{false},

source/diagnostics.tex

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1702,8 +1702,8 @@
17021702
\effects Constructs an object of class \tcode{system_error}.
17031703

17041704
\pnum
1705-
\ensures \tcode{code() == ec} and
1706-
\tcode{string(what()).find(what_arg) != string::npos}.
1705+
\ensures \tcode{code() == ec} and\newline
1706+
\tcode{string_view(what()).find(what_arg.c_str()) != string_view::npos}.
17071707
\end{itemdescr}
17081708

17091709
\indexlibrary{\idxcode{system_error}!constructor}%
@@ -1717,7 +1717,7 @@
17171717

17181718
\pnum
17191719
\ensures \tcode{code() == ec} and
1720-
\tcode{string(what()).find(what_arg) != string::npos}.
1720+
\tcode{string_view(what()).find(what_arg) != string_view::npos}.
17211721
\end{itemdescr}
17221722

17231723
\indexlibrary{\idxcode{system_error}!constructor}%
@@ -1744,7 +1744,7 @@
17441744

17451745
\pnum
17461746
\ensures \raggedright \tcode{code() == error_code(ev, ecat)} and\linebreak
1747-
\tcode{string(what()).find(what_arg) != string::npos}.
1747+
\tcode{string_view(what()).find(what_arg.c_str()) != string_view::npos}.
17481748
\end{itemdescr}
17491749

17501750
\indexlibrary{\idxcode{system_error}!constructor}%
@@ -1758,7 +1758,7 @@
17581758

17591759
\pnum
17601760
\ensures \raggedright \tcode{code() == error_code(ev, ecat)} and\linebreak
1761-
\tcode{string(what()).find(what_arg) != string::npos}.
1761+
\tcode{string_view(what()).find(what_arg) != string_view::npos}.
17621762
\end{itemdescr}
17631763

17641764
\indexlibrary{\idxcode{system_error}!constructor}%

source/iostreams.tex

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12904,7 +12904,7 @@
1290412904
\item \tcode{code() == ec},
1290512905
\item \tcode{path1().empty() == true},
1290612906
\item \tcode{path2().empty() == true}, and
12907-
\item \tcode{string_view(what()).find(what_arg)} \tcode{!= string_view::npos}.
12907+
\item \tcode{string_view(what()).find(what_arg.c_str())} \tcode{!= string_view::npos}.
1290812908
\end{itemize}
1290912909
\end{itemdescr}
1291012910

@@ -12920,7 +12920,7 @@
1292012920
\item \tcode{code() == ec},
1292112921
\item \tcode{path1()} returns a reference to the stored copy of \tcode{p1},
1292212922
\item \tcode{path2().empty() == true}, and
12923-
\item \tcode{string_view(what()).find(what_arg)} \tcode{!= string_view::npos}.
12923+
\item \tcode{string_view(what()).find(what_arg.c_str())} \tcode{!= string_view::npos}.
1292412924
\end{itemize}
1292512925
\end{itemdescr}
1292612926

@@ -12936,7 +12936,7 @@
1293612936
\item \tcode{code() == ec},
1293712937
\item \tcode{path1()} returns a reference to the stored copy of \tcode{p1},
1293812938
\item \tcode{path2()} returns a reference to the stored copy of \tcode{p2}, and
12939-
\item \tcode{string_view(what()).find(what_arg)} \tcode{!= string_view::npos}.
12939+
\item \tcode{string_view(what()).find(what_arg.c_str())} \tcode{!= string_view::npos}.
1294012940
\end{itemize}
1294112941
\end{itemdescr}
1294212942

source/lib-intro.tex

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -319,9 +319,10 @@
319319

320320
\definition{program-defined type}{defns.prog.def.type}
321321
\indexdefn{type!program-defined}%
322-
class type or enumeration type
322+
non-closure class type or enumeration type
323323
that is not part of the C++ standard library and
324324
not defined by the implementation,
325+
or a closure type of a non-implementation-provided lambda expression,
325326
or an instantiation of a program-defined specialization
326327

327328
\begin{defnote}

source/numerics.tex

Lines changed: 10 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -36,71 +36,22 @@
3636
and
3737
\tcode{valarray}
3838
components are parameterized by the type of information they contain and manipulate.
39-
A \Cpp{} program shall instantiate these components only with a type
40-
\tcode{T}
39+
A \Cpp{} program shall instantiate these components only with
40+
a cv-unqualified object type \tcode{T}
4141
that satisfies the
42-
following requirements:\footnote{In other words, value types.
42+
\oldconcept{DefaultConstructible},
43+
\oldconcept{CopyConstructible},
44+
\oldconcept{CopyAssignable}, and
45+
\oldconcept{Destructible}
46+
requirements\iref{utility.arg.requirements}.%
47+
\footnote{In other words, value types.
4348
These include arithmetic types,
4449
pointers, the library class
4550
\tcode{complex},
4651
and instantiations of
4752
\tcode{valarray}
4853
for value types.}
4954

50-
\begin{itemize}
51-
\item \tcode{T} is not an abstract class (it has no pure virtual member functions);
52-
\item \tcode{T} is not a reference type;
53-
\item \tcode{T} is not cv-qualified;
54-
\item If \tcode{T} is a class, it has a public default constructor;
55-
\item If \tcode{T} is a class, it has a public copy constructor with the signature \tcode{T::T(const T\&)}
56-
\item If \tcode{T} is a class, it has a public destructor;
57-
\item If \tcode{T} is a class, it has a public assignment operator whose signature is either
58-
\tcode{T\& T::operator=(const T\&)}
59-
or
60-
\tcode{T\& T::operator=(T)}
61-
\item If \tcode{T} is a class, its assignment operator, copy and default constructors,
62-
and destructor shall correspond to each other in the following sense:
63-
\begin{itemize}
64-
\item Initialization of raw storage using the copy constructor
65-
on the value of \tcode{T()}, however obtained,
66-
is semantically equivalent to value-initialization of the same raw storage.
67-
\item Initialization of raw storage using the default constructor,
68-
followed by assignment,
69-
is semantically equivalent to initialization of raw storage using the copy constructor.
70-
\item Destruction of an object,
71-
followed by initialization of its raw storage using the copy constructor,
72-
is semantically equivalent to assignment to the original object.
73-
\end{itemize}
74-
75-
\begin{note}
76-
This rule states, in part, that there shall not be any subtle differences in the semantics
77-
of initialization versus assignment.
78-
This gives an implementation
79-
considerable flexibility in how arrays are initialized.
80-
81-
\begin{example}
82-
An implementation is allowed to initialize a
83-
\tcode{valarray}
84-
by allocating storage using the
85-
\tcode{new}
86-
operator (which
87-
implies a call to the default constructor for each element) and then
88-
assigning each element its value.
89-
Or the implementation can allocate raw
90-
storage and use the copy constructor to initialize each element.
91-
\end{example}
92-
93-
If the distinction between initialization and assignment is important
94-
for a class, or if it fails to satisfy any of
95-
the other conditions listed above, the programmer should use
96-
\tcode{vector}\iref{vector} instead of
97-
\tcode{valarray}
98-
for that class.
99-
\end{note}
100-
\item If \tcode{T} is a class, it does not overload unary
101-
\tcode{operator\&}.
102-
\end{itemize}
103-
10455
\pnum
10556
If any operation on \tcode{T}
10657
throws an exception the effects are undefined.
@@ -7026,12 +6977,12 @@
70266977

70276978
\pnum
70286979
\remarks
7029-
The expression \tcode{\&a[i+j] == \&a[i] + j}
6980+
The expression \tcode{addressof(a[i+j]) == addressof(a[i]) + j}
70306981
evaluates to \tcode{true} for all \tcode{size_t i} and \tcode{size_t j}
70316982
such that \tcode{i+j < a.size()}.
70326983

70336984
\pnum
7034-
The expression \tcode{\&a[i] != \&b[j]}
6985+
The expression \tcode{addressof(a[i]) != addressof(b[j])}
70356986
evaluates to \tcode{true} for any two arrays
70366987
\tcode{a} and \tcode{b} and for any
70376988
\tcode{size_t i} and \tcode{size_t j}

source/ranges.tex

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1253,6 +1253,9 @@
12531253
\end{itemdecl}
12541254

12551255
\begin{itemdescr}
1256+
\pnum
1257+
\expects \range{i}{s} is a valid range.
1258+
12561259
\pnum
12571260
\effects Initializes \tcode{begin_} with \tcode{i} and \tcode{end_} with
12581261
\tcode{s}.
@@ -1266,7 +1269,8 @@
12661269

12671270
\begin{itemdescr}
12681271
\pnum
1269-
\expects \tcode{n == ranges::distance(i, s)}.
1272+
\expects \range{i}{s} is a valid range, and
1273+
\tcode{n == ranges::distance(i, s)}.
12701274

12711275
\pnum
12721276
\effects Initializes \tcode{begin_} with \tcode{i} and \tcode{end_} with
@@ -2387,6 +2391,8 @@
23872391
friend constexpr sentinel_t<R> end(@\placeholder{ref-view}@ r)
23882392
{ return r.end(); }
23892393
};
2394+
template<class R>
2395+
@\placeholder{ref-view}@(R&) -> @\placeholder{ref-view}@<R>;
23902396
}
23912397
\end{codeblock}
23922398

0 commit comments

Comments
 (0)