How does an option and any of the boost libraries work internally? In the project I'm working on, I am currently using a tagged union. I want to use something else, because C ++ associations do not allow objects with constructors, destructors, or overloaded assignment operators.
I requested the size of any and option, and did some experimentation with them. On my platform, the option takes the size of its longest type plus 8 bytes: I think that it is only 8 bytes of type data, and the rest is a stored value. On the other hand, each of them takes only 8 bytes. Since I am on a 64-bit platform, I assume that any of them contains a pointer.
How does anyone know what type he holds? How does Option achieve what it does with templates? I would like to know more about these classes before using them.
c ++ unions boost-variant boost-any
salvador p Feb 14 2018-11-11T00: 00Z
source share