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

Yes, C++ can have nonnullable smart pointers just fine if that is what you want. They will lose reset call, throw on assigning null T*, static assert on nullptr_t, require full initialization on construction, have maximum exception safety.

This could've been done since 2003 but wasn't. There are attempts to bring it into language as part of C++ Core Guidelines project.

This is possible because unlike Java and C# not everything can be null.



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

Search: