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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:47:01+00:00 2026-05-28T07:47:01+00:00

It is very difficult for me to explain this particular problem/question so please bear

  • 0

It is very difficult for me to explain this particular problem/question so please bear with me (I am having trouble with all my template related questions!).

Take this code as an example (note that the point of showing the code is to show a complex template hierarchy, not whether it makes sense):

#include <string>
#include <vector>
#include <list>

template <typename T>
struct Foo
{
  typedef typename T::value_type value_type;
  typedef typename T::value_type1 value_type1;
  typedef typename T::value_type2 value_type2;

  Foo() {}
  Foo(value_type1, value_type, value_type2) {}
  Foo(value_type, value_type1, value_type2) {}
};

template <typename T, typename T1, typename T2>
struct MiddleMan
{
  typedef T   value_type;
  typedef T1  value_type1;
  typedef T2  value_type2;
};

template <typename T>
struct MainClass
{
  typedef typename T::value_type value_type;
  typedef typename T::value_type1 value_type1;
  typedef typename T::value_type2 value_type2;

  typedef MainClass<T>  this_type;

  typedef Foo<this_type> iterator;
};

using namespace std;

int main()
{
  typedef MiddleMan<string, vector<string>, list<vector<string> > > mm;
  MainClass<mm>::iterator  a(1, 2, 3);

  return 0;
}

and assume this is the error you are getting

None of the 3 overloads could convert all the argument types

Note that I know in this instance, if you compile the code, the error message is not the same as above but the error message in my complex template code that I am currently working on is the above. I just presented a simplified example to help with the question.

Now I want to know the types of Foo, i.e. value_type, value_type1, value_type2 so that I can fix the error, without tracing back all the way to MiddleMan. The reason I don’t want to trace manually is that the code can be quite complex template code where a trace back is very difficult to do.

I figured since the compiler has already figured out the types, it should be able to let me know, i.e. there should be an easy way to figure it out at compile time (maybe through a message in the output window) the types attached to the typedefs. Is there an easy way?


SOLUTION-EDIT: Here is another example that may help future SOer after reading the selected answer:

template <typename T> struct incomplete;

template <typename T, typename T2, typename T3>
class foo
{
public:
  typedef T value_type;
  typedef T2 value_type2;
  typedef T3 value_type3;
};

int main()
{
  // Assume the following type is much more complex
  typedef foo<float, int, char> type_i_am_having_trouble_with;

  // At this point you are instantiating it, and the program compiles (or maybe
  // not) and you have no idea what some of the typedefs stand for
  type_i_am_having_trouble_with b;

  // Use this to find out what the typedefs stand for
  incomplete<type_i_am_having_trouble_with::value_type> test; 
}

Output from Visual C++ 2008:

error C2079: 'test' uses undefined struct 'incomplete<T>'
1>        with
1>        [
1>            T=float
1>        ]
  • 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-28T07:47:02+00:00Added an answer on May 28, 2026 at 7:47 am

    There are a few tricks to get the compiler to show you the actual type of a typedef. One is to try to instantiate an incomplete type.

    template<typename>
    struct Printer;
    
    typedef std::vector<int> foobartype;
    Printer<foobartype> printer;
    

    There is also boost::mpl::print which can actually issue a warning instead of erroring out.

    All those techniques have to be used at the place where the typename is actually accessible so you will have to ‘trace’ through the code eventually.

    Sadly, debugging template code is pretty much a black art and often you will have to play compiler and instantiate things in your head to get to the issue.

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

Sidebar

Related Questions

This is difficult to explain, please bear with me. I have a top menu
This is very specific, and a bit difficult to explain, and quite likely impossible,
This is a very difficult problem to describe. The big picture: An ajaxed dialog
I'm having a very difficult rails problem and i thought to ask for some
I have a slight problem with my application. It is very difficult to explain
I'm having a very difficult and strange problem Authenticating with System.Net.Mail.SMTPClient. I need to
I've found it very difficult to find any existing documentation on this. What I'm
I had a very difficult time with understanding the root cause of a problem
It is very difficult for me. I want to show the full related word
I have been having a very difficult time editing my .htaccess file to do

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.