|
Boost : |
Subject: Re: [boost] [lambda] Can't get simple lambda working...
From: Robert Dailey (rcdailey_at_[hidden])
Date: 2012-03-19 19:04:35
Actually never mind. It still doesn't work when I remove const. Apologies
for the confusion. I'm back to square one.
---------
Robert Dailey
On Mon, Mar 19, 2012 at 6:02 PM, Robert Dailey <rcdailey_at_[hidden]> wrote:
> Seems to be a problem with the std::vector being passed in as const
> reference. If I remove the const qualifier it compiles fine.
> MessageAttachment::name() is defined as const so it should work; no idea
> why const breaks it.
>
> ---------
> Robert Dailey
>
>
>
> On Mon, Mar 19, 2012 at 5:44 PM, Robert Dailey <rcdailey_at_[hidden]> wrote:
>
>> Here is a basic function I have:
>>
>>
>> bool MimeDocument::GetExistingAttachment(
>> std::string const& filename,
>> std::vector<MessageAttachment> const& attachments,
>> MessageAttachment& attachment
>> )
>> {
>> using namespace boost::lambda;
>> using boost::lambda::_1;
>>
>> std::vector<MessageAttachment>::const_iterator it =
>> std::find_if( attachments.begin(), attachments.end(),
>> bind( &MessageAttachment::name, _1 ) == filename
>> );
>>
>> if( it != attachments.end() ) {
>> attachment = *it;
>> return true;
>> }
>>
>> return false;
>> }
>>
>> MessageAttachment::name() has 2 overloads, one that takes 1 parameter and
>> the other that takes no parameter. I'm attempting to call the version that
>> accepts no parameters and returns a "char const*". I want to then compare
>> this value to the local variable "filename".
>>
>> This should happen for each object in the vector (_1).
>>
>> I get various types of compiler errors on MSVC9. They all have to do with
>> C2780:
>>
>> 1>c:\code\work\cmake-mds\server\gmmserver\domino\server\interface\dimime.cpp(287)
>> : error C2780: 'const
>> boost::lambda::lambda_functor<boost::lambda::lambda_functor_base<boost::lambda::action<10,boost::lambda::function_action<10,T>>,detail::bind_tuple_mapper<const
>> Arg1,const Arg2,const Arg3,const Arg4,const Arg5,const Arg6,const
>> Arg7,const Arg8,const Arg9,const Arg10>::type>> boost::lambda::bind(const
>> Arg1 &,const Arg2 &,const Arg3 &,const Arg4 &,const Arg5 &,const Arg6
>> &,const Arg7 &,const Arg8 &,const Arg9 &,const Arg10 &)' : expects 10
>> arguments - 2 provided
>> 1>
>> c:\code\work\cmake-mds\build-vc9\third_party\boost\1.48.0\include\boost\lambda\detail\bind_functions.hpp(1743)
>> : see declaration of 'boost::lambda::bind'
>>
>> Anyone have any idea what I'm doing wrong?
>>
>> ---------
>> Robert Dailey
>>
>
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk