Boost logo

Boost :

Subject: Re: [boost] [config] What Feature is this??
From: John Maddock (jz.maddock_at_[hidden])
Date: 2017-07-24 16:40:30

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.


This email has been checked for viruses by AVG.

Boost list run by bdawes at, gregod at, cpdaniel at, john at