28 Nov
2005
28 Nov
'05
9:20 p.m.
If I have a boost::variant variable holding either of two types, is there a simple test to determine which type it is currently holding? Yes, I know that the object-oriented way to to avoid testing for types at runtime, but a simple if-test would work very well in the code. I've seen the static_visitor example, and that would work, but it hides the type determination and type-specific actions inside another class (or at least other functions). Yes, that would work logically, but the code needing to make this determination would be much clearer is written simply as a if-the-else based on the current type of the variant variable. Merrill