56

I'm having trouble choosing between Boost.Any and Boost.Variant.
When should I use each one?

What are the advantages and disadvantages of each?

I am basically looking to store some states from external sources.

Yu Hao
  • 119,891
  • 44
  • 235
  • 294
the_drow
  • 18,571
  • 25
  • 126
  • 193
  • 8
    If you know all the possible types that data can have at compile time, then use Boost.Variant: the number of types that your data can have is finite and types are verified at compilation. If those types can be anything, then use Boost.Any. – user1284631 Oct 21 '14 at 11:17

1 Answers1

46

Have you looked at the comparison in the variant library already?

(Not sure what states from external sources are, so it's kind of hard to say what's more appropriate for you.)

jxh
  • 69,070
  • 8
  • 110
  • 193
drby
  • 2,619
  • 25
  • 26