Boost logo

Boost Users :

Subject: [Boost-users] trouble with spirit (boost 1.39)
From: Noah Roberts (roberts.noah_at_[hidden])
Date: 2010-01-13 18:04:55


void read_formula_line(esi::string_t const& line, table_fluid_data &
data)
{
  namespace sp = boost::spirit::classic;
  using namespace sp;

  unsigned int index = 0;
  parse_info<wchar_t const*> info =
    sp::parse(line.c_str(),
      // begin grammar
      (
          L'P'
>> uint_p[assign_a(index)]
       //>> uint_p[assign_a(data.formulas[index-1].formula_id)]
>> uint_p[boost::bind(&assign_i, _1, boost::ref(data.formulas
[index-1].formula_id))]
>> real_p[boost::bind(&assign_dbl, _1, boost::ref(data.formulas
[index-1].coefficients[0]))]
       //>> real_p[assign_a(data.formulas[index-1].coefficients[0])]
>> real_p[assign_a(data.formulas[index-1].coefficients[1])]
>> real_p[assign_a(data.formulas[index-1].coefficients[2])]
>> real_p[assign_a(data.formulas[index-1].coefficients[3])]
>> real_p[assign_a(data.formulas[index-1].coefficients[4])]
>> lexeme_d[*space_p] // necessary to clip off the last bit.
       )
     , space_p);

  if (!info.full) throw std::runtime_error("Parse fail in formula
line.");
}

The line is being parsed by the above code but the values are not being
assigned by the assign_a nor by the boost::bind call to my own val = x
setters. The setters are being called correctly, but the data is not
getting through for some reason. It's like the data structure is being
copied instead of referenced but I'm explicitely using references.

Any idea what gives?


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net