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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:30:57+00:00 2026-05-25T09:30:57+00:00

I suspect I can’t do this directly using a PIMPL pattern. Is it possible

  • 0

I suspect I can’t do this directly using a PIMPL pattern. Is it possible to have a smart pointer to a template class? I have not been able to compile by turning knobs on the shared_ptr declaration.

// ============Foo.h ============
// Forward declare the implementation
template <typename T> class FooImpl;

class Foo
{
  public:
    Foo getInstance(const string& fooType);
    ...
  private:
    shared_ptr< FooImpl<T> > m_impl;
};

// ============FooImpl.h ============
template <typename T>
class FooImpl
{
    ...
};

Under Visual Studio 2008: “error C2065: ‘T’ : undeclared identifier”. I receive a similar error under GCC. If I un-parameterize FooImpl (so that FooTempl inherits from FooImpl), the code will compile.

I suspect I can’t paramaterize the smart pointer, but I could be wrong.

EDIT: The second Visual Studio error is more telling: “error C3203: ‘FooImpl’ : unspecialized class template can’t be used as a template argument for template parameter ‘T’, expected a real type”

Jeff

  • 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-25T09:30:57+00:00Added an answer on May 25, 2026 at 9:30 am

    I’m not entirely certain what you are trying to accomplish, but does this help?

    Try 1:

    // ============Foo.h ============
    // Forward declare the implementation
    
    template <typename T> class FooImpl;
    
    template<class C>
    class Foo
    {
      public:
        Foo getInstance(const string& fooType);
        ...
      private:
        shared_ptr< FooImpl<C> > m_impl;
    };
    
    // ============FooImpl.h ============
    template <typename T>
    class FooImpl
    {
        ...
    };
    

    Try 2:

    // ============Foo.h ============
    // Forward declare the implementation
    
    class FooImplBase;
    
    class Foo
    {
      public:
        Foo getInstance(const string& fooType);
        ...
      private:
        shared_ptr< FooImplBase > m_impl;
    };
    
    // ============FooImpl.h ============
    class FooImplBase {
      public:
        virtual void AnAPI();
        virtual int AnotherAPI();
    };
    template <typename T>
    class FooImpl : public FooImplBase
    {
        ...
    };
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why on earth I can do this: #include <iostream> #include <algorithm> #include <vector> using
not an expert on js but this if-statement still tickles me because I suspect
not an expert on js but this if-statement still tickles me because I suspect
I suspect that I can't do this, but figured I'd ask the wise community
I suspect there is an easy answer for this question but I can't find
I'm trying to get this piece of code working a little better. I suspect
I've got no experience with this, so i suspect my logic is overly complicated,
I have this data structure: Root Child Child Child Child Child Child My models
I have a table like this: Item { int ItemID int ParentID string Name
I'm lovin' it, but I suspect it causes some problem. I know I can

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.