Boost logo

Boost :

Subject: Re: [boost] boost::bind result type
From: Daniel Walker (daniel.j.walker_at_[hidden])
Date: 2010-07-22 21:53:03


On Tue, Jul 20, 2010 at 8:16 PM, Steven Watanabe <watanabesj_at_[hidden]> wrote:
> AMDG
>
> Daniel Walker wrote:
>>
>> Actually, I just looked into it, and this wasn't as hard as I thought.
>> So, I can be a little more specific about the needed changes. As a
>> proof of concept, I have attached a patch that allows the following
>> where the bind object is stored directly by boost::function without
>> type erasure.
>>
>> #include <functional>
>> #include <boost/function.hpp>
>> #include <boost/bind.hpp>
>>
>> int main()
>> {
>>    using namespace boost;
>>    function<
>>         bind_signature(std::plus<int>,boost::arg<1>,int)
>>    > f = bind(std::plus<int>(), _1, 1);
>> }
>>
>
> If you're going to specify all the parameters of the
> bind expression in the type of the boost::function, you'd
> be better off just having a metafunction for deducing the
> return type of bind.

Yep, that would work too. I'm just trying to show that boost::function
could be extended to store bind objects without the type erasure
overhead.

Daniel Walker


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