Re:C++ Patterns: The Badge
by jupp0r on Tuesday June 11, 2019 @10:24PM
(#20161218)
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.
[ Parent
| on HN ]
There are no comments on this comment yet.