Boost logo

Boost Users :

From: Robert Caldecott (robert.caldecott_at_[hidden])
Date: 2006-03-11 07:18:28


OK, I'm a bit of a boost noob. I have a container of std::wstring's
and I want to use a lambda expression in a for_each loop to pass each
string to a WinAPI function - however, I need access to the c_str()
method, and this is giving me a problem.

For example, if I want to use the DeleteFile WinAPI call, I want to
write something like:

std::vector<std::wstring> v;
...
for_each(v.begin(), v.end(), ::DeleteFile(_1));

But the above won't work as I need to pass the 'C' string to ::DeleteFile.

So, I really want to be able to do something like this:

for_each(v.begin(), v.end(), ::DeleteFile(_1.c_str()));

Any ideas how I can access a member function (like c_str()) using a
lambda placeholder?


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