Strange GCC 'expected primary expression…' error [closed]?

When a dependent name is used to refer to a nested template, the nested name has to be prepended with the keyword template to help the compiler understand that you are referring to a nested template and parse the code correctly template void F(A &a) { a. Template f(); } Inside main the name a is not dependent, which is why you don't need the extra template keyword. Inside F name a is dependent, which is why the keyword is needed.

This is similar to the extra typename keyword when referring to nested type names through a dependent name. Just the syntax is slightly different.

In the former, the compiler thinks that you mean... a. F.

Notice that there are code snippet that are valid for both the keyword added and not added, yielding different results in each case, even for templates that take type parameters instead of integers. #include struct A { template static A f(T) { return A(); } template operator T() { return T(); } }; template int g() { U u; typedef A (*funcPtrType)(int()); return!(funcPtrType)u. F (0); } int main() { std::cout () If you add the keyword before f it outputs 1.

Explanation The version without the keyword parses as funcPtrType temp1 = (funcPtrType)u. F; // taking func address bool temp2 =! Temp1; // temp2 == false bool temp3 = temp2 (0); // temp4 == false return temp4; And the version with the keyword parses as A temp1 = u.

Template f (0); // function call funcPtrType temp2 = (funcPtrType) temp1; // temp2 == 0 bool temp3 =! Temp2; // temp3 == true return temp3; Notice that temp2 is a null pointer (produced by return T()). Whole different parses, and both are valid!

This really needs a way to disambiguate - which is to insert the template keyword as appropriate.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions