You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The following snippet shows a simplified version of indirect and a (potentially contrived) scenario, where the variadic constructor might be too greedy:
In the line indirect<Evil> i2(i1); we don't call the copy constructor of indirect (as I would expect as a user of indirect), but we call the variadic constructor as it is a better match. Note that it is only a better match as i1 is non-const. For a const indirect<Evil> the copy-constructor would still be called.
The first question is whether you all agree with me that indirect<Evil> i2(i1); should indeed call the copy-constructor or if you think that it is intentional design that it calls the variadic constructor. And if you agree, I think a fix would be to constraint the variadic constructor further. Something like:
In PR #128 we removed the parameter
std::in_place_t
from the variadic constructor ofindirect
:The following snippet shows a simplified version of
indirect
and a (potentially contrived) scenario, where the variadic constructor might be too greedy:https://compiler-explorer.com/z/KWvzcnjY9
In the line
indirect<Evil> i2(i1);
we don't call the copy constructor ofindirect
(as I would expect as a user ofindirect
), but we call the variadic constructor as it is a better match. Note that it is only a better match asi1
is non-const. For aconst indirect<Evil>
the copy-constructor would still be called.The first question is whether you all agree with me that
indirect<Evil> i2(i1);
should indeed call the copy-constructor or if you think that it is intentional design that it calls the variadic constructor. And if you agree, I think a fix would be to constraint the variadic constructor further. Something like:In prose: If the pack
Ts
consists of only one typeU
, make sure thatU
is notindirect&
.The text was updated successfully, but these errors were encountered: