I am trying to emulate boost::any for a toy language of mine, following the accepted answer from the following question,
Accessing Values in a Class Similar to boost::any
I can have,
Element e1 = 11;
Element e2 = 12.1;
now I would like to overload + so I can have,
e3 = e1 + e2;
but during run time I will not know if e1 will hold a int or a double but it will be number. So how I can I modify the const so that it also saves a variable telling me what kind of a number Element hold so I can call the correct Get method.
template /typename Datatype/
Element(Datatype InitialValue)
{
StoredValue = new ValueStorage(InitialValue);
}
I am also doing this on a microprocessor which does not have exceptions, passes -fno-rtti to the compiler, and can not use stdlib or boost.