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