Not a great solution, but I found that C++ move in Clang would generate a warning if the variable was used after it was moved [1]. I did not test it, and it is far inferior to Rust's model -- but at least something I think this capability in the language would be required to implement TypeStates as described in the above link. And sofar, it seems like it is only provided by Rust.[1] https://clang.llvm.org/extra/clang-tidy/checks/bugprone/use-after-move.html[2] and in MSVC https://medium.com/@nerudaj/detecting-use-after-move-in-msvc-2022-88bb202019b9https://lobste.rs/c/sh5fs7
Not a great solution, but I found that C++ move in Clang would generate a warning if the variable was used after it was moved [1]. I did not test it, and it is far inferior to Rust's model -- but at least something I think this capability in the language would be required to implement TypeStates as described in the above link. And sofar, it seems like it is only provided by Rust.[1] https://clang.llvm.org/extra/clang-tidy/checks/bugprone/use-after-move.html[2] and in MSVC https://medium.com/@nerudaj/detecting-use-after-move-in-msvc-2022-88bb202019b9https://lobste.rs/c/sh5fs7