
2012/11/4 TONGARI <tongari95@gmail.com>
Hi there,
I've used this metafunction for some time, and it just fitted my need. Recently, I make up my mind to complete it, willing to put it in public.
Synopsis -------------- can_be_called<F, Sig>
F Any callable type to test, even member-function ptr. Sig The desired calling signature, function-type only.
Example ------------- struct X;
struct F { void operator()(); };
can_be_called<void(int), void(char)>::type // mpl::true_ can_be_called<int(), void()>::type // mpl::true_, return val can always be discarded can_be_called<int(), int&()>::type // mpl::false_, cannot return as reference can_be_called<void(int&), void(int)>::type // mpl::false_, cannot accept rvalue can_be_called<void(), void(*)()>::type // compile error, "void(*)()" not a function-type can_be_called<F, void()>::type // mpl::true_ can_be_called<F const, void()>::type // mpl::false_, F::operator() is non-const can_be_called<void(X::*)(), void()>::type // mpl::true_, only the signature part is concerned can_be_called<void(X::*)(), void(X*)>::type // mpl::false_, implicit 'this' arg not accounted
Repository ---------------- https://github.com/jamboree/boost.functional
test files provided, compile well on g++ 4.7.1 & clang 3.2
No docs are written (yet), if you're interested, please let me know and I'll prepare for review or something...
Comments are welcome :)
Forgot to mention that there are 2 implementations provided, unlimited & limited, limited one can be used w/o variadic template support and has a function-arity limit defined by BOOST_CAN_BE_CALLED_MAX_ARITY. It's shipped with preprocessed headers.