Skip to content

Commit 6a86bab

Browse files
committed
[std] Move implementation recommendations to outside notes
and prefix them with "Recommended practice"
1 parent e811d57 commit 6a86bab

File tree

11 files changed

+60
-57
lines changed

11 files changed

+60
-57
lines changed

source/atomics.tex

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -634,12 +634,14 @@
634634
block\iref{intro.progress}.
635635

636636
\pnum
637+
\recommended
637638
Operations that are lock-free should also be address-free.
639+
The implementation should not depend on any per-process state.
638640
\begin{note}
639641
That is,
640642
atomic operations on the same memory location via two different addresses will
641-
communicate atomically. The implementation should not depend on any
642-
per-process state. This restriction enables communication by memory that is
643+
communicate atomically.
644+
This restriction enables communication by memory that is
643645
mapped into a process more than once and by memory that is shared between two
644646
processes.
645647
\end{note}

source/basic.tex

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6673,9 +6673,10 @@
66736673
even if it is not itself odr-used~(\ref{basic.def.odr}, \ref{basic.stc.static}).}
66746674
It is \impldef{threads and program points at which deferred dynamic initialization is performed}
66756675
in which threads and at which points in the program such deferred dynamic initialization occurs.
6676-
\begin{note}
6677-
Such points should be chosen in a way that allows the programmer to avoid deadlocks.
6678-
\end{note}
6676+
6677+
\recommended
6678+
An implementation should choose such points in a way
6679+
that allows the programmer to avoid deadlocks.
66796680
\begin{example}
66806681
\begin{codeblock}
66816682
// - File 1 -

source/expressions.tex

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7266,14 +7266,16 @@
72667266
\end{example}
72677267

72687268
\pnum
7269+
\recommended
7270+
Implementations should provide consistent results of floating-point evaluations,
7271+
irrespective of whether the evaluation is performed
7272+
during translation or during program execution.
72697273
\begin{note}
72707274
Since this document
72717275
imposes no restrictions on the accuracy of floating-point operations, it is unspecified whether the
72727276
evaluation of a floating-point expression during translation yields the same result as the
72737277
evaluation of the same expression (or the same operations on the same values) during program
7274-
execution.\footnote{Nonetheless, implementations should provide consistent results,
7275-
irrespective of whether the evaluation was performed during translation and/or during program
7276-
execution.}
7278+
execution.
72777279
\begin{example}
72787280
\begin{codeblock}
72797281
bool f() {

source/future.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -570,7 +570,7 @@
570570
\begin{itemize}
571571
\item
572572
\tcode{allocated}, set when a dynamic array object has been
573-
allocated, and hence should be freed by the destructor for the
573+
allocated, and hence to be freed by the destructor for the
574574
\tcode{strstreambuf} object;
575575
\item
576576
\tcode{constant}, set when the array object has

source/iostreams.tex

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11147,8 +11147,8 @@
1114711147
\pnum
1114811148
\begin{note}
1114911149
The member functions of the provided stream buffer
11150-
might be called from \tcode{emit()} while a lock is held.
11151-
Care should be taken to ensure that this does not result in deadlock.
11150+
can called from \tcode{emit()} while a lock is held,
11151+
which might result in a deadlock.
1115211152
\end{note}
1115311153

1115411154
\pnum
@@ -13719,10 +13719,10 @@
1371913719
\impldef{interpretation of the path character sequence with format \tcode{path::auto_format}}.
1372013720
The implementation may inspect the content of the character sequence to
1372113721
determine the format.
13722-
\begin{note}
13722+
13723+
\recommended
1372313724
For POSIX-based systems, native and generic formats are equivalent
1372413725
and the character sequence should always be interpreted in the same way.
13725-
\end{note}
1372613726
\\\rowsep
1372713727
\end{floattable}
1372813728

source/iterators.tex

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1435,11 +1435,15 @@
14351435
\end{itemize}
14361436

14371437
\pnum
1438+
\recommended
1439+
The implementaton of an algorithm on a weakly incrementable type
1440+
should never attempt to pass through the same incrementable value twice;
1441+
such an algorithm should be a single-pass algorithm.
14381442
\begin{note}
14391443
For \libconcept{weakly_incrementable} types, \tcode{a} equals \tcode{b} does not imply that \tcode{++a}
14401444
equals \tcode{++b}. (Equality does not guarantee the substitution property or referential
1441-
transparency.) Algorithms on weakly incrementable types should never attempt to pass
1442-
through the same incrementable value twice. They should be single-pass algorithms. These algorithms
1445+
transparency.)
1446+
Such algorithms
14431447
can be used with istreams as the source of the input data through the \tcode{istream_iterator} class
14441448
template.
14451449
\end{note}
@@ -1667,10 +1671,10 @@
16671671
\end{codeblock}
16681672

16691673
\pnum
1670-
\begin{note}
1671-
Algorithms on output iterators should never attempt to pass through the same iterator twice.
1672-
They should be single-pass algorithms.
1673-
\end{note}
1674+
\recommended
1675+
The implementation of an algorithm on output iterators
1676+
should never attempt to pass through the same iterator twice;
1677+
such an algorithm should be a single-pass algorithm.
16741678

16751679
\rSec3[iterator.concept.forward]{Concept \cname{forward_iterator}}
16761680

@@ -2013,18 +2017,15 @@
20132017
\end{libreqtab4b}
20142018

20152019
\pnum
2020+
\recommended
2021+
The implementation of an algorithm on input iterators
2022+
should never attempt to pass through the same iterator twice;
2023+
such an algorithm should be a single pass algorithm.
20162024
\begin{note}
2017-
For input iterators,
2018-
\tcode{a == b}
2019-
does not imply
2020-
\tcode{++a == ++b}.
2025+
For input iterators, \tcode{a == b} does not imply \tcode{++a == ++b}.
20212026
(Equality does not guarantee the substitution property or referential transparency.)
2022-
Algorithms on input iterators should never attempt to pass through the same iterator twice.
2023-
They should be
2024-
\term{single pass}
2025-
algorithms.
20262027
Value type \tcode{T} is not required to be a \oldconcept{CopyAssignable} type (\tref{cpp17.copyassignable}).
2027-
These algorithms can be used with istreams as the source of the input data through the
2028+
Such an algorithm can be used with istreams as the source of the input data through the
20282029
\tcode{istream_iterator}
20292030
class template.
20302031
\end{note}
@@ -2074,13 +2075,14 @@
20742075
\end{libreqtab4b}
20752076

20762077
\pnum
2078+
\recommended
2079+
The implementation of an algorithm on output iterators
2080+
should never attempt to pass through the same iterator twice;
2081+
such an algorithm should be a single-pass algorithm.
20772082
\begin{note}
2078-
The only valid use of an
2079-
\tcode{operator*}
2083+
The only valid use of an \tcode{operator*}
20802084
is on the left side of the assignment statement.
20812085
Assignment through the same value of the iterator happens only once.
2082-
Algorithms on output iterators should never attempt to pass through the same iterator twice.
2083-
They should be single-pass algorithms.
20842086
Equality and inequality might not be defined.
20852087
\end{note}
20862088

source/lib-intro.tex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1666,11 +1666,9 @@
16661666
Thus all evaluations of the expression \tcode{h(k)} with the
16671667
same value for \tcode{k} yield the same result for a given execution of the program.
16681668
\end{note}
1669-
\begin{note}
1670-
For two different
1669+
For two different
16711670
values \tcode{t1} and \tcode{t2}, the probability that \tcode{h(t1)} and \tcode{h(t2)}
16721671
compare equal should be very small, approaching \tcode{1.0 / numeric_limits<size_t>::max()}.
1673-
\end{note}
16741672
\\ \rowsep
16751673
\tcode{h(u)} &
16761674
\tcode{size_t} &

source/ranges.tex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -992,8 +992,7 @@
992992
\tcode{ranges::begin} and \tcode{ranges::end}.
993993
Since \tcode{ranges::begin} is not required to be equality-preserving
994994
when the return type does not model \libconcept{forward_iterator}, repeated calls
995-
might not return equal values or might not be well-defined;
996-
\tcode{ranges::begin} should be called at most once for such a range.
995+
might not return equal values or might not be well-defined.
997996
\end{note}
998997
\end{itemdescr}
999998

source/support.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5409,8 +5409,8 @@
54095409
\pnum
54105410
\begin{note}
54115411
The types \tcode{suspend_never} and \tcode{suspend_always} can be used
5412-
to indicate that an \grammarterm{await-expression} should either never
5413-
suspend or always suspend, and in either case not produce a value.
5412+
to indicate that an \grammarterm{await-expression} either never
5413+
suspends or always suspends, and in either case does not produce a value.
54145414
\end{note}
54155415

54165416
\rSec1[support.runtime]{Other runtime support}

source/threads.tex

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -126,10 +126,10 @@
126126
An implementation returns from such a timeout at any point from the time specified above to
127127
the time it would return from a steady-clock relative timeout on the difference between $C_t$
128128
and the time point of the call to the \tcode{_until} function.
129-
\begin{note}
129+
130+
\recommended
130131
Implementations
131132
should decrease the duration of the wait when the clock is adjusted forwards.
132-
\end{note}
133133

134134
\pnum
135135
\begin{note}
@@ -6449,10 +6449,9 @@
64496449
\begin{note}
64506450
It is valid to move from a future object for which \tcode{valid() == false}.
64516451
\end{note}
6452-
\begin{note}
6452+
\recommended
64536453
Implementations should detect this case and throw an object of type
64546454
\tcode{future_error} with an error condition of \tcode{future_errc::no_state}.
6455-
\end{note}
64566455

64576456
\indexlibraryglobal{future}%
64586457
\begin{codeblock}
@@ -6749,10 +6748,9 @@
67496748
It is valid to copy or move from a \tcode{shared_future}
67506749
object for which \tcode{valid()} is \tcode{false}.
67516750
\end{note}
6752-
\begin{note}
6751+
\recommended
67536752
Implementations should detect this case and throw an object of type
67546753
\tcode{future_error} with an error condition of \tcode{future_errc::no_state}.
6755-
\end{note}
67566754

67576755
\indexlibraryglobal{shared_future}%
67586756
\begin{codeblock}
@@ -7144,12 +7142,12 @@
71447142
deferred function in the thread that called the waiting function.
71457143
Once evaluation of \tcode{invoke(std::move(g), std::move(xyz))} begins, the function is no longer
71467144
considered deferred.
7147-
\begin{note}
7145+
7146+
\recommended
71487147
If this policy is specified together with other policies, such as when using a
71497148
\tcode{policy} value of \tcode{launch::async | launch::deferred}, implementations should defer
71507149
invocation or the selection of the policy when no more concurrency can be effectively
71517150
exploited.
7152-
\end{note}
71537151

71547152
\item
71557153
If no value is set in the launch policy, or a value is set that is neither specified

source/utilities.tex

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15164,12 +15164,13 @@
1516415164
a specialization of \tcode{reference_wrapper} or
1516515165
a function pointer. Otherwise, may throw \tcode{bad_alloc}
1516615166
or any exception thrown by the copy constructor of the stored callable object.
15167-
\begin{note}
15167+
15168+
\pnum
15169+
\recommended
1516815170
Implementations should avoid the use of
1516915171
dynamically allocated memory for small callable objects, for example, where
1517015172
\tcode{f}'s target is an object holding only a pointer or reference
1517115173
to an object and a member function pointer.
15172-
\end{note}
1517315174
\end{itemdescr}
1517415175

1517515176
\indexlibraryctor{function}%
@@ -15186,12 +15187,11 @@
1518615187
\tcode{f} is in a valid state with an unspecified value.
1518715188

1518815189
\pnum
15189-
\begin{note}
15190+
\recommended
1519015191
Implementations should avoid the use of
1519115192
dynamically allocated memory for small callable objects, for example,
1519215193
where \tcode{f}'s target is an object holding only a pointer or reference
1519315194
to an object and a member function pointer.
15194-
\end{note}
1519515195
\end{itemdescr}
1519615196

1519715197
\indexlibraryctor{function}%
@@ -15222,19 +15222,20 @@
1522215222
\pnum
1522315223
Otherwise, \tcode{*this} targets a copy of \tcode{f}
1522415224
initialized with \tcode{std::move(f)}.
15225-
\begin{note}
15226-
Implementations should avoid the use of
15227-
dynamically allocated memory for small callable objects, for example,
15228-
where \tcode{f} is an object holding only a pointer or
15229-
reference to an object and a member function pointer.
15230-
\end{note}
1523115225

1523215226
\pnum
1523315227
\throws
1523415228
Nothing if \tcode{f} is
1523515229
a specialization of \tcode{reference_wrapper} or
1523615230
a function pointer. Otherwise, may throw \tcode{bad_alloc}
1523715231
or any exception thrown by \tcode{F}'s copy or move constructor.
15232+
15233+
\pnum
15234+
\recommended
15235+
Implementations should avoid the use of
15236+
dynamically allocated memory for small callable objects, for example,
15237+
where \tcode{f} is an object holding only a pointer or
15238+
reference to an object and a member function pointer.
1523815239
\end{itemdescr}
1523915240

1524015241

0 commit comments

Comments
 (0)