title: Compiling a simple parser with Boost.Spirit
body: <p>Part of a simple skeleton utility I'm hacking on I have a grammar for triggering substitutions in text. I thought it a wonderful way to get comfortable with Boost.Spirit, but the template errors are a joy of a unique kind.</p>
  
  <p>Here is the code in its entirety:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iterator&gt;
  #include &lt;boost/spirit/include/qi.hpp&gt;
  #include &lt;boost/spirit/include/phoenix.hpp&gt;
  
  namespace bsq = boost::spirit::qi;
  
  namespace {
  template&lt;typename Iterator&gt;
  struct skel_grammar : public bsq::grammar&lt;Iterator&gt; {
      skel_grammar();
  
  private:
      bsq::rule&lt;Iterator&gt; macro_b;
      bsq::rule&lt;Iterator&gt; macro_e;
      bsq::rule&lt;Iterator, bsq::ascii::space_type&gt; id;
      bsq::rule&lt;Iterator&gt; macro;
      bsq::rule&lt;Iterator&gt; text;
      bsq::rule&lt;Iterator&gt; start;
  };
  
  template&lt;typename Iterator&gt;
  skel_grammar&lt;Iterator&gt;::skel_grammar() : skel_grammar::base_type(start)
  {
      text = bsq::no_skip[+(bsq::char_ - macro_b)[bsq::_val += bsq::_1]];
      macro_b = bsq::lit("&lt;&lt;");
      macro_e = bsq::lit("&gt;&gt;");
      macro %= macro_b &gt;&gt; id &gt;&gt; macro_e;
      id %= -(bsq::ascii::alpha | bsq::char_('_'))
          &gt;&gt; +(bsq::ascii::alnum | bsq::char_('_'));
      start = *(text | macro);
  }
  }  // namespace
  
  int main(int argc, char* argv[])
  {
      std::string input((std::istreambuf_iterator&lt;char&gt;(std::cin)),
                        std::istreambuf_iterator&lt;char&gt;());
      skel_grammar&lt;std::string::iterator&gt; grammar;
      bool r = bsq::parse(input.begin(), input.end(), grammar);
      std::cout &lt;&lt; std::boolalpha &lt;&lt; r &lt;&lt; '\n';
      return 0;
  }
  </code></pre>
  
  <p>What's wrong with this code?</p>