Add a macro to allow default move copy constructor and assignment operator above VS2013.
This commit is contained in:
@@ -6,6 +6,18 @@
|
||||
// -----------------------------------------------------------------------------
|
||||
// Macros
|
||||
|
||||
// Does the compiler support "= default" for move copy constructor and
|
||||
// assignment operator?
|
||||
#ifdef _MSC_VER
|
||||
#if _MSC_VER <= 1800 // VS 2013
|
||||
#define WEBCC_DEFAULT_MOVE_COPY_ASSIGN 0
|
||||
#else
|
||||
#define WEBCC_DEFAULT_MOVE_COPY_ASSIGN 1
|
||||
#endif // _MSC_VER <= 1800
|
||||
#else
|
||||
#define WEBCC_DEFAULT_MOVE_COPY_ASSIGN 1
|
||||
#endif // _MSC_VER
|
||||
|
||||
// Explicitly declare the copy constructor and assignment operator as deleted.
|
||||
#define DELETE_COPY_AND_ASSIGN(TypeName) \
|
||||
TypeName(const TypeName&) = delete; \
|
||||
|
||||
@@ -3,6 +3,8 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
#include "webcc/globals.h" // for COPY_ASSIGN_MOVE_DEFAULT
|
||||
|
||||
namespace webcc {
|
||||
|
||||
// Key-value SOAP parameter.
|
||||
@@ -44,6 +46,13 @@ class SoapParameter {
|
||||
as_cdata_(false) {
|
||||
}
|
||||
|
||||
#if WEBCC_DEFAULT_MOVE_COPY_ASSIGN
|
||||
|
||||
SoapParameter(SoapParameter&&) = default;
|
||||
SoapParameter& operator=(SoapParameter&&) = default;
|
||||
|
||||
#else
|
||||
|
||||
// Use "= default" if drop the support of VS 2013.
|
||||
SoapParameter(SoapParameter&& rhs)
|
||||
: key_(std::move(rhs.key_)), value_(std::move(rhs.value_)),
|
||||
@@ -60,6 +69,8 @@ class SoapParameter {
|
||||
return *this;
|
||||
}
|
||||
|
||||
#endif // WEBCC_DEFAULT_MOVE_COPY_ASSIGN
|
||||
|
||||
const std::string& key() const { return key_; }
|
||||
const std::string& value() const { return value_; }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user