Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4324346
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T09:07:12+00:00 2026-05-21T09:07:12+00:00

In this question , the asker has the following function: template<typename ITER> bool nextPermutation(ITER

  • 0

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?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-21T09:07:13+00:00Added an answer on May 21, 2026 at 9:07 am

    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 typenames though.

    FWIW, no it’s not possible to deduce anything about iterator_category on a language level.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Hopefully no one has asked this question - didn't see it, but I apologize
This question has been asked before ( link ) but I have slightly different
This question has been asked in a C++ context but I'm curious about Java.
This question has been asked in various forms in a number of different forums,
Perhaps this question has been asked elsewhere, but I'm unable to find it. With
Maybe this question has been asked many times before, but I never found a
I know this question has been asked before, but I ran into a problem.
I know this question has been asked a bit before. But looking around I
I know this question has been asked before, and I took a look at
I realize that this question has been asked 100times but none that I have

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.