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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T02:26:54+00:00 2026-06-04T02:26:54+00:00

I try to have a partially specialized template class inheriting from another template class.

  • 0

I try to have a partially specialized template class inheriting from another template class. I’m not sure how to to that. Here is my code:

template < typename T>
struct SmallContainer
{
    typedef vector<T> type;
};

template<typename CONTAINER, typename T>
class AnotherClass : public CONTAINER<SmallContainer<T>::type>
{ // ..... };

and gcc keeps saying
expected template-name before ‘<’ token
expected ‘{’ before ‘<’ token
expected unqualified-id before ‘<’ token

The idea of my object is to have AnotherClass be a generic container of vector of any other type I want.

I tried to do template< template CONTAINER, typename T> etc… without any success.
Any idea ?
Thanks…

  • 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-06-04T02:26:56+00:00Added an answer on June 4, 2026 at 2:26 am

    This would work for a container of just one template argument:

    template< template< typename > class Container, typename T >
    class AnotherClass
      : public Container< typename SmallContainer< T >::type >
    {};
    

    This, however, won’t work for any of the standard containers as they have extra template arguments (like allocator).

    Note that typename is needed before SmallContainer< T >::type or otherwise the compiler will assume it refers to a value.

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

Sidebar

Related Questions

I'm running a weird issue here. I have code that makes jquery ajax calls
Here is example which I have try <?php include 'spider/classes/simple_html_dom.php'; $html = new simple_html_dom();
I have a Try Catch in my code. I would like to know if
I have a syntax similar to this: template <class P> class Foo : public
I have a HasMany mapping that needs a condition. I have this partially working,
I'm currently using macros to declare relatively long lists of partially specialized template classes
I have a parent view and a partial view, but when it try to
i have try refox and see how eazy my EXE to be disassembled. the
I have try to set icon for my App in the xCode. In the
I have try { using (var eventWaitHandle = EventWaitHandle.OpenExisting(name)) { eventWaitHandle.Set(); } Environment.Exit(0); }

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.