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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:47:01+00:00 2026-06-14T01:47:01+00:00

I am trying following code from book C++ Template The Complete Guide , but

  • 0

I am trying following code from book C++ Template The Complete Guide , but it is failing to compile with Visual Studio 2010.

template < typename T>
class IsClassType {
private:
  typedef char One;
  typedef struct { char a[2]; } Two;
  template<typename C> static One test(int C::*);
  template<typename C> static Two test(...);

public:
  enum { Yes = sizeof ( IsClassType<T>::test<T>(0)) == 1 };
  enum { No  = !Yes };
};

template < typename T>
void check() {
  if ( IsClassType<T>::Yes ) {
    std::cout << " IsClassType Yes " << std::endl;
  } else {
    std::cout << " IsClassType No " << std::endl;
  }
}

int main() {
  std::cout << "Int:      ";
  check<int>();
}

Following is the compiler error.

1>------ Build started: Project: test123, Configuration: Debug Win32 ------
1>  test123.cpp
1>e:\svn\office_expt\test123\test123\test123.cpp(45): error C2783: 'IsClassType<T>::Two IsClassType<T>::test(...)' : could not deduce template argument for 'C'
1>          with
1>          [
1>              T=int
1>          ]
1>          e:\svn\office_expt\test123\test123\test123.cpp(42) : see declaration of 'IsClassType<T>::test'
1>          with
1>          [
1>              T=int
1>          ]
1>          e:\svn\office_expt\test123\test123\test123.cpp(51) : see reference to class template instantiation 'IsClassType<T>' being compiled
1>          with
1>          [
1>              T=int
1>          ]
1>          e:\svn\office_expt\test123\test123\test123.cpp(60) : see reference to function template instantiation 'void check<int>(void)' being compiled
1>e:\svn\office_expt\test123\test123\test123.cpp(45): error C2784: 'IsClassType<T>::One IsClassType<T>::test(int C::* )' : could not deduce template argument for 'int C::* ' from 'int'
1>          with
1>          [
1>              T=int
1>          ]
1>          e:\svn\office_expt\test123\test123\test123.cpp(41) : see declaration of 'IsClassType<T>::test'
1>          with
1>          [
1>              T=int
1>          ]
1>e:\svn\office_expt\test123\test123\test123.cpp(45): error C2056: illegal expression
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
  • 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-14T01:47:04+00:00Added an answer on June 14, 2026 at 1:47 am

    Is it this line:

    template<typename C> static Two test(...);
    

    The typename cannot be inferred from this. I think it should read:

    static Two test(...);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to compile this piece of code from the book The C Programming
I am trying to get the following code from a book to work. It
I am trying to convert the following code from Trefethen's Spectral Methods in MATLAB
I am trying to run the following code from within Eclipse: Process process =
I currently am trying the following code: $sql = $db->query(select id,username,fullname from userss ORDER
I'm trying the following code http://code.google.com/apis/ajax/playground/#change_the_playing_video It works well when runned from the playground
when I trying to run following code. var result = from c in db.brand
I am trying to execute windows commands from Java using the following code, Process
I have the following code that i am trying to change from a regular
I have been trying to extract e-mail addresses from the following code for quite

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.