Skip to content

Commit 866c95d

Browse files
jensmaurerzygoloid
authored andcommitted
[std] Rephrase notes giving advice to the programmer.
Partially addresses ISO/CS 017 (C++20 DIS)
1 parent 75bea3c commit 866c95d

12 files changed

+62
-74
lines changed

source/algorithms.tex

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,11 @@
204204
\pnum
205205
\begin{note}
206206
Unless otherwise specified, algorithms that take function objects as arguments
207-
are permitted to copy those function objects freely.
208-
Programmers for whom object identity is important should consider
209-
using a wrapper class that points to a noncopied implementation object
210-
such as \tcode{reference_wrapper<T>}\iref{refwrap}, or some equivalent solution.
207+
can copy those function objects freely.
208+
If object identity is important,
209+
a wrapper class that points to a noncopied implementation object
210+
such as \tcode{reference_wrapper<T>}\iref{refwrap}, or some equivalent solution,
211+
can be used.
211212
\end{note}
212213

213214
\pnum
@@ -391,11 +392,11 @@
391392
\begin{note}
392393
This implies that user-supplied function objects cannot rely on
393394
object identity of arguments for such input sequences.
394-
Users for whom the object identity of the arguments to these function objects
395-
is important should consider using a wrapping iterator
395+
If object identity of the arguments to these function objects
396+
is important, a wrapping iterator
396397
that returns a non-copied implementation object
397-
such as \tcode{reference_wrapper<T>}\iref{refwrap}
398-
or some equivalent solution.
398+
such as \tcode{reference_wrapper<T>}\iref{refwrap},
399+
or some equivalent solution, can be used.
399400
\end{note}
400401

401402
\pnum

source/containers.tex

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -773,18 +773,16 @@
773773
\pnum
774774
\begin{note}
775775
The sequence containers
776-
offer the programmer different complexity trade-offs and should be used
777-
accordingly.
776+
offer the programmer different complexity trade-offs.
778777
\tcode{vector}
779-
is the type of sequence container that should be used by default.
778+
is appropriate in most circumstances.
780779
\tcode{array}
781-
should be used when the container has a fixed size known during translation.
780+
has a fixed size known during translation.
782781
\tcode{list} or \tcode{forward_list}
783-
should be used when there are frequent insertions and deletions from the
782+
support frequent insertions and deletions from the
784783
middle of the sequence.
785784
\tcode{deque}
786-
is the data structure of choice
787-
when most insertions and deletions take place at the beginning or at the
785+
supports efficient insertions and deletions taking place at the beginning or at the
788786
end of the sequence.
789787
When choosing a container, remember \tcode{vector} is best;
790788
leave a comment to explain if you choose from the rest!

source/diagnostics.tex

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -843,9 +843,10 @@
843843
\begin{note}
844844
\tcode{error_category} objects are
845845
passed by reference, and two such objects
846-
are equal if they have the same address. This means that applications using
847-
custom \tcode{error_category} types should create a single object of each
848-
such type.
846+
are equal if they have the same address.
847+
If there is more than a single object of a custom \tcode{error_category} type,
848+
such equality comparisons can evaluate to \tcode{false}
849+
even for objects holding the same value.
849850
\end{note}
850851

851852
\indexlibraryglobal{error_category}%

source/exceptions.tex

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -355,8 +355,8 @@
355355
\end{codeblock}
356356
\end{example}
357357
\begin{note}
358-
\setlength{\emergencystretch}{1em}
359-
Consequently, destructors should generally catch exceptions and not let them propa\-gate.
358+
If a destructor directly invoked by stack unwinding exits via an exception,
359+
\tcode{std::terminate} is invoked.
360360
\end{note}
361361

362362

source/iostreams.tex

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11153,8 +11153,8 @@
1115311153
\pnum
1115411154
\begin{note}
1115511155
The member functions of the provided stream buffer
11156-
might be called from \tcode{emit()} while a lock is held.
11157-
Care should be taken to ensure that this does not result in deadlock.
11156+
can be called from \tcode{emit()} while a lock is held,
11157+
which might result in a deadlock if used incautiously.
1115811158
\end{note}
1115911159

1116011160
\pnum
@@ -11988,7 +11988,7 @@
1198811988
the ASCII control characters (0x00 -- 0x1F) in filenames.
1198911989
\end{example}
1199011990
\begin{note}
11991-
For wide portability, users may wish to limit \grammarterm{filename}
11991+
Wider portability can be achieved by limiting \grammarterm{filename}
1199211992
characters to the POSIX Portable Filename Character Set: \\
1199311993
\tcode{A B C D E F G H I J K L M N O P Q R S T U V W X Y Z} \\
1199411994
\tcode{a b c d e f g h i j k l m n o p q r s t u v w x y z} \\
@@ -14616,11 +14616,11 @@
1461614616

1461714617
\pnum
1461814618
\begin{note}
14619-
Programs performing directory iteration may wish to test if the
14620-
path obtained by dereferencing a directory iterator actually exists. It could be
14621-
a symbolic link to a non-existent file. Programs recursively
14622-
walking directory trees for purposes of removing and renaming entries may wish
14623-
to avoid following symbolic links.
14619+
A path obtained by dereferencing a directory iterator might not actually exist;
14620+
it could be a symbolic link to a non-existent file.
14621+
Recursively walking directory trees
14622+
for purposes of removing and renaming entries
14623+
might invalidate symbolic links that are being followed.
1462414624
\end{note}
1462514625

1462614626
\pnum
@@ -15141,9 +15141,9 @@
1514115141
\pnum
1514215142
\begin{note}
1514315143
Because hardware failures, network failures, file system races\iref{fs.race.behavior},
15144-
and many other kinds of errors occur frequently in file system operations, users should be aware
15145-
that any filesystem operation function, no matter how apparently innocuous, may encounter
15146-
an error; see~\ref{fs.err.report}.
15144+
and many other kinds of errors occur frequently in file system operations,
15145+
any filesystem operation function, no matter how apparently innocuous,
15146+
can encounter an error; see~\ref{fs.err.report}.
1514715147
\end{note}
1514815148

1514915149
\rSec3[fs.op.absolute]{Absolute}
@@ -15634,7 +15634,9 @@
1563415634
\pnum
1563515635
\begin{note}
1563615636
Some operating systems require symlink creation to
15637-
identify that the link is to a directory. Portable code should use \tcode{create_directory_symlink()} to create directory symlinks rather than \tcode{create_symlink()}
15637+
identify that the link is to a directory.
15638+
Thus, \tcode{create_symlink()} (instead of \tcode{create_directory_symlink()})
15639+
cannot be used reliably to create directory symlinks.
1563815640
\end{note}
1563915641

1564015642
\pnum

source/lex.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@
184184
source of the translation units containing these definitions is required
185185
to be available.
186186
\begin{note}
187-
An implementation could encode sufficient
187+
An implementation can choose to encode sufficient
188188
information into the translated translation unit so as to ensure the
189189
source is not required here.
190190
\end{note}

source/lib-intro.tex

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3051,13 +3051,6 @@
30513051
Objects constructed by the standard library that may hold a user-supplied pointer value
30523052
or an integer of type \tcode{std::intptr_t} shall store such values in a traceable
30533053
pointer location\iref{basic.stc.dynamic.safety}.
3054-
\begin{note}
3055-
Other libraries are
3056-
strongly encouraged to do the same, since not doing so may result in accidental use of
3057-
pointers that are not safely derived. Libraries that store pointers outside the user's
3058-
address space should make it appear that they are stored and retrieved from a traceable
3059-
pointer location.
3060-
\end{note}
30613054

30623055
\rSec3[value.error.codes]{Value of error codes}
30633056

source/preprocessor.tex

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -711,11 +711,12 @@
711711

712712
\pnum
713713
\begin{note}
714-
Although an implementation can provide a mechanism for making arbitrary
715-
source files available to the \tcode{< >} search, in general
716-
programmers should use the \tcode{< >} form for headers provided
717-
with the implementation, and the \tcode{" "} form for sources
718-
outside the control of the implementation. For instance:
714+
An implementation can provide a mechanism for making arbitrary
715+
source files available to the \tcode{< >} search.
716+
However, using the \tcode{< >} form for headers provided
717+
with the implementation and the \tcode{" "} form for sources
718+
outside the control of the implementation
719+
achieves wider portability. For instance:
719720

720721
\begin{codeblock}
721722
#include <stdio.h>

source/strings.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3947,7 +3947,7 @@
39473947
\pnum
39483948
\begin{note}
39493949
The library provides implicit conversions from \tcode{const charT*} and \tcode{std::basic_string<charT, ...>} to \tcode{std::basic_string_view<charT, ...>} so that user code can accept just \tcode{std::basic_string_view<charT>} as a non-templated parameter wherever a sequence of characters is expected.
3950-
User-defined types should define their own implicit conversions to \tcode{std::basic_string_view} in order to interoperate with these functions.
3950+
User-defined types can define their own implicit conversions to \tcode{std::basic_string_view} in order to interoperate with these functions.
39513951
\end{note}
39523952

39533953
\rSec2[string.view.synop]{Header \tcode{<string_view>} synopsis}

source/support.tex

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1985,7 +1985,7 @@
19851985
A function registered via \tcode{at_quick_exit}
19861986
is invoked by the thread that calls \tcode{quick_exit},
19871987
which can be a different thread
1988-
than the one that registered it, so registered functions should not rely on the identity
1988+
than the one that registered it, so registered functions cannot rely on the identity
19891989
of objects with thread storage duration.
19901990
\end{note}
19911991
After calling registered functions, \tcode{quick_exit} shall call \tcode{_Exit(status)}.

0 commit comments

Comments
 (0)