Skip to content

Commit 75bea3c

Browse files
jensmaurerzygoloid
authored andcommitted
[std] Move implementation recommendations to outside notes
and prefix them with "Recommended practice" Partially addresses ISO/CS 017 (C++20 DIS)
1 parent 84f8f1a commit 75bea3c

12 files changed

+78
-65
lines changed

source/atomics.tex

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -636,12 +636,15 @@
636636
block\iref{intro.progress}.
637637

638638
\pnum
639-
Operations that are lock-free should also be address-free.
640-
\begin{note}
639+
\recommended
640+
Operations that are lock-free should also be address-free%
641+
\footnote{
641642
That is,
642643
atomic operations on the same memory location via two different addresses will
643-
communicate atomically. The implementation should not depend on any
644-
per-process state. This restriction enables communication by memory that is
644+
communicate atomically.}.
645+
The implementation of these operations should not depend on any per-process state.
646+
\begin{note}
647+
This restriction enables communication by memory that is
645648
mapped into a process more than once and by memory that is shared between two
646649
processes.
647650
\end{note}

source/basic.tex

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6243,10 +6243,10 @@
62436243
by repeatedly stealing a cache line
62446244
for unrelated purposes
62456245
between load-locked and store-conditional instructions.
6246-
Implementations should ensure
6247-
that such effects cannot indefinitely delay progress
6246+
For implementations that follow this recommendation and
6247+
ensure that such effects cannot indefinitely delay progress
62486248
under expected operating conditions,
6249-
and that such anomalies
6249+
such anomalies
62506250
can therefore safely be ignored by programmers.
62516251
Outside this document,
62526252
this property is sometimes termed lock-free.
@@ -6663,9 +6663,10 @@
66636663
even if it is not itself odr-used~(\ref{basic.def.odr}, \ref{basic.stc.static}).}
66646664
It is \impldef{threads and program points at which deferred dynamic initialization is performed}
66656665
in which threads and at which points in the program such deferred dynamic initialization occurs.
6666-
\begin{note}
6667-
Such points should be chosen in a way that allows the programmer to avoid deadlocks.
6668-
\end{note}
6666+
6667+
\recommended
6668+
An implementation should choose such points in a way
6669+
that allows the programmer to avoid deadlocks.
66696670
\begin{example}
66706671
\begin{codeblock}
66716672
// - File 1 -

source/expressions.tex

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

72737273
\pnum
7274+
\recommended
7275+
Implementations should provide consistent results of floating-point evaluations,
7276+
irrespective of whether the evaluation is performed
7277+
during translation or during program execution.
72747278
\begin{note}
72757279
Since this document
72767280
imposes no restrictions on the accuracy of floating-point operations, it is unspecified whether the
72777281
evaluation of a floating-point expression during translation yields the same result as the
72787282
evaluation of the same expression (or the same operations on the same values) during program
7279-
execution.\footnote{Nonetheless, implementations should provide consistent results,
7280-
irrespective of whether the evaluation was performed during translation and/or during program
7281-
execution.}
7283+
execution.
72827284
\begin{example}
72837285
\begin{codeblock}
72847286
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 will 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: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -430,8 +430,7 @@
430430
The objects are constructed and the associations are established at some
431431
time prior to or during the first time an object of class
432432
\tcode{ios_base::Init} is constructed, and in any case before the body
433-
of \tcode{main}\iref{basic.start.main} begins execution.\footnote{If it is possible for them to do so, implementations should
434-
initialize the objects earlier than required.}
433+
of \tcode{main}\iref{basic.start.main} begins execution.
435434
The objects are not destroyed during program execution.\footnote{Constructors and destructors for objects with
436435
static storage duration can
437436
access these objects to read input from
@@ -441,6 +440,13 @@
441440
or
442441
\tcode{stderr}.
443442
}
443+
444+
\pnum
445+
\recommended
446+
If it is possible for them to do so, implementations should
447+
initialize the objects earlier than required.
448+
449+
\pnum
444450
The results of including \libheader{iostream} in a translation unit shall be as if
445451
\libheader{iostream} defined an instance of \tcode{ios_base::Init} with static
446452
storage duration.
@@ -13707,10 +13713,10 @@
1370713713
\impldef{interpretation of the path character sequence with format \tcode{path::auto_format}}.
1370813714
The implementation may inspect the content of the character sequence to
1370913715
determine the format.
13710-
\begin{note}
13716+
13717+
\recommended
1371113718
For POSIX-based systems, native and generic formats are equivalent
1371213719
and the character sequence should always be interpreted in the same way.
13713-
\end{note}
1371413720
\\
1371513721
\end{floattable}
1371613722

source/iterators.tex

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

14331433
\pnum
1434+
\recommended
1435+
The implementaton of an algorithm on a weakly incrementable type
1436+
should never attempt to pass through the same incrementable value twice;
1437+
such an algorithm should be a single-pass algorithm.
14341438
\begin{note}
14351439
For \libconcept{weakly_incrementable} types, \tcode{a} equals \tcode{b} does not imply that \tcode{++a}
14361440
equals \tcode{++b}. (Equality does not guarantee the substitution property or referential
1437-
transparency.) Algorithms on weakly incrementable types should never attempt to pass
1438-
through the same incrementable value twice. They should be single-pass algorithms. These algorithms
1441+
transparency.)
1442+
Such algorithms
14391443
can be used with istreams as the source of the input data through the \tcode{istream_iterator} class
14401444
template.
14411445
\end{note}
@@ -1663,10 +1667,10 @@
16631667
\end{codeblock}
16641668

16651669
\pnum
1666-
\begin{note}
1667-
Algorithms on output iterators should never attempt to pass through the same iterator twice.
1668-
They should be single-pass algorithms.
1669-
\end{note}
1670+
\recommended
1671+
The implementation of an algorithm on output iterators
1672+
should never attempt to pass through the same iterator twice;
1673+
such an algorithm should be a single-pass algorithm.
16701674

16711675
\rSec3[iterator.concept.forward]{Concept \cname{forward_iterator}}
16721676

@@ -2009,18 +2013,15 @@
20092013
\end{libreqtab4b}
20102014

20112015
\pnum
2016+
\recommended
2017+
The implementation of an algorithm on input iterators
2018+
should never attempt to pass through the same iterator twice;
2019+
such an algorithm should be a single pass algorithm.
20122020
\begin{note}
2013-
For input iterators,
2014-
\tcode{a == b}
2015-
does not imply
2016-
\tcode{++a == ++b}.
2021+
For input iterators, \tcode{a == b} does not imply \tcode{++a == ++b}.
20172022
(Equality does not guarantee the substitution property or referential transparency.)
2018-
Algorithms on input iterators should never attempt to pass through the same iterator twice.
2019-
They should be
2020-
\term{single pass}
2021-
algorithms.
20222023
Value type \tcode{T} is not required to be a \oldconcept{CopyAssignable} type (\tref{cpp17.copyassignable}).
2023-
These algorithms can be used with istreams as the source of the input data through the
2024+
Such an algorithm can be used with istreams as the source of the input data through the
20242025
\tcode{istream_iterator}
20252026
class template.
20262027
\end{note}
@@ -2070,13 +2071,14 @@
20702071
\end{libreqtab4b}
20712072

20722073
\pnum
2074+
\recommended
2075+
The implementation of an algorithm on output iterators
2076+
should never attempt to pass through the same iterator twice;
2077+
such an algorithm should be a single-pass algorithm.
20732078
\begin{note}
2074-
The only valid use of an
2075-
\tcode{operator*}
2079+
The only valid use of an \tcode{operator*}
20762080
is on the left side of the assignment statement.
20772081
Assignment through the same value of the iterator happens only once.
2078-
Algorithms on output iterators should never attempt to pass through the same iterator twice.
2079-
They should be single-pass algorithms.
20802082
Equality and inequality might not be defined.
20812083
\end{note}
20822084

source/lib-intro.tex

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1668,11 +1668,9 @@
16681668
Thus all evaluations of the expression \tcode{h(k)} with the
16691669
same value for \tcode{k} yield the same result for a given execution of the program.
16701670
\end{note}
1671-
\begin{note}
1672-
For two different
1671+
For two different
16731672
values \tcode{t1} and \tcode{t2}, the probability that \tcode{h(t1)} and \tcode{h(t2)}
16741673
compare equal should be very small, approaching \tcode{1.0 / numeric_limits<size_t>::max()}.
1675-
\end{note}
16761674
\\ \rowsep
16771675
\tcode{h(u)} &
16781676
\tcode{size_t} &

source/locales.tex

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3448,11 +3448,12 @@
34483448
on any other string for which
34493449
\tcode{do_compare()}
34503450
returns 0 (equal) when passed the two strings.
3451-
\begin{note}
3451+
3452+
\pnum
3453+
\recommended
34523454
The probability that the result equals that for another string which does
34533455
not compare equal should be very small, approaching
34543456
\tcode{(1.0/numeric_limits<unsigned long>::max())}.
3455-
\end{note}
34563457
\end{itemdescr}
34573458

34583459
\rSec3[locale.collate.byname]{Class template \tcode{collate_byname}}

source/ranges.tex

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1017,8 +1017,7 @@
10171017
\tcode{ranges::begin} and \tcode{ranges::end}.
10181018
Since \tcode{ranges::begin} is not required to be equality-preserving
10191019
when the return type does not model \libconcept{forward_iterator}, repeated calls
1020-
might not return equal values or might not be well-defined;
1021-
\tcode{ranges::begin} should be called at most once for such a range.
1020+
might not return equal values or might not be well-defined.
10221021
\end{note}
10231022
\end{itemdescr}
10241023

source/support.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5396,8 +5396,8 @@
53965396
\pnum
53975397
\begin{note}
53985398
The types \tcode{suspend_never} and \tcode{suspend_always} can be used
5399-
to indicate that an \grammarterm{await-expression} should either never
5400-
suspend or always suspend, and in either case not produce a value.
5399+
to indicate that an \grammarterm{await-expression} either never
5400+
suspends or always suspends, and in either case does not produce a value.
54015401
\end{note}
54025402

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

source/threads.tex

Lines changed: 8 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}
@@ -6447,10 +6447,10 @@
64476447
\begin{note}
64486448
It is valid to move from a future object for which \tcode{valid() == false}.
64496449
\end{note}
6450-
\begin{note}
6450+
6451+
\recommended
64516452
Implementations should detect this case and throw an object of type
64526453
\tcode{future_error} with an error condition of \tcode{future_errc::no_state}.
6453-
\end{note}
64546454

64556455
\indexlibraryglobal{future}%
64566456
\begin{codeblock}
@@ -6747,10 +6747,10 @@
67476747
It is valid to copy or move from a \tcode{shared_future}
67486748
object for which \tcode{valid()} is \tcode{false}.
67496749
\end{note}
6750-
\begin{note}
6750+
6751+
\recommended
67516752
Implementations should detect this case and throw an object of type
67526753
\tcode{future_error} with an error condition of \tcode{future_errc::no_state}.
6753-
\end{note}
67546754

67556755
\indexlibraryglobal{shared_future}%
67566756
\begin{codeblock}
@@ -7142,12 +7142,12 @@
71427142
deferred function in the thread that called the waiting function.
71437143
Once evaluation of \tcode{invoke(std::move(g), std::move(xyz))} begins, the function is no longer
71447144
considered deferred.
7145-
\begin{note}
7145+
7146+
\recommended
71467147
If this policy is specified together with other policies, such as when using a
71477148
\tcode{policy} value of \tcode{launch::async | launch::deferred}, implementations should defer
71487149
invocation or the selection of the policy when no more concurrency can be effectively
71497150
exploited.
7150-
\end{note}
71517151

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

source/utilities.tex

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7467,7 +7467,7 @@
74677467
live until the corresponding \tcode{undeclare_no_pointers()} call.
74687468
\begin{note}
74697469
In a garbage-collecting implementation, the fact that a region in an object is
7470-
registered with \tcode{declare_no_pointers()} should not prevent the object from
7470+
registered with \tcode{declare_no_pointers()} does not prevent the object from
74717471
being collected.
74727472
\end{note}
74737473

@@ -15170,12 +15170,13 @@
1517015170
a specialization of \tcode{reference_wrapper} or
1517115171
a function pointer. Otherwise, may throw \tcode{bad_alloc}
1517215172
or any exception thrown by the copy constructor of the stored callable object.
15173-
\begin{note}
15173+
15174+
\pnum
15175+
\recommended
1517415176
Implementations should avoid the use of
1517515177
dynamically allocated memory for small callable objects, for example, where
1517615178
\tcode{f}'s target is an object holding only a pointer or reference
1517715179
to an object and a member function pointer.
15178-
\end{note}
1517915180
\end{itemdescr}
1518015181

1518115182
\indexlibraryctor{function}%
@@ -15192,12 +15193,11 @@
1519215193
\tcode{f} is in a valid state with an unspecified value.
1519315194

1519415195
\pnum
15195-
\begin{note}
15196+
\recommended
1519615197
Implementations should avoid the use of
1519715198
dynamically allocated memory for small callable objects, for example,
1519815199
where \tcode{f}'s target is an object holding only a pointer or reference
1519915200
to an object and a member function pointer.
15200-
\end{note}
1520115201
\end{itemdescr}
1520215202

1520315203
\indexlibraryctor{function}%
@@ -15228,19 +15228,20 @@
1522815228
\pnum
1522915229
Otherwise, \tcode{*this} targets a copy of \tcode{f}
1523015230
initialized with \tcode{std::move(f)}.
15231-
\begin{note}
15232-
Implementations should avoid the use of
15233-
dynamically allocated memory for small callable objects, for example,
15234-
where \tcode{f} is an object holding only a pointer or
15235-
reference to an object and a member function pointer.
15236-
\end{note}
1523715231

1523815232
\pnum
1523915233
\throws
1524015234
Nothing if \tcode{f} is
1524115235
a specialization of \tcode{reference_wrapper} or
1524215236
a function pointer. Otherwise, may throw \tcode{bad_alloc}
1524315237
or any exception thrown by \tcode{F}'s copy or move constructor.
15238+
15239+
\pnum
15240+
\recommended
15241+
Implementations should avoid the use of
15242+
dynamically allocated memory for small callable objects, for example,
15243+
where \tcode{f} is an object holding only a pointer or
15244+
reference to an object and a member function pointer.
1524415245
\end{itemdescr}
1524515246

1524615247

0 commit comments

Comments
 (0)