Boost logo

Boost Users :

From: Raúl Huertas (raulh39_at_[hidden])
Date: 2007-03-28 13:02:57


Jason Ivey escribió:
> Is there any way to use the string algorithm predicates and other facilities
> in conjunction with the standard algorithms (IE. for_each, find_if, etc.)?
> For example I am trying to make the following example work in MSVC8:
>
> typedef std::vector<std::string> Strs;
> Strs strs;
> strs.push_back("bob");
> strs.push_back("lisa");
> strs.push_back("eric");
>
> Strs::const_iterator iter = find_if( strs.begin(),
> strs.end(),
> boost::bind(
> &istarts_with, _1, "B", std::locale() ) );
> std::cout << "Found: " << std::boolalpha << ( iter == strs.end() ) <<
> std::endl;
>
> I would be grateful for any comments or suggestions.
>
>

istarts_with is a template, when you want to use it with bind, you have
to tell the compiler all the templates parameter.

Just use:
&boost::istarts_with<std::string,std::string>
as the first parameter to bind.

> Thanks, Jason
>
>
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users
>
>
>


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