Boost logo

Boost :

Subject: Re: [boost] boost::bind result type
From: Daniel Walker (daniel.j.walker_at_[hidden])
Date: 2010-07-20 12:43:09


On Tue, Jul 20, 2010 at 12:09 PM, Steven Watanabe <watanabesj_at_[hidden]> wrote:
> AMDG
>
> David Sankel wrote:
>>
>> Thanks for clarifying what I meant by awkward. Is it possible, and if so
>> how, to make a generic solution? The main problem I see is bind taking a
>> type argument in some cases. Could boost.bind be modified to expose a
>> result
>> type? I haven't seen any reasons yet for bind not including this really
>> useful feature.
>>
>
> I believe that there's an open feature request for Boost.Typeof emulation
> support for Boost.Bind.  If you're willing to live with your code only
> working on gcc, msvc, and any other compilers that have a built-in
> typeof or decltype, then you can use Boost.Typeof in native mode
> now.

That's a good idea. That would help bridge the C++03/0x gap.

Here's another idea that we might be able to pursue in the future. The
original complaint is not that there isn't a general way to return a
bind object; you can use boost::function. The complaint is that
boost::function isn't optimal, since it precludes inlining. So,
another approach would be to provide an optimized specialization of
boost::function for bind objects; i.e. boost::function could leverage
implementation specific details of boost::bind to store bind objects
optimally. It makes sense that Boost libraries would be optimized when
used with other Boost libraries, and presumably, stdlib venders will
look for similar opportunities for internal optimization in order to
differentiate themselves. I'm not sure if this is possible, but it
might be something worth looking into.

Daniel Walker


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