Subject: Re: [boost] [TypeTraits] propose new callable-type call traits
From: Hui Li (hui.li_at_[hidden])
Date: 2014-01-11 22:13:32
I tried your boost::has_call. Unfortunately it doesn't compile when the call for the given type and signature is ambiguous.
Did you intend that it'd be false_type in that case (since you did seem to suggest that your has_call behave similarly to my has_valid_call) ?
Submitted an issue on github: https://github.com/jamboree/boost.has_call/issues/1 .
On Jan 11, 2014, at 2:55 PM, TONGARI J <tongari95_at_[hidden]> wrote:
> 2014/1/12 Hui Li <hui.li_at_[hidden]>
>> 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.
>> This could be useful for programmers who want to
>> (1) make the function call only when it's valid,
>> (2) generate customized error/warning messages when it's ambiguous, or
>> handle/redirect it without getting an ambiguous compiler error, and
>> (3) redirect non-viable calls to some default behavior, which can be
>> different than how it's handled when the call is ambiguous.
>> If people are interested, I suppose this could be a useful addition to
>> I would appreciate any feedback!
>> For clarity, the implementation and demonstration attached below is
>> written in c++11. It can be easily ported to c++98/03 compilers by using
>> TypeTratis to replace the std type traits, BOOST_TYPEOF_KEYWORD to replace
>> decltype, and Boost.Preprocessor to generate code for arbitrary arity.
> It's interesting that you use ambiguity to distinguish the types.
> Anyway, your code doesn't support function(pointer) which is also Callable,
> and... are you sure your approach can be ported back to C++03 where there's
> no SFINAE on expression?
> FWIW, I have my has_call implementation:
> which works for both C++11/03.
> I have real world usage of has_call (or has_valid_call in yours), but I
> don't have the need of has_ambiguous_call so far.
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk