I want to parse a floating point number in a text file and insert it in a symbol table; the parser and the symbol table are provided by spirit::qi.
Here is my code:
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/phoenix.hpp>
#include <stdint.h>
#include <iostream>
#include <string>
template<typename VTYPE>
struct VTable : boost::spirit::qi::symbols<char, VTYPE> {
VTable() {} // empty
};
int main() {
using boost::spirit::qi::_1;
using boost::spirit::qi::eps;
using boost::spirit::qi::rule;
using boost::spirit::qi::ascii::space;
using boost::spirit::qi::space_type;
using boost::spirit::qi::real_parser;
using boost::spirit::qi::int_parser;
using boost::spirit::qi::strict_real_policies;
VTable<double> floatDecs;
floatDecs.add("hallo", 15.26)("duDa", 18.5);
const std::string some = "some";
rule<std::string::iterator, double> value = real_parser<double, strict_real_policies<double>>() [ boost::phoenix::bind(&VTable<double>::add, floatDecs, boost::phoenix::cref(some), _1) ];
std::cout << boost::spirit::qi::phrase_parse(test.begin(), test.end(), value, space);
return 0;
}
The problem in here lies in boost::phoenix::bind, but I do not know, how to fix that (I am fairly new to this library).