|
Boost Users : |
Subject: Re: [Boost-users] Compilation/syntax error Boost.Lambda
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2010-02-05 11:39:22
AMDG
Joost Kraaijeveld wrote:
> On Fri, 2010-02-05 at 07:50 -0800, Steven Watanabe wrote:
>
>>> bind(&map<string, string>::insert,
>>>
>> insert is overloaded and the compiler doesn't know which one you mean.
>> You'll need to cast it to the right type.
>> See also http://www.gotw.ca/gotw/064.htm
>>
> Based on your answer and the Boost lambda docs
> (http://www.boost.org/doc/libs/1_42_0/doc/html/lambda/le_in_details.html#lambda.bind_expressions)
> I changed the code to:
> ...
> template< typename Predicate >
> map<string, string> getObjectsFromMap( const Predicate& aPredicate)
> {
> pair< map< string, string >::iterator, bool > (*InsertFn)(const map<string, string>::value_type&) = &map<string, string>::insert;
>
Try pair<...> (map<string, string>::* InsertFn)(const
map<...>::value_type&) = ...;
> map<string, string> matchedObjects;
> for_each( objectsMap.begin(),
> objectsMap.end(),
> if_then(
> bind(aPredicate, _1) ,
> bind(InsertFn,
> &matchedObjects ,
> make_pair(bind(&map<string, string>::value_type::first, _1),bind(&map<string, string>::value_type::second,_1)))));
> return matchedObjects;
> }
>
> But that gives me more errors than I could imagine. Could you give me a
> bit more info as I am really lost here.
>
In Christ,
Steven Watanabe
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net