Jump to content

  • Log In with Google      Sign In   
  • Create Account


Boost phoenix find_if?


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
2 replies to this topic

#1 lephyrius   Members   -  Reputation: 263

Like
0Likes
Like

Posted 12 May 2010 - 02:43 AM

I am trying to learn boost phoenix. Here I am trying to find the test object based on their name using a property. This is a small test case:
#include <boost/spirit/home/phoenix/algorithm.hpp>
#include <boost/spirit/home/phoenix/stl/algorithm/querying.hpp>
#include <boost/spirit/include/phoenix_core.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/home/phoenix/bind/bind_member_function.hpp>
#include <vector>

class Test
{
public:
	Test(const std::string& _name = "");
	const std::string& Name() const;
	void Name(const std::string& _name);
protected:
private:
	std::string name;
};

Test::Test(const std::string& _name) : name(_name) {

}

const std::string& Test::Name() const {
	return name;
}

void Test::Name(const std::string& _name) {
	name = _name;
}

typedef std::vector<Test> ChildVector;
void fetch() {
	std::string name = "bob";
	ChildVector children;
        // Here comes the evil error code
	ChildVector::iterator it = std::find_if( children.begin(), children.end(),((Test&)(boost::phoenix::arg_names::_1)).Name()  == name);
}

I get lots of error. I am using Visual Studio 2010.

Sponsor:

#2 Antheus   Members   -  Reputation: 2397

Like
0Likes
Like

Posted 12 May 2010 - 03:28 AM

Quote:
((Test&)(boost::phoenix::arg_names::_1)).Name()  == name);


Shouldn't this be:
boost::phoenic::arg_names::arg1


#3 lephyrius   Members   -  Reputation: 263

Like
0Likes
Like

Posted 12 May 2010 - 03:42 AM

Quote:
Original post by Antheus
Quote:
((Test&)(boost::phoenix::arg_names::_1)).Name()  == name);


Shouldn't this be:
boost::phoenic::arg_names::arg1


I tested and i got:

1>c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm(83): error C2064: term does not evaluate to a function taking 1 arguments
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\algorithm(95) : see reference to function template instantiation '_InIt std::_Find_if<Test*,_Pr>(_InIt,_InIt,_Pr)' being compiled
1> with
1> [
1> _InIt=Test *,
1> _Pr=bool
1> ]
1> test.cpp(67) : see reference to function template instantiation '_InIt std::find_if<std::_Vector_iterator<_Myvec>,bool>(_InIt,_InIt,_Pr)' being compiled
1> with
1> [
1> _InIt=std::_Vector_iterator<std::_Vector_val<Test,std::allocator<Test>>>,
1> _Myvec=std::_Vector_val<Test,std::allocator<Test>>,
1> _Pr=bool
1> ]




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS