Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 15 additions & 11 deletions source/utilities.tex
Original file line number Diff line number Diff line change
Expand Up @@ -6550,7 +6550,8 @@
The non-member \tcode{any_cast} functions provide type-safe access to the contained value.

\pnum
Implementations should avoid the use of dynamically allocated memory for a small contained value.
Implementations should nest an object within\iref{intro.object}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first "an object" seems both vague and unhelpful. Surely there is already some object nested within the any -- but the point is that there's a very specific object (namely the one that the user wants to store) should be nested within the any. The original wording was clearer about that since it at least said "contained value".

Copy link
Member Author

@eisenwave eisenwave Nov 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit confused about your comment. This is just applying the wording idiom that LWG came up with and replacing a term that is entirely undefined within the standard. That seems like a clear improvement (arguably an objective bug fix).

The part

for a small contained value

... remains unchanged, so why are you pointing out that its existence makes only the old wording clearer? Did you misread and come to the conclusion that that part is being deleted?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking at LWG4141, LWG seems comfortable with the "nested within" idiom.

@jwakely do you have an opinion on this PR?

an object of type \tcode{any} for a small contained value.
However, any such small-object optimization shall only be applied to types \tcode{T} for which
\tcode{is_nothrow_move_constructible_v<T>} is \tcode{true}.
\begin{example}
Expand Down Expand Up @@ -13181,8 +13182,9 @@

\pnum
\recommended
Implementations should avoid the use of
dynamically allocated memory for small callable objects, for example, where
Implementations should nest an object within\iref{intro.object}
a \tcode{function} for small callable objects,
for example, where
\tcode{f}'s target is an object holding only a pointer or reference
to an object and a member function pointer.
\end{itemdescr}
Expand All @@ -13202,8 +13204,9 @@

\pnum
\recommended
Implementations should avoid the use of
dynamically allocated memory for small callable objects, for example,
Implementations should nest an object within\iref{intro.object}
a \tcode{function} for small callable objects,
for example,
where \tcode{f}'s target is an object holding only a pointer or reference
to an object and a member function pointer.
\end{itemdescr}
Expand Down Expand Up @@ -13265,8 +13268,9 @@

\pnum
\recommended
Implementations should avoid the use of
dynamically allocated memory for small callable objects, for example,
Implementations should nest an object within\iref{intro.object}
a \tcode{function} for small callable objects,
for example,
where \tcode{f} refers to an object holding only a pointer or
reference to an object and a member function pointer.
\end{itemdescr}
Expand Down Expand Up @@ -13583,8 +13587,8 @@

\pnum
\recommended
Implementations should avoid the use of dynamically allocated memory
for a small contained value.
Implementations should nest an object within\iref{intro.object}
a \tcode{move_only_function} for a small contained value.
\begin{note}
Such small-object optimization can only be applied to a type \tcode{T}
for which \tcode{is_nothrow_move_constructible_v<T>} is \tcode{true}.
Expand Down Expand Up @@ -13978,8 +13982,8 @@

\pnum
\recommended
Implementations should avoid the use of dynamically allocated memory
for a small contained value.
Implementations should nest an object within\iref{intro.object}
a \tcode{copyable_function} for a small contained value.
\begin{note}
Such small-object optimization can only be applied to a type \tcode{T}
for which \tcode{is_nothrow_move_constructible_v<T>} is \tcode{true}.
Expand Down
Loading