Re:Learning that you can use unions in C for grouping things...
by comex on Sunday August 01, 2021 @12:08PM
(#28027319)
C++ namespaces are unrelated to this. They don’t accomplish the same thing.
[ Parent
| on HN ]
Re:Learning that you can use unions in C for grouping things...
by pjmlp on Sunday August 01, 2021 @12:22PM
(#28027436)
The goal of inline namespaces is exactly to allow for migrating libraries across versions.
Re:Learning that you can use unions in C for grouping things...
by comex on Sunday August 01, 2021 @11:13PM
(#28032516)
That's nice, but the blog post doesn't say anything about migrating libraries across versions? Looking at the comment thread, I see tialaramex's sibling comment suggested the blog post was about migration, but it's not.
I suppose migration is another possible use case for the union trick, and for that case C++ inline namespaces can be used as part of an implementation that achieves a broadly similar goal, but in a completely different way. As tialaramex notes, with inline namespaces you still end up with two different types.