|
Boost : |
From: Mat Marcus (mmarcus-boost_at_[hidden])
Date: 2003-08-26 10:10:21
It is not uncommon to use boost::function to hold on to the result of
boost::bind. Will that work for you?
- Mat
--On Tuesday, August 26, 2003 4:17 PM +0200 Daniel Frey
<daniel.frey_at_[hidden]> wrote:
> In my current project, there are a lot of code fragments that read
> like this:
>
> result->insert( "positions",
> positions_.begin(),
> positions_.end(),
> bind( &Position::serialize,
> _1,
> boost::cref( locale ) ) );
>
> The scheme is always the same, all that varies is the name of the
> serialized class. Thus I wanted to write a helper:
>
> result->insert( "positions",
> positions_.begin(),
> positions_.end(),
> serializer< Position >( locale ) );
>
> But the problem is, that AFAIK I have no (documented) way to specify
> the result type of such a helper function. The syntax I would
> imagine basically looks like this:
>
> template< typename T >
>
> typename Bind< &T::serialize, _1_type,
> boost::reference_wrapper< const Base::Locale > >::result_type
>
> serializer( const Base::Locale& locale ) {
> return bind( &T::serialize, _1, boost::cref( locale ) );
> }
>
> Is something like that possible? I hope so, but I guess I'm not the
> expert to understand all the details involved in the bind-internals.
> The above is just an idea, of course it might look different in
> practice. The question is, whether we can create some mapping
> between the call of the bind-function and a provider for the result
> type that users can understand without looking into the code of bind
> itself.
>
> Regards, Daniel
>
> --
> Daniel Frey
>
> aixigo AG - financial training, research and technology
> Schloß-Rahe-Straße 15, 52072 Aachen, Germany
> fon: +49 (0)241 936737-42, fax: +49 (0)241 936737-99
> eMail: daniel.frey_at_[hidden], web: http://www.aixigo.de
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk