What are the differences between std::variant and boost::variant?

Assignment/emplacement behavior: boost::variant may allocate memory when performing assignment into a live variant. There are a number of rules that govern when this can happen, so whether a boost::variant will allocate memory depends on the Ts it is instantiated with. std::variant will never dynamically allocate memory. However, as a concession to the complex rules of … Read more

How do boost::variant and boost::any work?

If you read the boost::any documentation they provide the source for the idea: http://www.two-sdg.demon.co.uk/curbralan/papers/ValuedConversions.pdf It’s basic information hiding, an essential C++ skill to have. Learn it! Since the highest voted answer here is totally incorrect, and I have my doubts that people will actually go look at the source to verify that fact, here’s a … Read more