ptr_fun с лямбда-функцией

У меня есть следующая программа, которая использует ptr_fun с лямбда-функцией.

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>

using namespace std;
int main()
{
    string target="aa";
    vector<string> v1;
    v1.push_back("aa");
    v1.push_back("bb");
    auto stringcasecmp=[](string lhs, string rhs)->int
    {
        return strcasecmp(lhs.c_str(), rhs.c_str());
    };

    auto pos = find_if(
        v1.begin(), v1.end(),
        not1( bind2nd(ptr_fun(stringcasecmp), target) )
        );

    if ( pos != v1.end())
    cout <<   "The search for `" << target << "' was successful.\n"
        "The next string is: `" << pos[1] << "'.\n";
}

Я получаю следующие сообщения об ошибках.

stackoverflow.cpp: In function ‘int main()’:
stackoverflow.cpp:21:41: error: no matching function for call to ‘ptr_fun(main()::<lambda(std::string, std::string)>&)’
stackoverflow.cpp:22:6: error: unable to deduce ‘auto’ from ‘<expression error>’

Как мне изменить код (минимально), чтобы он скомпилировался?

5
задан ggg 12 December 2011 в 11:32
поделиться