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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:19:38+00:00 2026-05-28T08:19:38+00:00

In another question , in one of the comments, I was informed that this

  • 0

In another question, in one of the comments, I was informed that this may be non-standard behavior (especially moving up the hierarchy):

struct f1
{
  int operator() (int a, int b) const { return a + b; }
};

struct f2
{
  int operator() (int a, int b) const { return a * b; }
};

struct f3 : f2
{
  typedef f2  base_type;
  int operator() (int a, int b) const 
  { return base_type::operator()(a,b) * (a / b); }
};

struct f4
{
  int operator() (int a, int b) const { return a - b; }
};

struct f5 : f4
{
  typedef f4  base_type; 
  int operator() (int a, int b) const 
  { return base_type::operator()(a,b) * a * b; }
};

template <typename F1, typename F3, typename F5>
class foo : F1, F3, F5 
{
  typedef F1    base_type_1;
  typedef F3    base_type_3;
  typedef F5    base_type_5;

public:
  int f1(int a, int b) { return base_type_1()(a, b); }
  int f3(int a, int b) { return base_type_3()(a, b); }
  int f5(int a, int b) { return base_type_5()(a, b); }

  int f3f2(int a, int b) 
  { 
    return base_type_3::base_type::operator()(a, b) * 
           base_type_3::operator()(a, b);
  }

  int f5f4(int a, int b)
  { 
    return base_type_5::base_type::operator()(a, b) * 
           base_type_5::operator()(a, b);
  }
};

int main()
{
  foo<f1, f3, f5> f;
  f.f1(1,2);
  f.f3(1,4);
  f.f5(1,5);

  f.f3f2(1, 1);
  f.f5f4(2, 2);

  return 0;
}

EDIT: This compiles under VC++ 2008, no warnings at level 4.

  • 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-28T08:19:39+00:00Added an answer on May 28, 2026 at 8:19 am

    I think the case wasn’t clear in ISO/IEC 14882:2003. Although it says:

    3.4.31/1 Qualified name lookup
    ...
    If the name found is not a class-name (clause 9) or namespace-name (7.3.1),
    the program is ill-formed.
    

    there is still an open question of what constitutes a class-name:

    9 Classes
    Class-specifiers and elaborated-type-specifiers (7.1.5.3) are used to make class-names.
    

    … and if you look up 7.1.5.3, elaborated-type-specifiers seem to include dependant names, but without explicitly allowing typedef keyword. It seems like unintended omission in version 2003 of the standard. Circumstantial evidence: Comeau Compiler in strict mode without C++0x extensions enabled accepts your code.

    However, using dependant names this way was explicitly made valid in ISO/IEC 14882:2011. Here is relevant wording:

    3.4.3/1 Qualified name lookup
    ...
    If a :: scope resolution operator in a nested-name-specifier is not preceded
    by a decltype-specifier, lookup of the name preceding that :: considers only 
    namespaces, types, and templates whose specializations are types.
    If the name found does not designate a namespace or a class, enumeration, or
    dependent type, the program is ill-formed.
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Another question related to this one . I have a List<SortableObjects> that is the
It's my second question, one after another. That's the problem with assembly (x86 -
This was the question asked in interview. Can we call one constructor from another
This question is related to another one, Emacs :TODO indicator at left side .
I was inspired by another question to write a script (or rather a one-liner)
An answer posted for one of my previous questions brings up another question; I
Yet another PHP question. I've got two arrays: one string-based and the other numeric.
I had a question answered which raised another one, why following does not work?
i got a question when create a javascript object, when one function invoking another
This may be more of a scoping question. I'm trying to set a JSON

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.