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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T03:11:04+00:00 2026-05-25T03:11:04+00:00

How can instantiate this template struct? template<typename T, template<typename, template <typename> class D= std::allocator

  • 0

How can instantiate this template struct?

template<typename T,
  template<typename, template <typename> class D= std::allocator
           >class Z=std::vector
         >

struct amen
{
    Z<T,D<T> > cc; // i know D template class parameter is not visible , how do i do it?
};

int main(){
amen<int> moreAmen;
}

Can anyone show me how to do it?

  • 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-25T03:11:05+00:00Added an answer on May 25, 2026 at 3:11 am

    You have this wrong. It should be

    template<typename U, typename D = std::allocator<U>
             > class Z = std::vector
    

    The allocator of std::vector is not a template. Then the declaration of cc becomes

    Z<T> cc;
    

    As you gave a default argument for the allocator, you don’t need to pass any argument for it. If you wanted to, you would need to pass std::allocator<T> or some other allocator again

    Z<T, std::allocator<T> > cc;
    // or T<T, my::funny:allocator> cc;
    

    The default argument of a parameter of a template template argument is not “inherited” to the corresponding template template parameter of your class/struct template. You need to specify it again, like above (by stating std::allocator<U> as default template argument).

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

Sidebar

Related Questions

I got class with template methods that looks at this: struct undefined {}; template<typename
Consider this one template<typename T> struct A { enum class X { V =
How can I instantiate a class by throwing in a variable name? Consider this
Is it possible to assure that only spring can instantiate a class, and not
a template parameter can be used in another template parameter that follows it this
This doesn't compile: template<class X> struct A { template<int I> void f() {} };
Can lambda expressions be used as class template parameters? (Note this is a very
Try this out: template <typename T> class Base { public: int someBaseMember; }; template
Given a template like template<int dim> class Point { ... }; this template can
Using the C# object initializer syntax I can instantiate an anonymous object like this:

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.