title: Add to a spirit qi symbol table in a semantic action
body: <p>Going by the opening paragraph of the <a href="http://www.boost.org/doc/libs/1_50_0/libs/spirit/doc/html/spirit/qi/reference/string/symbols.html" rel="nofollow">boost::spirit::qi::symbols documentation</a>, I assumed that it wouldn't be too hard to add symbols to a qi::symbols from a semantic action. Unfortunately it appears to be not as straightforward as I would have assumed.</p>
  
  <p>The following bit of test code exhibits the problem:</p>
  
  <pre><code>#define BOOST_SPIRIT_USE_PHOENIX_V3
  #include &lt;boost/spirit/include/qi.hpp&gt;
  #include &lt;boost/spirit/include/phoenix.hpp&gt;
  #include &lt;string&gt;
  
  namespace qi = boost::spirit::qi;
  
  typedef qi::symbols&lt;char, unsigned int&gt; constants_dictionary;
  
  template &lt;typename Iter&gt; struct parser : public qi::grammar&lt;Iter, qi::space_type&gt; {
  
      parser(constants_dictionary &amp;dict) : parser::base_type(start) {
  
          start = qi::lit("@") &gt;&gt; ((+qi::char_) &gt;&gt; qi::uint_)[dict.add(qi::_1, qi::_2)];
      }
  
      qi::rule&lt;Iter&gt; start;
  };
  
  int main() {
      constants_dictionary dict;
      parser&lt;std::string::const_iterator&gt; prsr(dict);
      std::string test = "@foo 3";
      parse(test.begin(), test.end(), prsr, qi::space);
  }
  </code></pre>
  
  <p>Gives type errors related to qi::_2 from VS2010:</p>
  
  <pre><code>C:\Users\k\Coding\dashCompiler\spirit_test.cpp(12) : error C2664: 'const boost::
  spirit::qi::symbols&lt;Char,T&gt;::adder &amp;boost::spirit::qi::symbols&lt;Char,T&gt;::adder::o
  perator ()&lt;boost::spirit::_1_type&gt;(const Str &amp;,const T &amp;) const' : cannot conver
  t parameter 2 from 'const boost::spirit::_2_type' to 'const unsigned int &amp;'
          with
          [
              Char=char,
              T=unsigned int,
              Str=boost::spirit::_1_type
          ]
          Reason: cannot convert from 'const boost::spirit::_2_type' to 'const uns
  igned int'
          No user-defined-conversion operator available that can perform this conv
  ersion, or the operator cannot be called
          C:\Users\k\Coding\dashCompiler\spirit_test.cpp(10) : while compiling cla
  ss template member function 'parser&lt;Iter&gt;::parser(constants_dictionary &amp;)'
          with
          [
              Iter=std::_String_const_iterator&lt;char,std::char_traits&lt;char&gt;,std::al
  locator&lt;char&gt;&gt;
          ]
          C:\Users\k\Coding\dashCompiler\spirit_test.cpp(21) : see reference to cl
  ass template instantiation 'parser&lt;Iter&gt;' being compiled
          with
          [
              Iter=std::_String_const_iterator&lt;char,std::char_traits&lt;char&gt;,std::al
  locator&lt;char&gt;&gt;
          ]
  </code></pre>
  
  <p>(Apologies for the nasty VS2010 error-style)</p>
  
  <p>What syntax am I supposed to be using to add (and later on, remove) symbols from this table?</p>