Re:C++ Patterns: The Badge
by jhalstead on Tuesday June 11, 2019 @06:43PM
(#20160178)
This reminds me of the Passkey idiom: https://arne-mertz.de/2016/10/passkey-idiom/
[ Parent
| on HN ]
Oh wow, that's so similar! So similar in fact, that I must have seen this blog post at some point and internalized the idea :)
The improvement that Badge<T> makes is the <T> part; you don't need to look up the PassKey declaration to see who can construct PassKeys, it's encoded right there in the type instead.
I do like how PassKey makes the copy ctor private. I think we can improve on that and delete both the copy and move ctors in Badge.