Boost C++ Libraries: Ticket #8606: Impossible to convert 0-size tuple to (empty) sequence any more https://svn.boost.org/trac10/ticket/8606 <p> The following used to work just fine with 1.48: </p> <div class="wiki-code"><div class="code"><pre><span class="cp">#include</span> <span class="cpf">&lt;boost/preprocessor.hpp&gt;</span><span class="cp"></span> <span class="n">BOOST_PP_TUPLE_TO_SEQ</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="p">())</span> </pre></div></div><p> producing </p> <pre class="wiki">() </pre><p> on output. With 1.53 (and probably later as there haven't been any changes since then AFAICS) it now also generates the following warnings when using MSVC (tested with 2008 and 2010): </p> <pre class="wiki">warning C4003: not enough actual parameters for macro 'BOOST_PP_TUPLE_TO_SEQ_1' </pre><p> but somehow still generates correct output. With g++ 4.4 it's even worse and it expands into </p> <pre class="wiki">BOOST_PP_TUPLE_TO_SEQ_0 () </pre><p> resulting in compilation errors. </p> <p> This seems to be the result of <a class="ext-link" href="https://github.com/ryppl/boost-svn/commit/fd3633b27d0ef637f6cffc3239c981a4876172a6#boost/preprocessor/tuple/to_seq.hpp"><span class="icon">​</span>changes done while adding variadic support</a> to the preprocessor library as <code>BOOST_PP_TUPLE_TO_SEQ_0()</code> definition was removed in this commit. </p> <p> Notice that <a href="http://www.boost.org/doc/libs/1_53_0/libs/preprocessor/doc/ref/tuple_to_seq.html">the documentation</a> does say that tuple size must be <code>&gt;= 1</code> but this was changed in 1.49, compare the version above with <a href="http://www.boost.org/doc/libs/1_48_0/libs/preprocessor/doc/ref/tuple_to_seq.html">this one</a>. </p> <p> Finally notice I decided to open a new ticket for this even though this is already mentioned in a comment in <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/6616" title="#6616: Bugs: boost preprocessor bug in 1.49 (closed: fixed)">#6616</a> because the other ticket doesn't to be about the same thing at all, so I thought it would be confusing to continue discussing this issue there. Please feel free to close this one if you think it's really the same issue. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/8606 Trac 1.4.3 vz-boost@… Thu, 23 May 2013 00:51:05 GMT summary changed https://svn.boost.org/trac10/ticket/8606#comment:1 https://svn.boost.org/trac10/ticket/8606#comment:1 <ul> <li><strong>summary</strong> <span class="trac-field-old">Warnings when converting 0-size tuple to sequence with MSVC</span> → <span class="trac-field-new">Impossible to convert 0-size tuple to (empty) sequence any more</span> </li> </ul> <p> After investigating this further, it turns out that doing this with variadic macros is not obvious at all because there doesn't seem to be any way to distinguish between empty tuple and a 1 element tuple as <code>BOOST_PP_VARIADIC_SIZE</code> returns 1 for both of them. </p> <p> Also, the reason for the difference in behaviour between g++ and MSVC was due to the fact that variadic support is not enabled for Boost Debian package for some reason (the compiler does support variadic macros, of course), so the situation is completely different there, sorry for the confusion. </p> <p> Anyhow, if there is really no way to handle empty tuples with <code>BOOST_PP_TUPLE_TO_SEQ</code> using variadic macros, could the same functionality be at least provided with non-variadic macros under a different name? It's really useful to handle tuples of all sizes consistently. </p> Ticket Edward Diener Sun, 17 May 2015 02:36:19 GMT <link>https://svn.boost.org/trac10/ticket/8606#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8606#comment:2</guid> <description> <p> There is no such thing as a 0 size tuple. The notation of '()' is a tuple whose size is 1 and whose single element is empty. Therefore attempting to convert a zero-sized tuple to any other Boost PP data type, by specifying that the size is 0, is undefined. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Edward Diener</dc:creator> <pubDate>Sun, 17 May 2015 04:50:12 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/8606#comment:3 https://svn.boost.org/trac10/ticket/8606#comment:3 <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">fixed</span> </li> </ul> Ticket vz-boost@… Sun, 17 May 2015 12:07:35 GMT <link>https://svn.boost.org/trac10/ticket/8606#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8606#comment:4</guid> <description> <p> Replying to <a class="ticket" href="https://svn.boost.org/trac10/ticket/8606#comment:2" title="Comment 2">eldiener</a>: </p> <blockquote class="citation"> <p> There is no such thing as a 0 size tuple. </p> </blockquote> <p> Terminological discussions aside, this worked in old Boost versions and was genuinely useful so this is objectively a regression. I know Boost doesn't guarantee backwards compatibility but there is no indication that this breakage was intentional. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>Edward Diener</dc:creator> <pubDate>Sun, 17 May 2015 14:04:13 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/8606#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/8606#comment:5</guid> <description> <p> It is not useful to have a tuple of 0 size and not be able to distinguish between '()' as a tuple of size 0 or a tuple of size 1 with the single element as empty. Since emptiness is perfectly allowable in the preprocessor, and since '(x,)' is clearly a tuple whose size is 2 with the second element being empty, it would always be wrong to make a special case for '()' and declare that this is tuple of size 0. Furthermore treating '()' as a apecial case would make it impossible to have a tuple of size 1 whose single element is empty. </p> <p> The VC++ preprocessor is a C++ non-standard conforming preprocessor and it is only with heroic effort that Paul Mensonides was able to get VC++ to handle Boost PP processing as much as it does ( there are numerous workarounds in Boost PP code just to handle VC++ ). The gcc preprocessor is vastly closer to the C++ standard. </p> </description> <category>Ticket</category> </item> </channel> </rss>