Boost logo

Boost :

Subject: Re: [boost] [TypeTraits] propose new callable-type call traits
From: Hui Li (hui.li_at_[hidden])
Date: 2014-01-12 01:38:51

Has is_callable_with_args made into boost somewhere? Or is there a plan to make it into boost? Would like to know the status since the link is a few years old.

It appears all 3 versions we have here follow 2 different approaches, and are different in terms of how an ambiguous call is handled.

(1) compute and compare sizeof(<function call expression>) in some form
This includes Eric Niebler's is_callable_with_args, and boost::has_call in c++03/98.
In this approach, an ambiguous call would result in a compiler error within the traits class.

(2) decltype(<function call expression>) in SFINAE context
This includes my has_valid_call, and boost::has_call in c++11.
In this approach, an ambiguous call would merely get the trait class evaluated to a false-type.

Whether we want to distinguish non-viable and ambiguous calls or not, i think boost::has_call should behave the same in c++03/98 and in c++11. The current version does not, which can be surprising to users.

I no longer have a real world application where distinguishing a non-viable call and ambiguous call is absolutely necessary (for my use case, i'm going to switch to the sizeof approach to get the compile error for ambiguous calls).

However, I do think it's worth exposing to programmers as much information as possible of whatever the compiler knows. Since the compiler can distinguish a non-viable call and an ambiguous call, the programmers should be able to do that too,
so that they have more control. that's one of the reason that we have metaprogramming, isn't it? :)

On Jan 12, 2014, at 12:24 AM, Eric Niebler <eniebler_at_[hidden]> wrote:

> On 1/11/2014 11:05 AM, Hui Li wrote:
>> I've implemented a few traits classes (code attached below) that, for a given callable-type T, and a set of Args..., detects whether the function call T::operator()(Args...) would be
>> (1) valid,
>> (2) ambiguous, or
>> (3) none is viable.
>> where T is allowed to have arbitrary overloaded operator()'s.
> <snip>
> Just FYI:
> --
> Eric Niebler
> _______________________________________________
> Unsubscribe & other changes:

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