Boost logo

Boost :

Subject: Re: [boost] [TypeTraits] propose new callable-type call traits
From: John Maddock (john_at_[hidden])
Date: 2014-01-12 04:54:46


> 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
> TypeTraits.
> 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.

I think that might make an excellent addition to type_traits - however, I
have no time at present to do anything on this myself, so you would have to
provide a complete solution, including docs and tests etc. As others have
mentioned, reliance on SFINAE-expressions is an issue because msvc still
doesn't fully support this. Other than that, we probably should have one
eye towards programming in C++11 these days...

John.


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