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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T03:31:37+00:00 2026-06-17T03:31:37+00:00

Inspired by this question , i’m wondering if there is some compile-time check one

  • 0

Inspired by this question, i’m wondering if there is some compile-time check one can introduce to detect if two given template instantiations:

template <typename T>
class Templ...

typedef Templ<std::string> stringInstance;
typedef Templ<double> doubleInstance;

are constructed from the same definition, or if they are built from different specializations of the Templ template

so basically the hypothetical template function will behave like this:

template <typename T>
class Templ
{}

template <>
class Templ<std::string>
{}

template <>
class Templ<double>
{}

template <typename T1,typename T2>
class Belong_To_Same_Templ_Definition
{}

//tests
typedef Templ<std::string> stringInstance;
typedef Templ<double> doubleInstance;
typedef Templ<int> intInstance;
typedef Templ<char> charInstance;

assert( Belong_To_Same_Templ_Definition< intInstance , charInstance >::value == true);
assert( Belong_To_Same_Templ_Definition< intInstance , doubleInstance >::value == false);
assert( Belong_To_Same_Templ_Definition< stringInstance , doubleInstance >::value == false);

is possible to create this kind of metafunction?

  • 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-17T03:31:39+00:00Added an answer on June 17, 2026 at 3:31 am

    It seems unlikely, to be honest (although I can’t definitively rule out a cunning trick).

    There is no first-class identity for a given specialization (outside the type arguments that select it), to compare.

    So, you could make it work with your own templates, if you want, but you can’t write an ad-hoc inference for existing templates.

    Consider also that it wouldn’t work anyway, in the sense that it couldn’t tell whether two instantiations have a compatible layout: even if Templ<int> and Templ<char> are instantiated from the same template code, with no specialization, that code can use traits classes which are specialied.

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

Sidebar

Related Questions

Inspired by this question , I'd like to know whether there is any trick
Inspired by this question on Meta , I wrote two queries on the Stack
Inspired by this question: How to manage Configuration Settings for each Developer How can
Inspired by this question. Why is there no list.clear() method in python? I've found
Inspired by this question How can I quickly identify most recently modified stored procedures
Inspired from this question , was wondering what are the possible ways to create
This question was inspired by this answer to another question, indicating that you can
This is inspired by this question and the comments on one particular answer in
Here are two REPL sessions (inspired by this question , although my question is
Inspired by this question How can I force GDB to disassemble? I wondered about

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.