|
Boost : |
Subject: Re: [boost] [proto][can_be_called]
From: Andy Venikov (avenikov_at_[hidden])
Date: 2010-05-06 13:47:57
Andy Venikov wrote:
> Currently,
> can_be_called<> expects only functors.
>
> Is it possible to extend it so that it can take any type and return true
> if that type can be called with the list of given parameters.
>
> For example,
>
>
> function<int (int, char, long)> functor;
> int f(int, char, long);
> int dummyInt;
>
>
> int main(int argc, char ** argv)
> {
> assert(false == test(functor, argc, 11, argv));
> assert(true == test(functor, 10, 11, 12));
>
> assert(true == test(f, 10, 11, 12));
> assert(false == test(dummyInt, 1));
> }
>
<snip>
Sorry, forgot the implementation of function template test:
template <typename Func, typename ... Prms>
inline
bool test(Func && func, Prms && ... prms)
{
return can_be_called<Func, Prms...>::value;
}
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk