String Algo used with std algorithms
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::vectorstd::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. Thanks, Jason
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::vectorstd::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_withstd::string,std::string as the first parameter to bind.
Thanks, Jason
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
Jason Ivey
-
Raúl Huertas