F
Flash Gordon
ok here is the problem: I need to have a map of variants that actually
vary *only* at initialization, i.e.
vmap["foo"] = variant<int, float>(1); // constructed as int
vmap["bar"] = variant<int, float>(2.34f); // constructed as float
vmap["foo"] = 10 * vmap["bar"]; // floating point multiplication, then
23.4f rounded to int 23
vmap["bar"] = vmap["foo"] / 2; // integer division, then 10 converted
to 10.0f
so essentially, I need a heterogenous map of primitive types
what would be the best way to implement this? I looked at
boost::variant but it doesn't seem to suit me
vary *only* at initialization, i.e.
vmap["foo"] = variant<int, float>(1); // constructed as int
vmap["bar"] = variant<int, float>(2.34f); // constructed as float
vmap["foo"] = 10 * vmap["bar"]; // floating point multiplication, then
23.4f rounded to int 23
vmap["bar"] = vmap["foo"] / 2; // integer division, then 10 converted
to 10.0f
so essentially, I need a heterogenous map of primitive types
what would be the best way to implement this? I looked at
boost::variant but it doesn't seem to suit me