Subject: Re: [boost] [review] Conversion review ends today
From: Jeffrey Lee Hellrung, Jr. (jeffrey.hellrung_at_[hidden])
Date: 2011-09-01 01:33:18
2011/8/31 Agustín K-ballo Bergé <kaballo86_at_[hidden]>
> On 01/09/2011 1:29, Gordon Woodhull wrote:
>> I was hoping that there was a way to paste together a bunch of function
>> objects as if they were function overloads.
> Create a new class that keeps references to all such function objects, and
> implements implicit conversions to each of them. Then you can use an
> instance of this class as an "overloaded function object".
Wouldn't that result in a conversion ambiguity? How would the compiler know
which function object to implicitly convert to when invoking operator()?
I would imagine a generic and safe way to do what Gordon is asking is
possible via Eric's can_be_called machinery. operator() for the wrapping
function object checks which of the child function objects "can_be_called"
with the given arguments, and if precisely one match, dispatches to the
matching child, else errors. Less safe but more flexible is to just choose
the first child function object that matches.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk