Reputation: 222
I'm trying to set karmas generator-value by a semantic action, however, it won't compile. I can't find the reson why, as I'm quite sure I use it as explained in the documentation. As I'm new to karma it's most likely I did some rookie mistake. A minimal example:
#include <boost/spirit/include/karma.hpp>
#include <boost/spirit/include/karma_int.hpp>
#include <boost/spirit/include/karma_generate.hpp>
namespace karma = boost::spirit::karma;
int main() {
std::string s;
std::back_insert_iterator<std::string> out(s);
boost::spirit::karma::generate(out,karma::int_[karma::_1=2]); //won't compile
//boost::spirit::karma::generate(out,karma::int_,2); this compiles and works
std::cout<<s;
}
results in the comipler error:
error: no viable overloaded '='
I'm using g++ 4.6.3 and boost 1.48.
Upvotes: 1
Views: 221
Reputation:
You are missing some headers to include. You can either use:
#include <boost/spirit/include/phoenix_operator.hpp>
that includes the operators needed for this to work, or:
#include <boost/spirit/include/phoenix.hpp>
that includes everything about Boost.Phoenix. On LWS.
Upvotes: 1