Boost logo

Boost :

Subject: [boost] [functional] Interested in can_be_called<F, Sig> metafunction?
From: TONGARI (tongari95_at_[hidden])
Date: 2012-11-04 08:15:16


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 :)


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