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 6054345
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T08:08:33+00:00 2026-05-23T08:08:33+00:00

A question regarding template disambiguator was given here: template disambiguator and in the answer

  • 0

A question regarding template disambiguator was given here:

template disambiguator

and in the answer we can read:

ISO C++03 14.2/4

When the name of a member template specialization appears after . or -> in a postfix-expression, or after nested-name-specifier in a qualified-id, and the postfix-expression or qualified-id explicitly depends on a template-parameter (14.6.2), the member template name must be prefixed by the keyword template. Otherwise the name is assumed to name a non-template.

Now here comes my conrete example that I don’t quite understand:

template <class T>
class Base {
  public:


  template <int v>
    static int baseGet() {return v;}

  class InnerA {
    public:

    template <int v>
      static int aget() {return v;}

  };

  class InnerB {
    public:
      typedef Base BaseType;
      typedef BaseType::InnerA OtherType;

      template <int v>
        static int baseGet() {return BaseType::baseGet<v>();} //(A)

      template <int v>
        static int aget() {return OtherType::aget<v>();} //(B)
  };
};

It obviously fails to compile. You need template in the line (B): OtherType::template aget<v>();.
However, both g++ (4.4.3) and clang++ (2.9) don’t complain about the lack of template in the line (A). Why? BaseType depends on the type T, does it not? Is it a small depart from the standard by those compilers, or do I misunderstand something in the standard?

  • 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-23T08:08:34+00:00Added an answer on May 23, 2026 at 8:08 am

    They implement the C++0x specification, where Base is the current instantiation. And C++0x allows to omit template keyword in such a case. Since BaseType is a typedef for Base, when you say BaseType, that names the current instantiation too.

    To quote the spec, since you seem to be interested in spec refs

    A name is a member of the current instantiation if it is […]

    • A qualified-id in which the nested-name-specifier refers to the current instantiation and that, when looked up, refers to at least one member of the current instantiation or a non-dependent base class thereof.

    and

    A name refers to the current instantiation if it is […]

    • in the definition of a […] nested class of a class template, […], the injected-class-name (Clause 9) of the class template or nested class

    and (the modified 14.2/4 that you quoted)

    […] or the nested-name-specifier in the qualified-id refers to a dependent type, but the name is not a member of the current instantiation (14.6.2.1), the member template name must be prefixed by the keyword template. […]


    Note: In C++03 your code is ill-formed because both BaseType and OtherType are dependent. The spec says:

    A type is dependent if it is […]

    • a template parameter
    • a qualified-id with a nested-name-specifier which contains a class-name that names a dependent type
    • a template-id in which either the template name is a template parameter or any of the template arguments is a dependent type

    (note that Base is equivalent to Base<T>, which is the base on which Base and BaseType::InnerA are dependent types).

    Note that “explicitly depends” in your quote is a pre-standard term, and was gotten rid of fairly lately (I believe it was at December1996). It basically meant (in this context) a qualified-id in which the qualifier is dependent or a class member access (a->x / a.x) where the a was dependent. After “explicitly depends” was removed from the draft, it was still lurking around at some places, and even C++0x has still references to “explicitly depends” in a note at 14.6.2p2:

    the base class name B<T>, the type name T::A, the names B<T>::i and pb->j explicitly depend on the template-parameter.

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

Sidebar

Related Questions

Quick question regarding delegateEvents in a View - can we specify multiple event bindings
I have question regarding the SQLAlchemy. How can I add into my mapped class
I have a question regarding template parts. I want to create a control that
Here's my silly question regarding jQuery that I should probably know. It's in regards
I have a question regarding loops within an email template. My current email library
I have a question regarding editing/saving data in database using Django. I have template
There was a question regarding passing taking the following function template, and instantiating it
I have a question regarding the standard ADL resolution in C++. Here is a
I have a question regarding a HTML template.. I have create a template function
I have question regarding macros. How could I cast through macro a template class

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.