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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T00:05:45+00:00 2026-06-14T00:05:45+00:00

without specializing for each class template/class, is it possible to write a generalized ‘rebind’

  • 0

without specializing for each class template/class, is it possible to write a generalized ‘rebind’ meta function, so that
given

 template<class > struct foo;
 struct bar;

the following

 is_same<rebind<foo<int>,float>,foo<float>> 
 is_same<rebind<bar>,bar>

and maybe

is_same< rebind<std::vector<int>,float>,std::vector<float>>  

returns a type equivalent of true?

  • 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-14T00:05:46+00:00Added an answer on June 14, 2026 at 12:05 am

    Sure.

    But be aware that any template template parameter taking a variadic template parameter list is restricted to accepting templates with only type parameters, not non-type parameters. In other words, the general case below won’t work for std::array because its second argument is an integer. You’d have to add a special case.

    The primary template is already a special case, since it handles classes that aren’t a specialization of a template.

    http://liveworkspace.org/code/5b6f0cb3aec1eb74701e73d8d21aebab

    template< typename bound, typename ... new_args >
    struct rebind_class {
        static_assert( sizeof ...( new_args ) == 0,
             "can't rebind arguments to non-specialization" );
        typedef bound type;
    };
    
    template< template< typename ... > class template_, typename ... new_args,
        typename ... old_args >
    struct rebind_class< template_< old_args ... >, new_args ... > {
        typedef template_< new_args ... > type;
    };
    
    template< typename ... args >
    using rebind = typename rebind_class< args ... >::type;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is it possible to use typedef on a std container without specializing it? Code
Is it possible to have a vector without specializing it? My problem is: I
My question is w.r.t the following thread : specialize a member template without specializing
I am trying to use template meta-programming to determine the base class. Is there
Without having to write VBA code, is there a way to maybe write a
Without going into whether this is a good or bad idea: Is it possible
I'm trying to access each value in a array without serializing it. I than
void foo (void *p); // library function; can't edit template<typename T> void Remove (T
Is it possible to run some code when an assembly is loaded, without doing
Let's say we have a template class Area , which has a member variable

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.