Boost C++ Libraries: Ticket #6948: Boost::spirit::karma generator bug https://svn.boost.org/trac10/ticket/6948 <p> I wanna save a generator so that I can call it anytime without writing duplicate codes. Here is my code: </p> <p> #include&lt;boost/spirit/include/karma.hpp&gt; #include&lt;boost/spirit/include/karma_format_attr.hpp&gt; #include&lt;list&gt; #include&lt;iostream&gt; </p> <p> <em>auto par = '{' &lt;&lt; -(boost::spirit::karma::int_ % ',') &lt;&lt; '}';</em>This would lead error! int main(){ </p> <blockquote> <p> using namespace std; namespace karma = boost::spirit::karma; list&lt;int&gt; l{1, 2, 4}; auto par = '{' &lt;&lt; -(boost::spirit::karma::int_ % ',') &lt;&lt; '}';<em>This would not! cout&lt;&lt;karma::format(par, l)&lt;&lt;endl; return 0; </em></p> </blockquote> <p> } </p> <p> When I define par out of a functint would leads to runtime error. Does I used it generator in a wrong way or it is a bug? GCC version 4.6.3 </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/6948 Trac 1.4.3 yaoyuan1216@… Mon, 28 May 2012 01:58:45 GMT attachment set https://svn.boost.org/trac10/ticket/6948 https://svn.boost.org/trac10/ticket/6948 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">2.cpp</span> </li> </ul> Ticket Joel de Guzman Mon, 28 May 2012 02:31:53 GMT owner changed https://svn.boost.org/trac10/ticket/6948#comment:1 https://svn.boost.org/trac10/ticket/6948#comment:1 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Joel de Guzman</span> to <span class="trac-author">Hartmut Kaiser</span> </li> </ul> Ticket Hartmut Kaiser Mon, 28 May 2012 14:06:27 GMT status changed; resolution set https://svn.boost.org/trac10/ticket/6948#comment:2 https://svn.boost.org/trac10/ticket/6948#comment:2 <ul> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">invalid</span> </li> </ul> <p> Use BOOST_AUTO instead (see here: <a class="ext-link" href="http://boost-spirit.com/home/articles/qi-example/zero-to-60-mph-in-2-seconds/"><span class="icon">​</span>http://boost-spirit.com/home/articles/qi-example/zero-to-60-mph-in-2-seconds/</a>). The article explains the rationale as well. </p> Ticket anonymous Mon, 28 May 2012 14:45:25 GMT <link>https://svn.boost.org/trac10/ticket/6948#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/6948#comment:3</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/6948#comment:2" title="Comment 2">hkaiser</a>: </p> <blockquote class="citation"> <p> Use BOOST_AUTO instead (see here: <a class="ext-link" href="http://boost-spirit.com/home/articles/qi-example/zero-to-60-mph-in-2-seconds/"><span class="icon">​</span>http://boost-spirit.com/home/articles/qi-example/zero-to-60-mph-in-2-seconds/</a>). The article explains the rationale as well. </p> </blockquote> <p> Excuse me! I've changed 'auto' to 'BOOST_AUTO', but it doesn't work! I got the same error as before. In addition, I used gcc4.6.3 which supports 'auto' keyword. Would you have any idea? </p> <p> Code: #include&lt;boost/spirit/include/karma.hpp&gt; #include&lt;boost/spirit/include/karma_format_attr.hpp&gt; #include&lt;list&gt; #include&lt;iostream&gt; </p> <p> BOOST_AUTO(par, '{' &lt;&lt; -(boost::spirit::karma::int_ % ',') &lt;&lt; '}');<em>Define par here would lead to error! int main(){ </em></p> <blockquote> <p> using namespace std; namespace karma = boost::spirit::karma; list&lt;int&gt; l{1, 2, 4}; <em>BOOST_AUTO(par, '{' &lt;&lt; -(boost::spirit::karma::int_ % ',') &lt;&lt; '}');</em>Whils this would not! cout&lt;&lt;karma::format(par, l)&lt;&lt;endl; return 0; </p> </blockquote> <p> } </p> </description> <category>Ticket</category> </item> <item> <dc:creator>anonymous</dc:creator> <pubDate>Mon, 28 May 2012 14:47:28 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/6948 https://svn.boost.org/trac10/ticket/6948 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">2_new.cpp</span> </li> </ul> Ticket