How can I check whether my compiler supports rvalue references or not? Is there a standard preprocessor macro, or do different compilers have different macros? Ideally, I would want to write this:
#ifdef RVALUE_REFERENCES_SUPPORTED
foobar(foobar&& that)
{
// ...
}
#endif
I'm not aware of any standard preprocessor macro, but:
_MSC_VER >= 1600
__GXX_EXPERIMENTAL_CXX0X__
__has_feature
macros for doing exactly what you need: __has_feature(cxx_rvalue_references)
So for most common compilers, it should be fairly easy to cobble something together yourself.
I am also pretty sure that Boost has a macro for this purpose, which you may be able to use if your project includes Boost (otherwise you could look at their implementation)