Boost logo

Boost Users :

From: Jean-Pierre Bergamin (james_at_[hidden])
Date: 2008-02-01 07:43:07


Hello everyone

I ran into an issue I cannot explain, when using bind with the string
algorithms.
The following code fragment works as expected with MSVC 8.0:

#include <boost/algorithm/string/predicate.hpp>
#include <boost/bind.hpp>
#include <iostream>
#include <vector>
#include <string>

using namespace std;
using namespace boost;
using namespace boost::algorithm;

int main() {
    typedef vector<string> string_container;
    string_container numbers;
    numbers.push_back("one");
    numbers.push_back("two");
    numbers.push_back("three");

    string_container::const_iterator s = find_if(numbers.begin(),
numbers.end(),
        bind(&contains<string, string>, _1, "w"));

    if (s != numbers.end()) {
        cout << "Found: " << *s << endl;
    }

    return 0;
}

Trying to compile the same code with gcc 3.4.5 gives the error:
test.cpp:18: error: no matching function for call to `bind(<unknown type>,
boost::arg<1> (&)(), const char[2])'

Does anyone has an idea how to let bind know the "type" of the predicate
"contains"?

Regards

Jean-Pierre Bergamin


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