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

  • Home
  • SEARCH
  • 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 6976099
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T17:27:12+00:00 2026-05-27T17:27:12+00:00

Here is the code I was looking, Source code : template <typename T> struct

  • 0

Here is the code I was looking, Source code :

template <typename T>
struct function_traits
    : public function_traits<decltype(&T::operator())>
{};

if we instantiate it with some functor X i.e function_traits<X>; , That will build the base class which is function_traits<decltype(&X::operator())> due to inheritance , but to build function_traits<decltype(&X::operator())> it’s base also has to be built, which could be function_traits<decltype(Z)>

I understand function_traits<X> != function_traits<Z>. Isn’t that recursive inheritance? 0_o.
How all things is working together?

  • 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-27T17:27:13+00:00Added an answer on May 27, 2026 at 5:27 pm

    This is illegal code. You cannot derive from an incomplete type, and at the point you try to derive from function_traits, the type is incomplete.

    struct A { typedef A type; };
    struct B { typedef A type; };
    
    template <typename T>
    struct X : X<typename T::type> {};
    
    X<B> test; // error: invalid use of incomplete type ‘struct X<A>’
    

    The only way you could get round this is if the function_traits you are trying to derive from is a complete type. You can do this using specialisation:

    struct A { typedef A type; };
    struct B { typedef A type; };
    
    template <typename T>
    struct X : X<typename T::type> {};
    
    template <>
    struct X<A> {}; // X<A> is now a complete type.
    
    X<B> test; // OK! Derives from X<A>, which is complete.
    

    Here, X<A> is complete when you try to derive from it, so you’re fine.

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

Sidebar

Related Questions

I'm looking for something like break for loops. Here's some example code (using Symfony's
I am looking into this New EmailAddressAttribute part of their source code here .
I'm looking through the source code of a project written in C. Here is
I want to understand if code snippets are what I am looking for here.
Here a code to demonstrate an annoying problem: class A { public: A(): m_b(1),
Edit: The code here still has some bugs in it, and it could do
I'm looking for an C source code parser that can create a comprehensive AST
I was looking over some C++ code and I ran into this memcpy function.
I'm a java newbie looking for some help reading a file. Here is the
When trying to use the code presented here link text I ran into some

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.