-
Hey, We have created our own Variant which allows converting types to arbitrary other types at run time (not at compile time like std::variant). Now I’d like to deserialise a class which contains some std::strings and our variant. The type info is provided a class member.
Unfortunately
Is there any way to pass the custom data type field (m_datatype) to the Variants from_json() method? I'm using version 3.11.3 of this library. Thx for your help :) |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
It's because you're writing the datatype in
but trying to read it in
You need to either put You can use a member function in |
Beta Was this translation helpful? Give feedback.
It's because you're writing the datatype in
but trying to read it in
You need to either put
variant_datatype
in theVariant
class, or do all the loading and saving in theMyClass
functions.You can use a member function in
Variant
, but you have to create theVariant
object in theshared_ptr
, call theVariant
function yourself passing in the type, and not use thestd::shared_ptr<Variant>
built-in handling.