Is there no "introspection" into the type (I mean the compiler knows the actual template parameters, is there no way to access them to see their "values" - types).
Thanks Cubby, yes I was aware of that kind of "extraction".
More generally though, helios suggests std::enable_if --- can one query the actual template types?
You can query properties about the types, such as whether it's an integer, whether it's a subtype of another class, stuff like that. To perform exact type comparisons you'll need to use template specialization. E.g.:
Thanks helios. However, I do know about enable_if and type_traits - but I don't think there are metafunctions for accessing actual template parameters. Am I wrong?
It is vague because my question aims at being very general, at answering questions like:
for any template class X, how can we obtain its actual template parameters? Just like we have std::is_const to retrieve information about a certain type, are there other metafunctions to obtain information about the template parameters being used in a specific instantiation?
I am sorry if its vague - but its in the nature of the question!`
It is vague because my question aims at being very general
Can't you at least provide an example of a problem you'd like to solve?
for any template class X, how can we obtain its actual template parameters?
What do you mean by "actual" template parameters? Are you referring to an analogy of actual and formal parameters?
Just like we have std::is_const to retrieve information about a certain type, are there other metafunctions to obtain information about the template parameters being used in a specific instantiation?
Any of the classes in type_traits can be used with template parameters of metatype typename.
The type traits in type_traits are what they are. If you want to query for other traits, it may or may not be possible, depending on what you're looking for. For example, the trait type_name_contains_the_letter_A<T> is not doable except by exhaustive enumeration of all types in the source.