In this question, the asker has the following function:
template
bool nextPermutation(ITER start, ITER end)
{
return nextPermutation
Visual C++ is well-known not to (fully) support two-phase lookup, which is the underlying reason for why typename
is required in the first place. If the compiler doesn't fully support this, it might not fully parse a template before it is instantiated, by which time it "knows" that std::iterator_traits<ITER>::iterator_category
is a type. Obviously, this deficiency extends to VC10.
When it comes to typename, I'd trust GCC over VC any day.
Doesn't MSVC implement the late-parsing scheme? In such a scheme, the compiler isn't dependent on typename
. It just stores all the token in between the template definition's braces, and when the template is instantiated, it parses those tokens. Since it then knows what is and what is not a type, it will work without typename
.
But if the compiler doesn't diagnose the missing typename
when you instantiate the template, then it's non-conforming.
Or is it actually possible to deduce that iterator_category is either a type or a function because it's followed by a pair of parenthesis ()?
All that matters is whether the name is dependent and qualified. Whether or not the template could deduce itself that the name is always a type doesn't matter. It might matter for the quality of error messages for missing typename
s though.
FWIW, no it's not possible to deduce anything about iterator_category
on a language level.