Boost C++ Libraries: Ticket #10125: call_once: compile errors in variadic version with rvalue reference emulation https://svn.boost.org/trac10/ticket/10125 <p> In the variadic template version, boost::call_once uses BOOST_THREAD_RV_REF for the function and function argument parameters. </p> <p> If the Boost.Move rvalue reference emulation is active, this only compiles for classes that use one of the macros in Boost.Move in their class definiton. Notably, it dooes not compile for Boost.Bind and Boost.Function objects. </p> <p> Could this be changed to use BOOST_THREAD_FWD_REF instead of BOOST_THREAD_RV_REF or could const&amp; overloads be added? </p> en-us Boost C++ Libraries /htdocs/site/boost.png https://svn.boost.org/trac10/ticket/10125 Trac 1.4.3 viboes Mon, 16 Jun 2014 18:52:32 GMT owner, status changed https://svn.boost.org/trac10/ticket/10125#comment:1 https://svn.boost.org/trac10/ticket/10125#comment:1 <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> </ul> <p> Please, could you show an example an the compile error? </p> Ticket raad@… Mon, 16 Jun 2014 21:17:03 GMT <link>https://svn.boost.org/trac10/ticket/10125#comment:2 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10125#comment:2</guid> <description> <p> Please see the attached simple example for MSVC12. The error message is: </p> <pre class="wiki">boost_call_once_test\boost_call_once_test\boost_call_once_test.cpp(19): error C2665: 'boost::call_once' : none of the 2 overloads could convert all the argument types 1&gt; boost_call_once_test\boost_call_once_test\boost\thread\win32\once.hpp(232): could be 'void boost::call_once(boost::once_flag &amp;,void (__cdecl *)(void))' 1&gt; boost_call_once_test\boost_call_once_test\boost\thread\once.hpp(35): or 'void boost::call_once&lt;boost::once_flag&gt;(Function,boost::once_flag &amp;)' 1&gt; with 1&gt; [ 1&gt; Function=boost::once_flag 1&gt; ] 1&gt; while trying to match the argument list '(boost::once_flag, boost::_bi::bind_t&lt;void,boost::_mfi::mf0&lt;void,test_class&gt;,boost::_bi::list1&lt;boost::_bi::value&lt;T&gt;&gt;&gt;)' 1&gt; with 1&gt; [ 1&gt; T=test_class 1&gt; ] </pre><p> I don't know why the error message doesn't even mention </p> <pre class="wiki">void call_once&lt;Function&gt;(once_flag&amp; flag, boost::rv&lt;Function&gt; &amp;f) </pre><p> , <a class="missing wiki">IntelliSense</a> suggests that overload too. </p> <p> clang gives similar errors. </p> </description> <category>Ticket</category> </item> <item> <author>raad@…</author> <pubDate>Mon, 16 Jun 2014 21:18:06 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/10125 https://svn.boost.org/trac10/ticket/10125 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">boost_call_once_test.zip</span> </li> </ul> <p> Poject showing the error for MSVC12 </p> Ticket viboes Sun, 29 Jun 2014 21:38:26 GMT <link>https://svn.boost.org/trac10/ticket/10125#comment:3 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10125#comment:3</guid> <description> <p> I have reached to make it work with </p> <pre class="wiki">#define BOOST_THREAD_VERSION 4 //#define BOOST_NO_CXX11_RVALUE_REFERENCES #define BOOST_THREAD_PROVIDES_ONCE_CXX11 </pre><p> I don't remember why BOOST_THREAD_PROVIDES_ONCE_CXX11 is not defined when BOOST_THREAD_VERSION is defined. </p> <p> Please could you check if this work for you. I will comeback when I found why I have not defined it. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sun, 29 Jun 2014 21:45:57 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10125#comment:4 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10125#comment:4</guid> <description> <p> I have found this comment </p> <pre class="wiki">// For C++11 call_once interface the compiler MUST support constexpr. // Otherwise once_flag would be initialized during dynamic initialization stage, which is not thread-safe. #if defined(BOOST_THREAD_PROVIDES_ONCE_CXX11) #if defined(BOOST_NO_CXX11_CONSTEXPR) #undef BOOST_THREAD_PROVIDES_ONCE_CXX11 #endif #endif </pre><p> And </p> <pre class="wiki">#if BOOST_THREAD_VERSION&gt;=3 // ONCE_CXX11 // fixme BOOST_THREAD_PROVIDES_ONCE_CXX11 doesn't works when thread.cpp is compiled BOOST_THREAD_VERSION 3 #if ! defined BOOST_THREAD_DONT_PROVIDE_ONCE_CXX11 \ &amp;&amp; ! defined BOOST_THREAD_PROVIDES_ONCE_CXX11 #define BOOST_THREAD_DONT_PROVIDE_ONCE_CXX11 #endif </pre><p> I will comeback with more insight. </p> </description> <category>Ticket</category> </item> <item> <author>raad@…</author> <pubDate>Mon, 30 Jun 2014 07:16:32 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10125#comment:5 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10125#comment:5</guid> <description> <p> Defining BOOST_THREAD_PROVIDES_ONCE_CXX11 would work for me as I don't actually need this for MSVC, only for the latest clang. I only use MSVC for testing as I don't have access to clang regularly. But unfortunately I still have to define BOOST_NO_CXX11_RVALUE_REFERENCES as the standard library I have to use with clang is not move-aware and does not provide std::move and std::forward :-( </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Tue, 01 Jul 2014 21:53:00 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10125#comment:6 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10125#comment:6</guid> <description> <p> Boost doesn't supports this combination. I think that it would be better to remove this checker and don't use C++11 with this library. </p> </description> <category>Ticket</category> </item> <item> <author>raad@…</author> <pubDate>Wed, 02 Jul 2014 05:32:21 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10125#comment:7 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10125#comment:7</guid> <description> <p> I see, thank you. I have to change to libc++ as soon as possible. But everything in Boost works except for this single compile error when variadic templates are switched on. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Wed, 02 Jul 2014 05:51:41 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10125#comment:8 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10125#comment:8</guid> <description> <p> I have assumed that if the compiler has variadic templates it has move semantic. In order to support the configuration you want I would need to make the distinction. Do you think it is worth the effort? </p> </description> <category>Ticket</category> </item> <item> <author>raad@…</author> <pubDate>Wed, 02 Jul 2014 09:29:52 GMT</pubDate> <title/> <link>https://svn.boost.org/trac10/ticket/10125#comment:9 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10125#comment:9</guid> <description> <p> Well, there is a workaround (also disabling variadic templates when disabling rvalue references), so it's not critical. </p> <p> But as the rest of Boost (including the rest of Boost.Thread) works in this configuration with variadic templates and without rvalue references and it seems that I'm not the only one using the latest clang with an older standard library, I think it's worth it if it's not too much work. </p> <p> Maybe the simplest solution would be to disable the variadic version of call_once if BOOST_NO_CXX11_RVALUE_REFERENCES is defined? The attached patch works for me with all compiler and standard library combinations. </p> </description> <category>Ticket</category> </item> <item> <author>raad@…</author> <pubDate>Wed, 02 Jul 2014 09:33:05 GMT</pubDate> <title>attachment set https://svn.boost.org/trac10/ticket/10125 https://svn.boost.org/trac10/ticket/10125 <ul> <li><strong>attachment</strong> → <span class="trac-field-new">call_once_variadic.patch</span> </li> </ul> Ticket viboes Thu, 03 Jul 2014 06:10:20 GMT <link>https://svn.boost.org/trac10/ticket/10125#comment:10 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10125#comment:10</guid> <description> <p> Ok, I will do it. </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Fri, 04 Jul 2014 05:54:23 GMT</pubDate> <title>milestone changed https://svn.boost.org/trac10/ticket/10125#comment:11 https://svn.boost.org/trac10/ticket/10125#comment:11 <ul> <li><strong>milestone</strong> <span class="trac-field-old">To Be Determined</span> → <span class="trac-field-new">Boost 1.56.0</span> </li> </ul> Ticket raad@… Mon, 07 Jul 2014 10:34:31 GMT <link>https://svn.boost.org/trac10/ticket/10125#comment:12 </link> <guid isPermaLink="false">https://svn.boost.org/trac10/ticket/10125#comment:12</guid> <description> <p> I just saw that this is now in master. Thank you very much! </p> </description> <category>Ticket</category> </item> <item> <dc:creator>viboes</dc:creator> <pubDate>Sat, 19 Jul 2014 16:39:53 GMT</pubDate> <title>status changed; resolution set https://svn.boost.org/trac10/ticket/10125#comment:13 https://svn.boost.org/trac10/ticket/10125#comment:13 <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> Ticket