> If `operator T()` were prvalue qualified that would help prevent bugs, using deducing this on the object parameter:
>
> T relocating_wrapper<T>::operator T(this relocating_wrapper self) { return self.opt_.pop(); }
>
> Users would have to go to considerable lengths to misuse it and the resulting code would have a manifest use-after-move bug. Yes, there's still a double relocation but that should be elidable.
That code is already okay w/t C++23 right?
> Well, this is a good argument for `reloc` to DTRT on references: that is, `reloc r` should behave on reference typed variables r as static_cast<decltype(r)>(r) while ending the lifetime of the reference and removing it from scope.
Indeed that looks better.
> Fair enough, though I think it'd be worth mentioning in a "further directions" section.
You make me doubt. How large would that chunk of the proposal be? At minimum, I guess all template parameter pack functions that capture its parameter pack with a forwarding reference will need to be reconsidered... to be eventually replaced by the decltype(auto)... syntax, plus changing std::forward to reloc. That would also open the door to the non-variadic syntax: vector<T>::push_back(decltype(auto) x). And what about decltype(Concept)... syntax?
Also, another technicality now that I am in the writing of the proposal, is it okay to consider reloc as a new unary operator, or does it need to be a keyword? I have heard here and there that new keywords are difficult to be approved, that's why I am asking. Personally I don't see why reloc would need to be a keyword.