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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T06:16:44+00:00 2026-05-28T06:16:44+00:00

To make referencing types easier you can bring individual types into the current scope

  • 0

To make referencing types easier you can bring individual types into the current scope with the using clause:

namespace MyCompany
{
    namespace MyProject
    {
        class MyType {};
        void myFunc(MyType const& obj) {}
    }
}

int main()
{
    using MyCompany::MyProject::MyType;
    using MyCompany::MyProject::myFunc;

    MyType  plop;
    myFunc(plop);
}

The problem is if the class is a template class (or function). Is it possible to bring these into the current scope without fully instantiating them?

namespace MyCompany
{
    namespace MyProject
    {
        template<typename T>
        class MyType {};

        template<typename T>
        void myFunc(MyType<T> const& obj) {}
    }
}

int main()
{
    // Can I bring the templates into scope?
    // Or do I need to fully instantiate each version in the using clause?
    using MyCompany::MyProject::MyType;  ????
    using MyCompany::MyProject::myFunc;  ????

    MyType  plop;
    myFunc(plop);
}
  • 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-28T06:16:45+00:00Added an answer on May 28, 2026 at 6:16 am

    Both VC10 & gcc run the code ok with different instantiations after the using declaration.
    So it seems the using declaration has brought the whole template to the scope.

    Also in c++0x standard n3290 7.3.3 – 5

    A using-declaration shall not name a template-id. [ Example:
    struct A {
     template <class T> void f(T);
     template <class T> struct X { };
    };
    struct B : A {
     using A::f<double>; // ill-formed
     using A::X<int>; // ill-formed
    };
    

    which seems to suggest that using should not be used with specific template-id.

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

Sidebar

Related Questions

I'm running into an issue where I can't make a reference to a class
To make things easier when switching between machines (my workstation at the office and
How can I make a SQL Compact 2008 application for the desktop? I know
I'm trying to make a game of lights out. I can get the lights
I would like to make a form I have in my website self referencing.
What can I do to make this work: template<class C, class V, Test V::*>
In my PhoneGap Eclipse project I am using jQuery for visual effects by referencing
I've cobbled together a Windows Class Library (Called MPC_Core) using .NET 4, I'm referencing
Make a new AS3 Document in Flash, paste in the following code and run
make is not only useful for building your programming project, but it seems to

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.