Re: [Boost-users] boost::lambda question
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Rob Caldecott Sent: Saturday, March 11, 2006 12:36 PM To: boost-users@lists.boost.org 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.
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@solidworks.com> wrote in message news:ED67712627032740B15C91998D43FB4C0242C9AE@corp-mail4.solidworks.swk...
-----Original Message----- From: boost-users-bounces@lists.boost.org [mailto:boost-users- bounces@lists.boost.org] On Behalf Of Rob Caldecott Sent: Saturday, March 11, 2006 12:36 PM To: boost-users@lists.boost.org 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.
Rob Caldecott wrote:
Hi Nat,
I tried that, and it still fails. I *think* it is because DeleteFileW is defined as a WINAPI function (or "__stdcall").
That's indeed the reason. There is a macro you can define to make Boost.Bind (but not Boost.Lambda) support __stdcall. http://www.boost.org/libs/bind/bind.html#Q_win32_api Sebastian Redl
participants (3)
-
Nat Goodspeed
-
Rob Caldecott
-
Sebastian Redl