Hi, i am new to this forum. I read a lot but this is my first post.
I need an universal variable which can hold long,double,std::string, double[3] most of the time. Very seldom i need also a vector<vector<string>> like a little table with strings in the variable. These variables should be put in a map to access them via string key´s like std::map<string, variable>...
Sure, i would encapsulate all the stuff but i am worry about how to make the best choice for the internal structure.
One way would be the "OOP" way. I make a baseclass and for each typ an inherit class with the specialities for this object. I have heard that RTTI -typecasting is timeconsuming.
The next one will be, i always use a string for the long,double,string and convert the string on demand.
There may be a lot of more way´s ??
First goal should be the access speed and second the memory footprint for this stuff.
Have you got any tips/hints advice how you would choice about this ?
I have to use std::string for strings. These are dynamicly so i don´t know how union works with this. As i know (i have used unions 15 years back) the share the same memory as the biggest varable is. But not dynamicly.
I don't want to depreciate Howie's approach. As for my a don't know boost::any. But recently i had to implement something like that. I used void* to hold anything in the same class: