Boost logo

Boost :

Subject: Re: [boost] MSVC9 SFINAE quirks?
From: Simonson, Lucanus J (lucanus.j.simonson_at_[hidden])
Date: 2009-01-09 12:56:46


Steven Watanabe wrote:
>>> I can take a look at it if I have a full test case to work with.
>>> Where can I get the current version of gtl?
>>> https://svn.boost.org/svn/boost/sandbox/gtl is old.
>>
>
Simonson, Lucanus J wrote:
>> Try it now. You can just add #include "gtl.hpp" at the top of the code >>snippet from my previous email and you should be able to reproduce the >>same compiler errors I'm seeing using what is now in the sandbox.
>
Steven Watanabe wrote:
>Okay. So msvc just doesn't like SFINAE except at the top level.
>I think you're going to have to make all the tests boolean metafunctions
>and add a top level enable_if.

It turns out the problem was that my meta logic was written so that any type was true and only gtl_no was false. When I wanted to use meta logic for SFINAE the default template was defining "type" and it was specialized (or partially specialized) for gtl_no to not define "type" in that case. MSVC9 seems to have not instantiated the template fully and just assumed that since the default at the top level defined "type" then substitution would eventually succeed and flagged the two functions as ambiguous. By changing requires_1 so that default does not define "type" and only the specialization for gtl_yes defines "type" I got it to work. This requires me to rewrite some of my code, however, to move all SFINAE to the top level.

In my original example I sent to the list requires_1 worked in a one template parameter case, but failed when there were two. There seems to be an inconsistency in the behavior of the compiler. Do you think this is a problem in the MSVC compiler, or are they doing the right thing, or is it a grey area in the standard?

Thanks,
Luke


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk