[cfe-dev] How to test for std::move (intersection of Apple and Clang)
Jeffrey Walton
noloader at gmail.com
Fri Jul 31 16:12:00 PDT 2015
I have the following code:
// R-values: MS at VS2010 (16.00); GCC at 4.3; Clang at 2.9; and Intel 11.1.
// The extra tests on GCC are because Clang and ICC claims to be GCC 4.
#if (_MSC_VER >= 1600)
# define MY_CXX11_RVALUES 1
#elif defined(__clang__)
# if __has_feature(cxx_rvalue_references)
# define MY_CXX11_RVALUES 1
# endif
#elif (__INTEL_COMPILER >= 1110)
# define MY_CXX11_RVALUES 1
#elif (__GNUC__ >= 5 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
# define MY_CXX11_RVALUES 1
#endif // R-value compilers
Then guard the rvalue gear in the declaration and implementation:
if MY_CXX11_RVALUES
MyClass::MyClass(MyClass&& t)
: m_alloc(std::move(t.m_alloc)), m_size(t.m_size), m_ptr(std::move(t.m_ptr))
{
t.m_alloc = A();
t.m_alloc = nullptr;
t.m_size = 0;
}
}
#endif
Results in:
./myclass.h:276:18: error: no member named 'move' in namespace 'std'
: m_alloc(std::move(t.m_alloc)), m_size(t.m_size), m_ptr...
~~~~~^
./myclass.h:276:65: error: no member named 'move' in namespace 'std'
...: m_alloc(std::move(t.m_alloc)), m_size(t.m_size),
m_ptr(std::move(t.m_p...
And the compiler:
$ c++ -v
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: x86_64-apple-darwin12.6.0
Thread model: posix
What is the proper way to guard to rvalues and std::move when using
Clang on Apple?
More information about the cfe-dev
mailing list