4 ms·
A non_null_unique_ptr<T> that is enforced at compile time would be far more valuable for me. That would mean some kind of destructive move where the compi
by jbandela1 3y ago
A
non_null_unique_ptr<T>
that is enforced at compile time would be far more valuable for me. That would mean some kind of destructive move where the compiler guarantees that you can not access a moved from object.
- fluoridation 3y agoT && gets you the semantics you're looking for. EDIT: Why are you booing me? I'm right.
- devit 3y agoT&& doesn't run the T destructor when it's destroyed, which is the whole point of unique_ptr.
- kccqzy 3y agoNot the compiler but today you can already have a ClangTidy check: https://clang.llvm.org/extra/clang-tidy/checks/bugprone/use-after-move.html https://clang.llvm.org/extra/clang-tidy/checks/bugprone/use-... If your build system respects ClangTidy checks and turn them into errors, it's effectively the same as a compiler guarantee.
- deleted 3y ago[deleted]