Boost logo

Boost :

Subject: Re: [boost] Does boost help in creating generic function wrappers?
From: Andy Venikov (avenikov_at_[hidden])
Date: 2010-07-15 11:07:50


Steven Watanabe wrote:
<snip>
>> functional/forward_adapter won't work since it hides function
>> parameters, it only lets you operate with the function.
>
> What do you mean by "hides function parameters"?

Sorry I was unclear.

What I mean was that forward_adapter doesn't let you intercept the
actual function call. You can store the inner functor in the wrapper
which allows a delayed call, but whenever someone calls
wrapper(prms...), you won't have a chance to intercept that call. Of
course, as you suggest below, one could inject one's own functor in
between the inner functor and the forward_adapter, but then one is left
to deal with how to solve forwarding problem on one's own.

>
>> It looks like it may be possible to do that by using boost/preprocessor
>> I'll have to generate a whole lot of overloads with O(2^N) (because of
>> the overload on (T &) or (T const &) for every argument).
>> But it looks pretty dounting. It's basically what forward_adapter had
>> to do.
>>
>> Isn't there a ready-made library that would allow me to generate all
>> of the overloads?
>
> Just define your wrapper to take references, and wrap it in
> forward_adapter.
> This should have exactly the same effect as defining all the overloads
> yourself.

Correct me if I'm wrong, but I think it's not going to work when the
inner functor has (T const &) parameter. If my wrapper declares
everything T &, then it won't be able to accept non-const rvalues
whereas the original functor was able to do that.

>
> In Christ,
> Steven Watanabe
>

Thanks,
    Andy.


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