c++ - boost::Variant usage -


I am developing the GMI application through wxWidgets. It has 2 parts - GUI part and "Logic" portion. I want to be completely independent on the rigid part wxWidgets. But a component in the GUI is returning to the wxVariant and I need to use it in the logic part.

Therefore, to promote the "convertible" type :: Variable

The work of wxVariant works like this:

  wxVariant v ("37 "); Int i = v.GetInteger (); // i == 37   

So I'm thinking like something

  string s = methodReturningWxVariant (). GetString (); Promotion: Version BV (S); // Code later eg BV.GetInt (); BV.GetBool ();   

Is it possible to use this promotion: version (or Promotion :: any)?

Simple answer? No. You can not convert through strings, it is a loss of information and boost :: variant does not attempt to parse the strings automatically.

I do not know wxVariant provides a clear conversion ??? In general, converting to boost :: variant without testing special cases can be difficult.

Comments