I have written a working token parser based on the code shown at spirit lex example 4
One of my rules looks like this
set_name
= ( tok.set_ >> tok.name_ >> tok.identifier )
[
std::cout << val("set name statement to: ") << _3 << "\n"
]
;
This works well. When presented with
SET NAME xyz
it outputs as I expect
set name statement to: xyz
Now I want to do something useful, store the name found into a class. Working from parser semantic examples I write this code
class writer
{
public:
void print(string const& s) const
{
std::cout << s << std::endl;
}
};
writer w;
...
set_name
= ( tok.set_ >> tok.name_ >> tok.identifier )
[
boost::bind( &writer::print, &w, ::_3 )
]
;
This does not compile
1>C:\Program Files\boost\boost_1_44\boost/bind/bind.hpp(318) : error C2664: 'R boost::_mfi::cmf1::operator ()(const U &,A1) const' : cannot convert parameter 2 from 'bool' to 'const std::basic_string ' 1> with 1> [ 1> R=void, 1> T=eCrew::rule::writer, 1> A1=const std::string &, 1> U=eCrew::rule::writer * 1> ] 1> and 1> [ 1> _Elem=char, 1> _Traits=std::char_traits, 1> _Ax=std::allocator 1> ] 1> Reason: cannot convert from 'bool' to 'const std::string' 1> No constructor could take the source type, or constructor overload resolution was ambiguous
Why is the compiler complaining about a trying to convert from bool to string? There is no bool that I can see.