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

  • Home
  • SEARCH
  • 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 99163
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T00:20:06+00:00 2026-05-11T00:20:06+00:00

Is it possible to use the using declaration with template base classes? I have

  • 0

Is it possible to use the ‘using’ declaration with template base classes? I have read it isn’t here but is that because of a technical reason or is it against the C++ standard, and does it apply to gcc or other compilers? If it is not possible, why not?

Example code (from the link above):

struct A {     template<class T> void f(T); };  struct B : A {     using A::f<int>; }; 
  • 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. 2026-05-11T00:20:07+00:00Added an answer on May 11, 2026 at 12:20 am

    What you linked to is a using directive. A using declaration can be used fine with templated base classes (haven’t looked it up in the standard, but just tested it with a compiler):

    template<typename T> struct c1 {      void foo() { std::cout << 'empty' << std::endl; }  };   template<typename T> struct c2 : c1<T> {      using c1<T>::foo;      void foo(int) { std::cout << 'int' << std::endl; }  };   int main() {      c2<void> c;     c.foo();     c.foo(10);  } 

    The compiler correctly finds the parameter-less foo function because of our using-declaration re-declaring it into the scope of c2, and outputs the expected result.

    Edit: updated the question. here is the updated answer:

    The article is right about that you are not allowed to use a template-id (template name and arguments). But you can put a template name:

    struct c1 {      template<int> void foo() { std::cout << 'empty' << std::endl; }  };   struct c2 : c1 {      using c1::foo; // using c1::foo<10> is not valid     void foo(int) { std::cout << 'int' << std::endl; }  };   int main() {      c2 c;     c.foo<10>();     c.foo(10);  } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 162k
  • Answers 162k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer So, in your button action method, you can do something… May 12, 2026 at 11:56 am
  • Editorial Team
    Editorial Team added an answer First you should have a string variable to write columns… May 12, 2026 at 11:56 am
  • Editorial Team
    Editorial Team added an answer Hungry? is equal to Nullable<Hungry>, which in terms mean that… May 12, 2026 at 11:56 am

Related Questions

Why is it impossible to have a reference to void? The only thing I
Is it possible to use the __unused attribute macro on Objective-C object method parameters?
One can easily use JDO syntax to query on multiple parameters as follows: //specify
I've seen several questions related to properly mapping an enum type using NHibernate. This

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.