title: Boost.Spirit.Qi grammar for default values in Boost.Fusion adapt struct
body: <pre><code>struct coordinate {
    int x;
    int y;
    int z;
  };
  
  BOOST_FUSION_ADAPT_STRUCT(
    coordinate,
    (int, x)
    (int, y)
    (int, z)
  )
  
  template &lt;typename Iterator&gt;
  struct coordinate_grammar : qi::grammar&lt;Iterator, coordinate(), ascii::space_type&gt;
  {
    coordinate_grammar()
    :
      coordinate_grammar::base_type(start),
      optional_x(-(qi::int_ &gt;&gt; ':')),
      optional_z(-('@' &gt;&gt; qi::int_)),
      start(optional_x &gt;&gt; qi::int_ &gt;&gt; optional_z)
    {
    }
  
    qi::rule&lt;Iterator, int, ascii::space_type&gt; optional_x;
    qi::rule&lt;Iterator, int, ascii::space_type&gt; optional_z;
    qi::rule&lt;Iterator, coordinate(), ascii::space_type&gt; start;
  };
  </code></pre>
  
  <p>I would like to set <code>0</code> as the default value of <code>x</code>, and <code>1000</code> as the default value of <code>z</code>.</p>
  
  <p><strong>Input --> Desired Output:</strong></p>
  
  <ul>
  <li><code>200:400@300</code> --> <code>[200,400,300]</code></li>
  <li><code>200:400</code> --> <code>[200,400,1000]</code></li>
  <li><code>400@300</code> --> <code>[0,400,300]</code></li>
  <li><code>400</code> --> <code>[0,400,1000]</code></li>
  </ul>
  
  <p>How do I need to modify the rule syntax to provide a default value when a value has not been specified for the optional <em>(<code>optional_x</code> and <code>optional_z</code>)</em> parsers?</p>