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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T20:54:43+00:00 2026-06-07T20:54:43+00:00

Below I have 3 prototypes. I expected the first one (commented out) to work,

  • 0

Below I have 3 prototypes. I expected the first one (commented out) to work, but that’s the only one that doesn’t work (see comments in code for errors). Even more surprising to me is that either of the following 2 work, even when both are present.

/////////////////////////////////////////////////
// Prototypes:
/////////////////////////////////////////////////
//  Causes "ambiguous call to overloaded function" at the call site when when one or both  
//  of the below prototypes is also present. Otherwise causes unresolves external
//template<typename T> void func(); 

//  Okay, can have this one AND/OR the below declaration
template<typename T> typename std::enable_if<std::is_integral<T>::value, void>::type func();

//  Also okay, can have this one AND/OR the above declaration
template<typename T> typename std::enable_if<std::is_integral<T>::value, void>::type func();


int main()
{
    func<int>();
}


/////////////////////////////////////////////////
// Definitions:
/////////////////////////////////////////////////
template<typename T> typename std::enable_if<std::is_integral<T>::value, void>::type func() {}

template<typename T> typename std::enable_if<!std::is_integral<T>::value, void>::type func() {}

Which is the correct prototype, and why doesn’t the first one work? I’m using VS2010 & VS2012

  • 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-07T20:54:45+00:00Added an answer on June 7, 2026 at 8:54 pm

    The first one causes the error because it declares a different function template. To put it simply, it is different because all the enable_if thingies are part of its signature, not just the final type it resolves to.

    You never provide a definition for that first template declaration, and that’s why you get an “unresolved external” error if you don’t put the others in.

    If you put the others in, now you have one of the others plus this one as a candidate, and both are viable, and not ordered. That’s why you get an “ambiguous call” error.

    The correct way is to declare the ones you define, i.e., exactly what you have uncommented right now.

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

Sidebar

Related Questions

Below I have written a sample program that I have written to learn about
below i have a code that runs in most of my simple programs ..
I have below a working query that needs to be simplified. The reason is
Hello I have one c++ Programming assignment question. I tried hard but somehow I
I have some simple javascript that as far as i can tell should work
I have this tested function below that works fine for fading an element in
I have a spring bean that I have configured in applicationContext like below: <bean
Basically, I have the same question as this one below: http://www.mail-archive.com/prototype-scriptaculous@googlegroups.com/msg08682.html In my case,
I have a page that is based on my master page. the code below
I have a statement using jQuery as below: jQuery(#page>ul>li:last>a).click(); How can I do that

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.