[phoenix] how to compare std:string

Hi all - I have a vector of std::pair< std::string, int > and I want to use std::find_if to get the location where the std::pair first is some string value. I have successfully performed the correct incantation to compare the std::pair second to an int; however, it eludes me to what I need for the string. This is my test ---------------------------------- #include <vector> #include <algorithm> #include <boost/spirit/home/phoenix/core.hpp> #include <boost/spirit/home/phoenix/operator.hpp> #include <boost/spirit/home/phoenix/bind/bind_member_variable.hpp> int main() { using namespace boost::phoenix; using namespace boost::phoenix::arg_names; typedef std::pair< std::string, int > node_type; typedef std::vector< node_type > node_storage_type; node_storage_type my_nodes; my_nodes.push_back( std::pair< std::string, int >( "foo", 8 ) ); // this works great node_storage_type::iterator iter = std::find_if( my_nodes.begin(), my_nodes.end(), bind( &node_type::second, arg1 ) == 8 ); // compilation error here: ..\..\..\library\vendor\boost_1_38_0\boost/spirit/home/phoenix/operator/comparison.hpp(27) : error C2678: binary '==' : no operator found which takes a left-hand operand of type 'std::basic_string<_Elem,_Traits,_Ax>' (or there is no acceptable conversion) // iter = std::find_if( my_nodes.begin(), my_nodes.end(), bind( &node_type::first, arg1 ) == "foo" ); return 0; } Thanks ! michael -- ---------------------------------- Michael Caisse Object Modeling Designs www.objectmodelingdesigns.com

Michael Caisse wrote:
Hi all -
I have a vector of std::pair< std::string, int > and I want to use std::find_if to get the location where the std::pair first is some string value. I have successfully performed the correct incantation to compare the std::pair second to an int; however, it eludes me to what I need for the string.
This is my test ---------------------------------- [...]
Try: #include <string> Cheers, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net

Joel de Guzman wrote:
Michael Caisse wrote:
Hi all -
I have a vector of std::pair< std::string, int > and I want to use std::find_if to get the location where the std::pair first is some string value. I have successfully performed the correct incantation to compare the std::pair second to an int; however, it eludes me to what I need for the string.
This is my test ---------------------------------- [...]
Try:
#include <string>
Cheers,
How embarrassing. Thank you Joel! -- ---------------------------------- Michael Caisse Object Modeling Designs www.objectmodelingdesigns.com

Michael Caisse wrote:
Joel de Guzman wrote:
Michael Caisse wrote:
Hi all -
I have a vector of std::pair< std::string, int > and I want to use std::find_if to get the location where the std::pair first is some string value. I have successfully performed the correct incantation to compare the std::pair second to an int; however, it eludes me to what I need for the string.
This is my test ---------------------------------- [...]
Try:
#include <string>
Cheers,
How embarrassing. Thank you Joel!
Most welcome. Happens to me all the time, that's why I knew at once :-) Regards, -- Joel de Guzman http://www.boostpro.com http://spirit.sf.net
participants (2)
-
Joel de Guzman
-
Michael Caisse