In this question, the asker has the following function:
template<typename ITER>
bool nextPermutation(ITER start, ITER end)
{
return nextPermutation(start, end, std::iterator_traits<ITER>::iterator_category());
}
Why isn't a typename
needed before the std::iterator_traits
? I thought it was needed for nested types of a template, if the template is dependent on a template parameter itself? GCC seems to support my idea, as it doesn't compile under both 4.3.4 and 4.5.1, demanding a typename
. Even so, it still compiles just fine under both Visual Studio 2008 and 2010.
Is this just another Visual Studio extension/bug I don't know about?
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 ()
? (See @DeadGM's messages starting here.) So is this maybe actually a bug in GCC?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…