11 May
2003
11 May
'03
8:31 p.m.
Slava Akhmechet wrote:
I was able to get boost::bind working to bind the semantic action to the member function of MyGrammar. This seems like a superior solution. In any case, I am not sure how to pass custom data to a functor. When specifing a semantic action I have to pass the type of the functor, which implies that spirit creates a temporary object. Am I missing something?
No, you pass an instance of the functor, which can be cosntructed with arbitrary arguments. struct functor { f(char const *s) : msg(s) {} template<class Iter> void operator(Iter, Iter) { std::cout << this->msg; } char const *msg; }; parse(something, something_p[functor("something")]); -- Rainer Deyke - rainerd@eldwood.com - http://eldwood.com