There is something in there I'm curious about (and don't know how to dig
out of C++ documentation) and there is a related point on which I want
to make a suggestion. (Of course you already spotted the main error in
your simplification of whatever you're really trying to do, so I won't
comment on that.
Rodolfo Lima wrote:
template <class T> void f()
{
f<typename T::template B<int>::type>();
}
When f() is defined, the compiler must be informed that B is a template
or it wouldn't know how to parse the following < character.
It must also somehow figure out that B<int> is a type (not a function)
and that type is a type.
I use mainly Intel compilers (not GCC) and each version gets a little
pickier than the previous about being told that sort of thing in the
"correct" way. I'm not happy with the fact that it can't wait till
instantiation time to find out things that shouldn't scramble the syntax
when unknown (not knowing how to parse the < more obviously scrambles
the syntax).
Does typename in your example qualify type (not B)? Is the :: after
B<int> the thing that tells the compiler B<int> can't be a function?
Anyway, my suggestion is to be a little nicer to whatever programmer
will work on this code after you. Make more use of typedef to clarify
the construction.
In most such cases, typedef can break up the confusing part quite well.
In your example, it only helps a little. But your construct is ugly
enough, even a little help is worth the extra lines.
typedef T::template B<int> local_B;
typedef typename local_B::type local_type;
f<local_type>();
I hope the above is correct. I'm never quite sure with the typename
qualifier, without experimenting.