Keeping track of templated classes

Started by
4 comments, last by Zahlman 15 years, 2 months ago
Is there a way to keep a list of templated classes? I'm attempting to write my own configuration file system. I'll be parsing configuration files for keywords such as "int" "float" etc. So when I'm parsing a file I want to be able to create a templated variable class "Variable<int>" and "Variable<float>". This isn't hard, but how can I keep a list of all of these when I cannot use a templated class as a list type?
Advertisement
I think the trick is that Variable<T> inherits from non-templated VariableBase.
Ah, of course. Thanks. I resorted to just parsing floats because I can't think of any way to create user-defined types with a script. I can't imagine including every file in my game that has a type definition in it and hard coding a string to match every single user type.
Quote:Original post by M4573R
I resorted to just parsing floats

Beware, most integer values cannot be represented by floats. Have you tried parsing the integer 123456789 as a float for example? ;)
Hm, I guess I could just parse everything as strings and let the end user be responsible for converting it to the right type.
You might consider using a pre-existing solution, such as boost::any.

This topic is closed to new replies.

Advertisement