r/cpp • • Aug 13 '26

C++26: std::indirect

https://www.sandordargo.com/blog/2026/08/12/cpp26-indirect
164 Upvotes

157 comments sorted by

View all comments

Show parent comment

3

u/germandiago Aug 14 '26

Ireally think (hope) that at some point move-after-free errors can be properly diagnosed in a big amount of cases, even if perfect destructive mode is not portable or compatible (you know, the curse/blessing of your older code working or at least incrementably adapted).

In that sense, I think this is what needs to be done if you think of the future, till that valueless_after_move() becomes 100% irrelevant.

FWIW, on my side I do not use such functions, but you need to be careful.

Use this: https://clang.llvm.org/extra/clang-tidy/checks/bugprone/use-after-move.html

In MSVC there is this (beware, this one I got it from an AI): C26800 (Use of a moved-from object

There are other things such as attribute clang::consumable, but that already requires tagging so it is heavier to handle. It is an extension, on top of that.