Boost logo

Boost :

Subject: Re: [boost] [utility][enable_if]Fiddly function lookup failure on msvc11
From: B (kenich.yamamoto_at_[hidden])
Date: 2013-10-07 08:06:02


2013/10/7 Gavin Lambert <gavinl_at_[hidden]>

> On 10/7/2013 9:41 AM, Quoth 山本賢一:
>
> template <class T>
>> struct always_true :
>> boost::mpl::true_
>> {
>> };
>>
> [...]
>
> Does the behaviour change if you make always_true not a template, or if
> you make some member of it actually depend on the template argument?
>

The behaviour changed and the code compiled if I changed always_true not a
template.

struct always_true :
    boost::mpl::true_
{
};

template <class T> inline
typename boost::enable_if_c<
    !boost::mpl::not_<
        always_true
>::type::value
, int
>::type
get_one(T)
{
    return 1;
}

The behaviour didn't change and the code didn't compile if I made some
member of always_true actually depend on the template argument.

template <class T>
struct always_true :
    boost::mpl::true_
{
    typedef typename boost::add_const<T>::type unused_type;
};

The actual condition to reproduce the issue seems very complex. My best
guess is that msvc11 gives up resolving template-parameter-dependent
condition and marks it as failure (in the sense of SFINAE) under a specific
circumstance.


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