title: Why can I not access the value in a semantic action?
body: <p>I'm trying to write a parser to create an AST using boost::spirit. As a first step I'm trying to wrap numerical values in an AST node. This is the code I'm using:</p>
  
  <pre><code>AST_NodePtr make_AST_NodePtr(const int&amp; i) {
      return std::make_shared&lt;AST_Node&gt;(i);
  }
  
  namespace qi = boost::spirit::qi;
  namespace ascii = boost::spirit::ascii;
  namespace l = qi::labels;
  
   template&lt;typename Iterator&gt;
      struct test_grammar : qi::grammar&lt;Iterator, AST_NodePtr(), ascii::space_type&gt; {
          test_grammar() : test_grammar::base_type(test) {
  
              test = qi::int_ [qi::_val = make_AST_NodePtr(qi::_1)];
          }
          qi::rule&lt;Iterator, AST_NodePtr(), ascii::space_type&gt; test;
  
      }; 
  </code></pre>
  
  <p>As far as I understood it from the documentation q::_1 should contain the value parsed by qi::int_, but the above code always gives me an error along the lines</p>
  
  <pre><code>invalid initialization of reference of type ‘const int&amp;’ from expression of type ‘const _1_type {aka const boost::phoenix::actor&lt;boost::spirit::argument&lt;0&gt; &gt;}
  </code></pre>
  
  <p>Why does this not work even though qi::_1 is supposed to hold the parsed valued? How else would I parse the input into a custom AST?</p>