
6 May
2010
6 May
'10
5:47 p.m.
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; }