Boost C++ Libraries: Ticket #5810: BOOST_STATIC_ASSERT requires unnecessary parentheses https://svn.boost.org/trac10/ticket/5810 <p> In Boost 1.47.0 the BOOST_STATIC_ASSERT macro is defined as having one parameter. When the argument contains comma-separated template arguments, we (sometimes) have to use additional parentheses: </p> <blockquote> <p> BOOST_STATIC_ASSERT(is_base_of&lt;B, D&gt;::value); /* error: two arguments passed */ </p> </blockquote> <blockquote> <p> BOOST_STATIC_ASSERT((is_base_of&lt;B, D&gt;::value)); /* OK */ </p> </blockquote> <p> Today many C++ compilers support variadic macros, so for such compilers BOOST_STATIC_ASSERT might be defined like this: </p> <blockquote> <p> #ifndef BOOST_NO_STATIC_ASSERT </p> </blockquote> <blockquote> <p> # define BOOST_STATIC_ASSERT(...) \ </p> <blockquote> <p> static_assert((<span class="underline">VA_ARGS</span>), #<span class="underline">VA_ARGS</span>) </p> </blockquote> <p> #else </p> <blockquote> <p> .... </p> </blockquote> </blockquote> <p> and BOOST_STATIC_ASSERT(is_base_of&lt;B, D&gt;::value) might be correct. Are there any problems with such definition? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/5810 Trac 1.4.3 anonymous Wed, 24 Aug 2011 12:12:21 GMT type changed https://svn.boost.org/trac10/ticket/5810#comment:1 https://svn.boost.org/trac10/ticket/5810#comment:1 <ul> <li><strong>type</strong> <span class="trac-field-old">Feature Requests</span> → <span class="trac-field-new">Bugs</span> </li> </ul> Ticket John Maddock Thu, 14 Feb 2013 18:29:08 GMT <link>https://svn.boost.org/trac10/ticket/5810#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/5810#comment:2</guid> <description> <p> I'll commit a patch for this shortly, however, only a partial solution is possible for BOOST_STATIC_ASSERT_MSG(expression, message), as I can't see a way to define it in terms of BOOST_STATIC_ASSERT using variadic macros. It does work when a native static_assert is available though. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>John Maddock</dc:creator> <pubDate>Thu, 14 Feb 2013 18:31:35 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/5810#comment:3 https://svn.boost.org/trac10/ticket/5810#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> <p> (In <a class="changeset" href="https://svn.boost.org/trac10/changeset/82886" title="Use variadic macros in static assert to make use easier. Add warning ...">[82886]</a>) Use variadic macros in static assert to make use easier. Add warning suppression for GCC. Minor doc fix. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/5810" title="#5810: Bugs: BOOST_STATIC_ASSERT requires unnecessary parentheses (closed: fixed)">#5810</a>. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7242" title="#7242: Bugs: GCC 4.8 warns unused local typedef (closed: fixed)">#7242</a>. Fixes <a class="closed ticket" href="https://svn.boost.org/trac10/ticket/7966" title="#7966: Bugs: static_assert: doc: nitpicking (closed: fixed)">#7966</a>. </p> Ticket