
12 Feb
2009
12 Feb
'09
10:30 a.m.
Gokulakannan Somasundaram wrote:
Thanks for pointing me to Boost.Variant. But let me just try to clarify my understanding on Boost Variant. It is a kind of union data type, where we store the data and its type together. Whenever we retrieve the data, it does a switch-case lookup and type-casts the data to that type. In my opinion, the switch-case is equivalent to a virtual table lookup. They should be having more or less the same runtime penalty.
Indeed. A switch-case is actually faster than a virtual table lookup, however.