Boost logo

Boost :

Subject: Re: [boost] [config] What Feature is this??
From: Edward Diener (eldiener_at_[hidden])
Date: 2017-07-24 18:26:52


On 7/24/2017 12:40 PM, John Maddock via Boost wrote:
>
>
> On 24/07/2017 16:18, Edward Diener via Boost wrote:
>> On 7/24/2017 8:29 AM, Andrey Semashev via Boost wrote:
>>> On 07/24/17 14:37, Edward Diener via Boost wrote:
>>>> On 7/23/2017 2:50 PM, John Maddock via Boost wrote:
>>>>> Folks, I think I'm looking to add a new C++11 defect macro, but
>>>>> don't know what the feature is called, nor can I see a way of
>>>>> detecting it with clang's __has_feature function.
>>>>>
>>>>> The code I want to enable involves function overloading based on a
>>>>> decltype return type as in:
>>>>
>>>> I never realized that function overloading could occur based on any
>>>> return type. I always thought it had to be based on the parameter
>>>> types. Is this part of the C+11 standard ? Where in the standard is
>>>> this specified ?
>>>
>>> I think it's not about overloading but about disabling function
>>> template instantiations via SFINAE.
>>
>> I am glad to hear that. I misinterpreted the original message and
>> probably should have realized it. Thanks !
>
> It's sort of about both actually - we're using SFINAE to select between
> two overloads based on the properties of the argument types (sort of
> poor man's Concepts), so we can write:
>
> template <class Arg>
> auto foo(const Arg&) -> decltype(expression-involving-type-Arg)
>
> and that function overload will be considered only if the expression
> inside the decltype compiles. You may have to go through heroics to get
> the return type correct (use of the comma operator for example), but
> it's a very easy way to select between function overloads based on which
> concepts the argument types adhere to.

Thanks, John, I just fell asleep by not realizing you were talking about
SFINAE ala enable_if etc. I am surprised that any compiler would operate
differently in regard to SFINAE between using the C++03 'return-type
some_function(etc.)' form and the C++11 'auto some_function(etc.) ->
return-type' form, whether decltype was used or not.

>
> John.
>
>
> ---
> This email has been checked for viruses by AVG.
> http://www.avg.com


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