Are there easy-to-use classes or high-level libraries that allow you to interact with VARIANT in Visual C ++?
In particular, I would like to convert POD types (e.g. double , long ), strings (e.g. CString ) and containers (e.g. std::vector ) and VARIANT s. For example:
long val = 42; VARIANT var; if (ToVariant(val, var)) ...
I (naively?) Suggested that people working with COM do this all the time, so most likely there will be the only convenient library that handles all kinds of conversions. But all I could find was a motley assortment of wrapper classes, each of which converts several types:
Is there a simple way โ not before switching to Visual Basic โ to avoid this nightmare of inconvenient memory management and bitwise code VT_ARRAY | VT_I4 VT_ARRAY | VT_I4 ?
Related questions:
- CComVariant vs. _variant_t, CComBSTR vs. _bstr_t
- Convert VARIANT to ...?
- What is the best way to convert VARIANT_BOOL to a C ++ bool?
windows visual-c ++ variant
Nate kohl
source share