Date: Mon, 12 Feb 2024 23:50:15 +0100
On Mon, Feb 12, 2024 at 4:30 PM Nicolas Fleury <nidoizo_at_[hidden] <mailto:nidoizo_at_[hidden]>> wrote:
> Note that support of [[asserts_rvo]] on the declaration is important to me, as the point is to add as a guideline for functions returning by copy in huge productions, and being able to call a function with trust regarding no-copy without needing to look at its implementation. This is really the most important to me, this is the kind of information I would expect in Intellisense.
I'm not seeing why the tiny bit of information about whether
creating the return object had (e.g.) an extra move or not
would be sufficiently interesting to the caller to announce
that in the declaration. A lot of other performance-relevant
details (such as whether additional copies are made in the
implementation way before the return value is created,
or whether an inefficient O(n^2) algorithm is used where
O(n) would be possible) are not announced in the declaration,
either.
There will always be properties of a function that cannot
be expressed in declarations alone, yet are important to
some fraction of the callers.
In contrast, for someone actively striving to provide a
high-performance implementation, it might very well be
useful to assert (similar to static_assert) that NRVO
is actually applied to particular "return" statement, and
prefer an error over a silent performance regression.
Jens
> Note that support of [[asserts_rvo]] on the declaration is important to me, as the point is to add as a guideline for functions returning by copy in huge productions, and being able to call a function with trust regarding no-copy without needing to look at its implementation. This is really the most important to me, this is the kind of information I would expect in Intellisense.
I'm not seeing why the tiny bit of information about whether
creating the return object had (e.g.) an extra move or not
would be sufficiently interesting to the caller to announce
that in the declaration. A lot of other performance-relevant
details (such as whether additional copies are made in the
implementation way before the return value is created,
or whether an inefficient O(n^2) algorithm is used where
O(n) would be possible) are not announced in the declaration,
either.
There will always be properties of a function that cannot
be expressed in declarations alone, yet are important to
some fraction of the callers.
In contrast, for someone actively striving to provide a
high-performance implementation, it might very well be
useful to assert (similar to static_assert) that NRVO
is actually applied to particular "return" statement, and
prefer an error over a silent performance regression.
Jens
Received on 2024-02-12 22:50:22