Boost logo

Boost Users :

Subject: Re: [Boost-users] [Range] Extending the library for a base class and all its derived - enable_if
From: Avi Kivity (avi_at_[hidden])
Date: 2014-04-26 09:13:05

On 04/26/2014 07:05 AM, Nathan Ridge wrote:
>>>> Would something like
>>>> template <typename C>
>>>> struct range_iterator<typename enable_if<is_base_of<Base, C>,
>>>> C>::type> { ... };
>>>> work?
>>> This does not compile.
>> Well, it should be
>> template <typename C>
>> struct range_iterator<typename enable_if<is_base_of<Base, C>::value, C>::type> { ... };
>> but an simpler example I tried also does not compile, complaining that
>> template parameter C is not used (though it clearly is). I wonder if
>> it's a bug in the error message (and the code is disallowed) or a real
>> compiler bug.
> The code is disallowed. In order to select the partial specialization
> for some argument type 'A', the compiler would have to compare 'A' and
> 'typename enable_if<is_base_of<Base, C>::value, C>::type' and deduce
> 'C'. It cannot do this (in standardese this is called a "non-deduced
> context").

Ok, thanks for the clarification.

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at