<div dir="ltr">Hello all,<div><br></div><div>I am trying to help along the recently added Boost.Lockfree (1) library utilize libc++'s std::atomic, as it is currently using Boost.Atomic, and an emulated, locking implementation at that.  <atomic> is currently used for this library for modern gcc and msvc compilers, but not yet clang / libc++.<div>
<br></div><div><br></div><div style>(note: to enable <atomic> for boost::lockfree, first apply this patch: <a href="https://svn.boost.org/trac/boost/attachment/ticket/8593/lockfree_atomic_libcpp.patch">https://svn.boost.org/trac/boost/attachment/ticket/8593/lockfree_atomic_libcpp.patch</a> )</div>
<div style><br></div><div style>The problem can be seen in the compile errors for this simple program:</div><div style><br></div><div style><div>#include "boost/lockfree/queue.hpp"</div><div><br></div><div style>
<div>int main(int argc, const char * argv[])</div><div>{</div></div></div><div><div><span style="white-space:pre">  </span>boost::lockfree::queue<int> q( 1 );</div></div><div style>  return 0;</div><div>}</div><div>
<br></div><div style>The diagnostic is:</div><div style><br></div><div style><div>In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/memory:606:</div>
<div>/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/atomic:623:58: error: no viable conversion from 'boost::lockfree::detail::tagged_ptr<boost::lockfree::queue<int, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>::node>' to '_Atomic(boost::lockfree::detail::tagged_ptr<boost::lockfree::queue<int, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>::node>)'</div>
<div>    _LIBCPP_CONSTEXPR __atomic_base(_Tp __d) _NOEXCEPT : __a_(__d) {}</div><div>                                                         ^    ~~~</div><div>/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/c++/v1/atomic:727:51: note: in instantiation of member function 'std::__1::__atomic_base<boost::lockfree::detail::tagged_ptr<boost::lockfree::queue<int, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>::node>, false>::__atomic_base' requested here</div>
<div>    _LIBCPP_CONSTEXPR atomic(_Tp __d) _NOEXCEPT : __base(__d) {}</div><div>                                                  ^</div><div>../../../../../cinder-dev/boost/boost/lockfree/queue.hpp:192:9: note: in instantiation of member function 'std::__1::atomic<boost::lockfree::detail::tagged_ptr<boost::lockfree::queue<int, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>::node> >::atomic' requested here</div>
<div>        head_(tagged_node_handle(0, 0)),</div><div>        ^</div><div>/Users/richeakin/code/cinder/audio-rewrite/audio2/test/BasicTest/xcode/../src/BasicTestApp.cpp:75:30: note: in instantiation of member function 'boost::lockfree::queue<int, boost::parameter::void_, boost::parameter::void_, boost::parameter::void_>::queue' requested here</div>
<div>        boost::lockfree::queue<int> q( 1 );</div><div>                                    ^</div><div>../../../../../cinder-dev/boost/boost/lockfree/detail/tagged_ptr_dcas.hpp:112:5: note: candidate function</div>
<div>    operator bool(void) const</div><div>    ^</div><div><br></div><div><br></div><div style>My understanding is (please correct me if wrong) that _Atomic(_Tp) is a directive to the compiler, which is replaced with atomic the true atomic instructions for each given architecture. As such, it doesn't know how to replace boost::lockfree::detail::tagged_ptr<...> with size_t, or whatever other atomic value lockfree expects. But, this is where my understanding of this sort of template metaprogramming reaches its end, I just can't tell why this trips up with libc++ but not with vc11.</div>
<div style><br></div><div style>Can anyone see where the translation falls short, or have suggestions on how to proceeed?</div><div><br></div><div style>Thank you kindly,</div><div style>Rich</div></div><div><br></div><div>
<br></div><div>1: <a href="http://www.boost.org/doc/libs/1_53_0/doc/html/lockfree.html">http://www.boost.org/doc/libs/1_53_0/doc/html/lockfree.html</a></div></div></div>