Boost logo

Boost Users :

Subject: Re: [Boost-users] Compilation/syntax error Boost.Lambda
From: Joost Kraaijeveld (J.Kraaijeveld_at_[hidden])
Date: 2010-02-05 11:29:07


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;
        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.

TIA

-- 
Groeten,
Joost Kraaijeveld
Askesis B.V.
Molukkenstraat 14
6524NB Nijmegen
tel: 024-3888063 / 06-51855277
fax: 024-3608416
web: www.askesis.nl

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