I don't know exactly how libraries work, but'd be extremely nice to be able to use this:
template <typename Type1="int">
because then you could use typeid(type).name() and use that as a template, hence being able to get the type back!
Printable View
I don't know exactly how libraries work, but'd be extremely nice to be able to use this:
template <typename Type1="int">
because then you could use typeid(type).name() and use that as a template, hence being able to get the type back!
Can you go into detail? I know about the RTTI but my experience in templates is limited. Why would this be a good thing?
Say you're working on a variant type.
I've been modifying the Boost Any one.
Anyway, you can't get back.... you can use typeid(type) to get the type, or typeid(type).name() to get it as a string, but you cannot use the type_info class or the character array in very many ways...
so you have to cast when you want the data back, for the Any type, like this:
cout << any_cast<int> (any1) << endl;
While if you could do that, you could just have
cout << any1 << endl;
go here and download Loki. Look at its TypeInfo class.
btw for template classes you are allowed to specify default parameters tho it would be int not "int"
I know, but it was an example so that you could pass a string in case you used typeid.
where on the site is it?
I just found it... it doesn't look like it does what I meant
I meant a string intentionally. I know you can do default parameters, but I want to be able to use a string in it... that way you could get the datatype back from typeid(type).name()Quote:
btw for template classes you are allowed to specify default parameters tho it would be int not "int"