Arthur O'Dwyer via SG14 <sg14@lists.isocpp.org> 於 2026年8月17日週一 下午11:19寫道:
You could "eliminate" it by relaxing the guarantees you document for your wrapper. Instead of documenting that you always call the stored callable, you could document that you call "the stored callable, or a copy of it," and furthermore document that you do not make copies unless the stored callable is trivially copyable (i.e. you guarantee never to make an expensive copy).
One possible caveat with the relaxed “stored callable, or a copy of it” guarantee: if that permission applies to all trivially copyable callables, I think it can change fairly ordinary stateful-callable semantics. For example, a mutable lambda capturing an int may be trivially copyable; invoking a fresh copy each time could produce 1, 1, 1 instead of 1, 2, 3.
So I wonder if the intended relaxation should be narrower: only for the empty + trivially default-constructible + trivially copyable case used to justify this optimization, rather than for trivially copyable targets in general.
I like the underlying idea of making target identity explicitly non-semantic for that category; I just think the scope of that permission may matter.
Capita