I am developing a framework to simplify creation of embedded software applications.
Resources are typically limited in this type of environment, so I need to make it very efficient in its use of memory space.
One goal is to be able to reference any variable by a <typeNumber, instanceNumber> value pair.
I have no problem creating objects that support an abstract list of instances of any given type.
I can successfully use operator[] to access any instance with its type-specific behavior.
I can likewise make an abstract list of of those objects that support type instance lists.
However, it is is a 2-step process to access the data and its type-specific behavior.
It seems that whatever I try, I ultimately come to a single function call that must return any type. It seems that C++ does not support this.
I suspect that RTTI might solve my problem, but I am trying to avoid using it, because I'd like my framework to work in systems that do not support it. (Actually, some say they support RTTI, but do not support exception handling, which RTTI uses.)
I'd also like to avoid any type of hard-coded switch block with fixed type-casting because I'd like to be able to add types to the list dynamically
Can anyone suggest an alternative?
Recommended Answers
Jump to Posthttp://www.boost.org/doc/html/any.html
http://www.boost.org/doc/html/variant.htmlyou may also find this discussion on static typing technology at large interesting.
Jump to PostIf you work with Microsoft compilers and do any COM programming (such as for distributed processing and inter-language support) you will come across the VARIANT structure with is nothing more than a structure with two objects:
- unsigned int type -- declares the type of data contained in the structure
…
Jump to Postwhat compiler are you using and what operating system are you working with. I know for a fact that Microsoft added exception handling in eVC++ 4.0 which is pretty old now.
>>I definitely cannot afford to turn all my variables into VARIANT types. A union of all types takes …
All 12 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.