Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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.


Not the compiler but today you can already have a ClangTidy check: 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.


T && gets you the semantics you're looking for.

EDIT: Why are you booing me? I'm right.


T&& doesn't run the T destructor when it's destroyed, which is the whole point of unique_ptr.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: