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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T05:15:44+00:00 2026-05-16T05:15:44+00:00

I am trying to compile Flusspferd on Windows using MSVC, but it fails due

  • 0

I am trying to compile Flusspferd on Windows using MSVC, but it fails due to a template instantiation problem. For the ease of explanation I rewrote the problem in simpler terms:

#include <boost/utility/enable_if.hpp>
#include <boost/type_traits/is_convertible.hpp>

class UndefinedType;

class A
{

};

class TestClass {

public:

    TestClass(A* a)
    {

    }

    template<typename OtherType>
    TestClass(OtherType t, typename boost::disable_if<typename boost::is_convertible<OtherType, UndefinedType>::type>::type * = 0)
    {

    }
};

The problem is, that TestClass contains a templated constructor that uses boost::is_convertible with the forwarded class UndefinedType. is_convertible only works for complete types, meaning that this constructor should only be used when UndefinedType has been defined, otherwise the template instantiation will fail with C2139.

In Flusspferd the TestClass is used in places where UndefinedType has not been defined, but using its other constructor:

void test()
{
    A* a = new A();
    TestClass test(a); // will instantiate the templated constructor, but why?
}

Though TestClass(A* a) is the most specific constructor for this situation, the template will be instantiated leading to C2139 because of is_convertible.

GCC compiles fine, so the question is: why isn’t MSVC? Who is right? Is there a way to get around this?

Thanks for the help!

Update:

MSalters is right. The correct behaviour is undefined. From the C++-Standard:

If the overload resolution process can determine the correct function to call without instantiating a class template definition, it is unspecified whether that instantiation actually takes place.

template <class T> struct S {
    operator int();
};

void f(int);
void f(S<int>&);
void f(S<float>);

void g(S<int>& sr) {
    f(sr);  // instantiation of S<int> allowed but not required
            // instantiation of S<float> allowed but not required
};
  • 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-16T05:15:44+00:00Added an answer on May 16, 2026 at 5:15 am

    As you state, “is_convertible only works for complete types”. This means that if you violate this precondition, anything can happen – in particular undefined behavior. So both GCC and MSVC are “right” – they’re neither obliged to produce working code nor an error.

    • 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 fastboot for Android using this guide , but I'm getting
I am trying to compile a simple C Windows API program using the Windows
Hi trying the compile Objective C++/Protocol code but the compilation fails with error Expected
While trying to compile a Silverlight project for Windows Phone using Visual Studio 2010
When trying to compile a file that include winnt.h via windows.h, I get the
While trying to compile a 64 bit linux kernel using gcc, I see the
Im trying to compile but im getting these errors: 1>.\item.cpp(123) : warning C4800: 'int'
I'm trying to compile using a compiled Boost libs. I can compile using header-only
Iam trying to compile rtmpd using VS2008 Iam getting this error. Error 63 error
When trying to compile the following: #include <string> #include <iterator> #include <iostream> using namespace

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.