diff --git a/include/rapidjson/document.h b/include/rapidjson/document.h index 8631c54..1ce4ef2 100644 --- a/include/rapidjson/document.h +++ b/include/rapidjson/document.h @@ -416,7 +416,7 @@ public: //! Default constructor creates a null value. GenericValue() : data_(), flags_(kNullFlag) {} -#ifdef RAPIDJSON_CXX11 +#if RAPIDJSON_HAS_CXX11_RVALUE_REFS //! Move constructor in C++11 GenericValue(GenericValue&& rhs) : data_(rhs.data_), flags_(rhs.flags_) { rhs.flags_ = kNullFlag; // give up contents @@ -574,7 +574,7 @@ public: return *this; } -#ifdef RAPIDJSON_CXX11 +#if RAPIDJSON_HAS_CXX11_RVALUE_REFS //! Move assignment in C++11 GenericValue& operator=(GenericValue&& rhs) { return *this = rhs.Move(); diff --git a/include/rapidjson/internal/meta.h b/include/rapidjson/internal/meta.h index d83e1f1..3e6c931 100644 --- a/include/rapidjson/internal/meta.h +++ b/include/rapidjson/internal/meta.h @@ -34,7 +34,7 @@ RAPIDJSON_DIAG_PUSH RAPIDJSON_DIAG_OFF(6334) #endif -#ifdef RAPIDJSON_HAS_CXX11_TYPETRAITS +#if RAPIDJSON_HAS_CXX11_TYPETRAITS #include #endif @@ -102,7 +102,7 @@ template struct IsPointer : TrueType {}; /////////////////////////////////////////////////////////////////////////////// // IsBaseOf // -#ifdef RAPIDJSON_HAS_CXX11_TYPETRAITS +#if RAPIDJSON_HAS_CXX11_TYPETRAITS template struct IsBaseOf : BoolType< ::std::is_base_of::value> {}; diff --git a/include/rapidjson/rapidjson.h b/include/rapidjson/rapidjson.h index 752744c..7328c4e 100644 --- a/include/rapidjson/rapidjson.h +++ b/include/rapidjson/rapidjson.h @@ -357,6 +357,26 @@ template struct StaticAssertTest {}; #endif // RAPIDJSON_DIAG_* +/////////////////////////////////////////////////////////////////////////////// +// C++11 features + +#ifndef RAPIDJSON_HAS_CXX11_RVALUE_REFS +#if defined(__clang__) +#define RAPIDJSON_HAS_CXX11_RVALUE_REFS __has_feature(cxx_rvalue_references) +#elif (defined(RAPIDJSON_GNUC) && (RAPIDJSON_GNUC >= RAPIDJSON_VERSION_CODE(4,3,0)) && defined(__GXX_EXPERIMENTAL_CXX0X__)) || \ + (defined(_MSC_VER) && _MSC_VER >= 1600) + +#define RAPIDJSON_HAS_CXX11_RVALUE_REFS 1 +#else +#define RAPIDJSON_HAS_CXX11_RVALUE_REFS 0 +#endif +#endif // RAPIDJSON_HAS_CXX11_RVALUE_REFS + +// no automatic detection, yet +#ifndef RAPIDJSON_HAS_CXX11_TYPETRAITS +#define RAPIDJSON_HAS_CXX11_TYPETRAITS 0 +#endif + //!@endcond ///////////////////////////////////////////////////////////////////////////////