3 ms·
It doesn't compile because the code is wrong :). I forgot remove reference for the T in the result type and in the return statement. Interestingly it compiles
by gpderetta 4y ago
It doesn't compile because the code is wrong :).
I forgot remove reference for the T in the result type and in the return statement.
Interestingly it compiles with gcc-12 for some reason.
In generic code you do want to copy if T is not movable (for example when implementing a container). The annoying thing with the existing std move is that it might or might not move from the x depending on the implementation of the sink. This implementation will always move from if x is movable.
Different tradeoffs.
Now can we make a move with your requirements (only move no copy?) I think so. Let me think about it.