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

This is especially helpful in conjunction with private constructors and make_shared or make_unique. You cannot even friend make_shared because of namespace aliasing in standard libraries, but shared_from_this can make improperly allocated objects error at runtime. Private badges/tokens solve that problem by allowing public constructors requiring a parameter value of the badge/token type that has limited visibility, but can be constructed inside a factory and passed to make_shared.


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

Search: