title: How to tel a boost::karma::rule not to consume its attribute without providing a valid generator?
body: <p>Say we have the following source code:</p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;iterator&gt;
  #include &lt;boost/spirit/include/karma.hpp&gt;
  
  namespace karma = boost::spirit::karma;
  
  template &lt;typename OutputIterator&gt; struct grammar : karma::grammar&lt;OutputIterator, std::nullptr_t()&gt; {
    grammar() : grammar::base_type(query) {
      query =  "yeah";
    }
  
    karma::rule&lt;OutputIterator, std::nullptr_t()&gt; query;
  };
  
  
  int main(void) {
    typedef std::back_insert_iterator&lt;std::string&gt; iterator_type;
    std::string generated;
    iterator_type output_it(generated);
    //keys_and_values&lt;sink_type&gt; g;
    grammar&lt;iterator_type&gt; g;
    bool result = karma::generate(output_it, g, nullptr);
    std::cout &lt;&lt; result &lt;&lt; ":" &lt;&lt; generated &lt;&lt; std::endl;
    return 0;
  }
  </code></pre>
  
  <p>This fails to compile because <code>karma</code> lacks some traits for <code>std::nullptr_t</code> (those are <code>boost::spirit::traits::extract_c_string</code> and <code>boost::spirit::traits::char traits</code>). More specifically, it fails because <code>karma</code> is not able to find a generator for an attribute of type <code>std::nullptr_t</code>.</p>
  
  <p>I see several ways to cope with that:</p>
  
  <ol>
  <li><strong>Replace <code>std::nullptr_t</code> by <code>karma::unused_type</code> in the grammar definition</strong> : It works on this example but may introduce ambiguity in a more complex grammar.</li>
  <li><strong>Defining the traits specialization</strong> : In my opinion, this is dirty and not generic. Plus, it exposes my specialization of a standard type for everyone, leading to potential conflicts.</li>
  <li><strong><a href="http://www.boost.org/doc/libs/1_55_0/libs/spirit/doc/html/spirit/advanced/customize/transform.html" rel="nofollow">Specializing an attribute transform</a></strong> : Same problem of specializing a standard type just for me.</li>
  <li><strong><a href="http://boost-spirit.com/home/articles/karma-examples/creating-your-own-generator-component-for-spirit-karma/" rel="nofollow">Write a custom generator</a></strong> : The best candidate so far, but it makes a serious load of highly templated code lines compared to the task complexity.</li>
  <li><strong>Put a intermediate rule with a <code>karma::unused_type</code> attribute</strong>. A quick fix that works but have no sense.</li>
  </ol>
  
  <p><strong>Question</strong> : How can I tell the <code>karma::rule</code> to generate a simple literal and not care about having or not a generator for its attribute ?</p>