Boost logo

Boost :

Subject: Re: [boost] [type_traits] type_traits for types with operator().
From: Jason Roehm (jasonr_at_[hidden])
Date: 2014-01-29 13:42:51

On 01/29/2014 12:28 PM, John Maddock wrote:
>> Recently I looked for type_traits for callable classes. It so strange, I
>> didn't find such traits. Most likely, I just missed them or something
>> like
>> them.
>> I actually don't know is there a real need for them. Anyway I tried to
>> write such traits at least for practice and metaprogramming training. I
>> tested them with gcc, clang and msvc2010. I would appreciate if you
>> looked
>> at the code. Here is the
>> link<> to
>> my github repository.
>> It's cool that they can see hidden generated operator() of lambdas
>> closure
>> type.
> My apologies for not replying before Anton.
> This looks cool. However what does it detect? Any operator() or
> nullary operator()?
> A better C++11 style interface *if* it can be implemented would be
> something like:
> template <class F, class Args...>
> struct is_callable;
> Which inherits from true_type only if F is callable with arguments
> Args...

There has been some discussion on implementing this sort of interface on
this mailing list, some in the last few weeks and some closer to a year
ago, IIRC. I believe there is at least one implementation out there that
provides a has_call trait. As you pointed out, though, there are a lot
of cases to handle, and I'm not sure that it covers all of the bases.


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