Boost logo

Boost Users :

From: Rob Caldecott (robert.caldecott_at_[hidden])
Date: 2006-03-11 13:00:59


Hi Nat,

I tried that, and it still fails. I *think* it is because DeleteFileW is
defined as a WINAPI function (or "__stdcall").

For example, using boost::bind, the following will work:

void Delete(const wchar_t* filename)
{
 ::DeleteFile(filename);
}
...
for_each(v.begin(), v.end(), bind(&Delete, bind(&wstring::c_str, _1)));

However, the following fails:

for_each(v.begin(), v.end(), bind(&::DeleteFileW, bind(&wstring::c_str,
_1)));

with:

c:\boost\include\boost-1_33_1\boost\bind.hpp(63) : error C2825: 'F': must be
a class or namespace when followed by '::'
        c:\boost\include\boost-1_33_1\boost\bind\bind_template.hpp(15) : see
reference to class template instantiation 'boost::_bi::result_traits<R,F>'
being compiled
        with
        [
            R=boost::_bi::unspecified,
            F=int (__stdcall *)(LPCWSTR)
        ]
        c:\tmp\boost\boost\boost.cpp(46) : see reference to class template
instantiation 'boost::_bi::bind_t<R,F,L>' being compiled
        with
        [
            R=boost::_bi::unspecified,
            F=BOOL (__stdcall *)(LPCWSTR),
            L=boost::_bi::list1<boost::_bi::bind_t<const wchar_t
*,boost::_mfi::cmf0<const wchar_t
*,std::basic_string<wchar_t,std::char_traits<wchar_t>,std::allocator<wchar_t>>>,boost::_bi::list1<boost::arg<1>>>>
        ]
c:\boost\include\boost-1_33_1\boost\bind.hpp(63) : error C2039:
'result_type' : is not a member of '`global namespace''
c:\boost\include\boost-1_33_1\boost\bind.hpp(63) : error C2146: syntax error
: missing ';' before identifier 'type'
c:\boost\include\boost-1_33_1\boost\bind.hpp(63) : error C2208:
'boost::_bi::type' : no members defined using this type
c:\boost\include\boost-1_33_1\boost\bind.hpp(63) : fatal error C1903: unable
to recover from previous error(s); stopping compilation

"Nat Goodspeed" <ngoodspeed_at_[hidden]> wrote in message
news:ED67712627032740B15C91998D43FB4C0242C9AE_at_corp-mail4.solidworks.swk...
>> -----Original Message-----
>> From: boost-users-bounces_at_[hidden] [mailto:boost-users-
>> bounces_at_[hidden]] On Behalf Of Rob Caldecott
>> Sent: Saturday, March 11, 2006 12:36 PM
>> To: boost-users_at_[hidden]
>> Subject: Re: [Boost-users] boost::lambda question
>>
>> Thanks Sebastian, but I am still struggling to make this work. I now
> get
>> the following error:
>>
>> "error C2664: 'DeleteFileW' : cannot convert parameter 1 from 'const
>> boost::lambda::lambda_functor<T>' to 'LPCWSTR'"
>
> [Nat] Don't you have to bind DeleteFileW as well? Something like
> (untested):
>
> for_each(v.begin(), v.end(), bind(::DeleteFileW,
> bind(&wstring::c_str, _1)));
>
> I think this phrasing should work with either boost::lambda::bind or
> boost::bind.


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