
OK, thanks to Sebastian and Nat, plus some Google group searches, I found a solution, which is, in a nutshell - #define BOOST_BIND_ENABLE_STDCALL: Here is a sample: #include <windows.h> #include <string> #include <vector> #include <algorithm> #define BOOST_BIND_ENABLE_STDCALL #include <boost/bind.hpp> int _tmain(int argc, _TCHAR* argv[]) { using namespace std; using namespace boost; vector<wstring> v; v.push_back(L"test.txt"); for_each(v.begin(), v.end(), bind(&DeleteFileW, bind(&wstring::c_str, _1))); return 0; } Without enabling BOOST_BIND_ENABLE_STDCALL, the bind on ::DeleteFileW would fail. "Robert Caldecott" <robert.caldecott@gmail.com> wrote in message news:2b1e8f000603110418u3f4746fbreeac69e61aac3047@mail.gmail.com...
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()));