Boost C++ Libraries: Ticket #13163: boost::detail::heap_new does not have a variadic variant https://svn.boost.org/trac10/ticket/13163 <p> Locally, we had code that previously built in CentOS 6.x, using a compiler circa from 2009 that does not support variadic templates / rvalue references: </p> <pre class="wiki">gcc (GCC) 4.4.7 20120313 (Red Hat 4.4.7-18) Copyright (C) 2010 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. </pre><p> Without variadic templates / rvalue references boost provides a boost::thread's variable argument constructor that supports up to 9 arguments + thread main. Sadly, the variadic implementation that is enabled when rvalue references + variadic arguments are supported is: </p> <pre class="wiki"> template&lt;typename F, class ...ArgTypes&gt; static inline detail::thread_data_ptr make_thread_info(BOOST_THREAD_RV_REF(F) f, BOOST_THREAD_RV_REF(ArgTypes)... args) { return detail::thread_data_ptr(detail::heap_new&lt; detail::thread_data&lt;typename boost::remove_reference&lt;F&gt;::type, ArgTypes...&gt; &gt;( boost::forward&lt;F&gt;(f), boost::forward&lt;ArgTypes&gt;(args)... ) ); } </pre><p> In turn, this calls into the platform specific version of heap_new, which currently only supports up to a total of 4 arguments. Locally, I have modified my boost version (e.g. boost/thread/pthread/thread_heap_alloc.hpp) to have this definition: </p> <pre class="wiki">#if defined(BOOST_THREAD_PROVIDES_VARIADIC_THREAD) template&lt;typename T,typename... Args&gt; inline T* heap_new(Args&amp;&amp;... args) { return new T(static_cast&lt;Args&amp;&amp;&gt;(args)...); } #else ... </pre><p> While this is functional for my needs, obviously I think it (or something like it) should get into boost proper. Moreover, not that it likely matters, but it would also be wise to support at least 10 arguments to heap_new, in the non-variadic variant, so that it supports the ubiquity of other use cases in boost::thread et al. </p> <p> A similar implementation should be provided for win32. </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/13163 Trac 1.4.3 anonymous Tue, 15 Aug 2017 19:32:38 GMT component changed; owner set https://svn.boost.org/trac10/ticket/13163#comment:1 https://svn.boost.org/trac10/ticket/13163#comment:1 <ul> <li><strong>owner</strong> set to <span class="trac-author">Anthony Williams</span> </li> <li><strong>component</strong> <span class="trac-field-old">None</span> → <span class="trac-field-new">thread</span> </li> </ul> Ticket viboes Tue, 22 Aug 2017 21:02:35 GMT owner, status, description changed https://svn.boost.org/trac10/ticket/13163#comment:2 https://svn.boost.org/trac10/ticket/13163#comment:2 <ul> <li><strong>owner</strong> changed from <span class="trac-author">Anthony Williams</span> to <span class="trac-author">viboes</span> </li> <li><strong>status</strong> <span class="trac-field-old">new</span> → <span class="trac-field-new">assigned</span> </li> <li><strong>description</strong> modified (<a href="/trac10/ticket/13163?action=diff&amp;version=2">diff</a>) </li> </ul> Ticket viboes Tue, 22 Aug 2017 21:05:17 GMT <link>https://svn.boost.org/trac10/ticket/13163#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13163#comment:3</guid> <description> <p> Hi, </p> <p> it is incredible that no one have observed this bug since the beginning. </p> <p> I'll try to fix it for the next version. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 22 Aug 2017 21:16:23 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/13163#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13163#comment:4</guid> <description> <p> In addition to your variadic patch I'm ready to provide the up to 9 version for </p> <pre class="wiki"> template&lt;typename T,typename A1,typename A2,typename A3,typename A4&gt; inline T* heap_new_impl(A1 a1,A2 a2,A3 a3,A4 a4) { return new T(a1,a2,a3,a4); } </pre><p> but not for the mix of const/non-const ref variant </p> <pre class="wiki"> template&lt;typename T,typename A1,typename A2&gt; inline T* heap_new(A1 const&amp; a1,A2 const&amp; a2) { return heap_new_impl&lt;T,A1 const&amp;,A2 const&amp;&gt;(a1,a2); } template&lt;typename T,typename A1,typename A2&gt; inline T* heap_new(A1&amp; a1,A2 const&amp; a2) { return heap_new_impl&lt;T,A1&amp;,A2 const&amp;&gt;(a1,a2); } template&lt;typename T,typename A1,typename A2&gt; inline T* heap_new(A1 const&amp; a1,A2&amp; a2) { return heap_new_impl&lt;T,A1 const&amp;,A2&amp;&gt;(a1,a2); } template&lt;typename T,typename A1,typename A2&gt; inline T* heap_new(A1&amp; a1,A2&amp; a2) { return heap_new_impl&lt;T,A1&amp;,A2&amp;&gt;(a1,a2); } </pre><p> Of course, a patch using preprocessor programming is welcome. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 22 Aug 2017 21:46:01 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/13163#comment:5 https://svn.boost.org/trac10/ticket/13163#comment:5 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.66.0</span> </li> </ul> Ticket viboes Tue, 22 Aug 2017 22:35:13 GMT <link>https://svn.boost.org/trac10/ticket/13163#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/13163#comment:6</guid> <description> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/bb32aa3164c89bf882c248ff7794661f88d17768"><span class="icon">​</span>https://github.com/boostorg/thread/commit/bb32aa3164c89bf882c248ff7794661f88d17768</a> </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 26 Aug 2017 09:46:00 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/13163#comment:7 https://svn.boost.org/trac10/ticket/13163#comment:7 <ul> <li><strong>status</strong> <span class="trac-field-old">assigned</span> → <span class="trac-field-new">closed</span> </li> <li><strong>resolution</strong> → <span class="trac-field-new">fixed</span> </li> </ul> <p> <a class="ext-link" href="https://github.com/boostorg/thread/commit/a02f0ec577644ca45cdca20e91cd8cd82e6c2017"><span class="icon">​</span>https://github.com/boostorg/thread/commit/a02f0ec577644ca45cdca20e91cd8cd82e6c2017</a> </p> Ticket