|
Boost : |
Subject: Re: [boost] [functional] Interested in can_be_called<F, Sig> metafunction?
From: Matt Calabrese (rivorus_at_[hidden])
Date: 2012-11-04 14:54:49
On Sun, Nov 4, 2012 at 2:23 PM, Mathias Gaunard <
mathias.gaunard_at_[hidden]> wrote:
> Personally, I've found it more useful to just not define
> result_of<F(args)>::type if F(args) cannot be called.
>
The only problem with that is that you have to rely on the creator of a
function object to abide by this convention. "can_be_called" (callable
might be a simpler name and is what was used with C++0x concepts) would
work regardless of whether or not result_of is defined.
Anyway, +1 from me to the idea of a can_be_called metafunction. Just
because it might be something to consider in terms of interface, the way
Callable was with concepts was defined is the following (
http://generic.nfshost.com/generic/standard_concepts/concepts/callable.html
):
////////////////////////////////////////////////////////////////////////////////
auto concept Callable
<file:///E:/boost_sandbox/generic/libs/doc/html/boost_generic/standard_concepts/concepts/callable.html><typename
F, typename... Args> {
typename result_type;
result_type operator()(F&, Args...);
result_type operator()(F&&, Args...);}
////////////////////////////////////////////////////////////////////////////////
So, instead of specifying the return type when invoking the metafunction,
it automatically defines an associated type "result_type," which a
programmer could then check against if he or she desired. Again, your
implementation may be more useful depending on the context, but this is
something to consider.
-- -Matt Calabrese
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk