<p dir="ltr">On Jul 31, 2015 4:12 PM, "Jeffrey Walton" <<a href="mailto:noloader@gmail.com">noloader@gmail.com</a>> wrote:<br>
><br>
> I have the following code:<br>
><br>
> // R-values: MS at VS2010 (16.00); GCC at 4.3; Clang at 2.9; and Intel 11.1.<br>
> // The extra tests on GCC are because Clang and ICC claims to be GCC 4.<br>
> #if (_MSC_VER >= 1600)<br>
> # define MY_CXX11_RVALUES 1<br>
> #elif defined(__clang__)<br>
> # if __has_feature(cxx_rvalue_references)<br>
> # define MY_CXX11_RVALUES 1<br>
> # endif<br>
> #elif (__INTEL_COMPILER >= 1110)<br>
> # define MY_CXX11_RVALUES 1<br>
> #elif (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))<br>
> # define MY_CXX11_RVALUES 1<br>
> #endif // R-value compilers<br>
><br>
> Then guard the rvalue gear in the declaration and implementation:<br>
><br>
> if MY_CXX11_RVALUES<br>
> MyClass::MyClass(MyClass&& t)<br>
> : m_alloc(std::move(t.m_alloc)), m_size(t.m_size), m_ptr(std::move(t.m_ptr))<br>
> {<br>
> t.m_alloc = A();<br>
> t.m_alloc = nullptr;<br>
> t.m_size = 0;<br>
> }<br>
> }<br>
> #endif<br>
><br>
> Results in:<br>
><br>
> ./myclass.h:276:18: error: no member named 'move' in namespace 'std'<br>
> : m_alloc(std::move(t.m_alloc)), m_size(t.m_size), m_ptr...<br>
> ~~~~~^<br>
> ./myclass.h:276:65: error: no member named 'move' in namespace 'std'<br>
> ...: m_alloc(std::move(t.m_alloc)), m_size(t.m_size),<br>
> m_ptr(std::move(t.m_p...<br>
><br>
> And the compiler:<br>
><br>
> $ c++ -v<br>
> Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)<br>
> Target: x86_64-apple-darwin12.6.0<br>
> Thread model: posix<br>
><br>
> What is the proper way to guard to rvalues and std::move when using<br>
> Clang on Apple?</p>
<p dir="ltr">You need to test the version of the standard library, not of the compiler, to detect std::move. Or you could implement your own move function; it's pretty trivial.<br>
_______________________________________________<br>
> cfe-dev mailing list<br>
> <a href="mailto:cfe-dev@cs.uiuc.edu">cfe-dev@cs.uiuc.edu</a><br>
> <a href="http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev">http://lists.cs.uiuc.edu/mailman/listinfo/cfe-dev</a><br>
</p>