Browse Source

Merge topic 'more-rule-of-3'

8f8f73712a Source: fix more rule of 3 warnings from clang -Wdeprecated

Acked-by: Kitware Robot <[email protected]>
Acked-by: buildbot <[email protected]>
Merge-request: !6659
Brad King 4 years ago
parent
commit
db422ae0c7
2 changed files with 31 additions and 18 deletions
  1. 30 18
      Source/cmCMakePresetsFile.h
  2. 1 0
      Source/cmXMLParser.h

+ 30 - 18
Source/cmCMakePresetsFile.h

@@ -101,14 +101,18 @@ public:
   class ConfigurePreset : public Preset
   {
   public:
-#if __cplusplus < 201703L && (!defined(_MSVC_LANG) || _MSVC_LANG < 201703L)
+    ConfigurePreset() = default;
+    ConfigurePreset(ConfigurePreset&& /*other*/) = default;
+    ConfigurePreset(const ConfigurePreset& /*other*/) = default;
+    ConfigurePreset& operator=(const ConfigurePreset& /*other*/) = default;
+    ~ConfigurePreset() override = default;
+#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
+    ConfigurePreset& operator=(ConfigurePreset&& /*other*/) = default;
+#else
     // The move assignment operators for several STL classes did not become
     // noexcept until C++17, which causes some tools to warn about this move
-    // assignment operator throwing an exception when it shouldn't. Disable the
-    // move assignment operator until C++17 is enabled.
-    // Explicitly defining a copy assignment operator prevents the compiler
-    // from automatically generating a move assignment operator.
-    ConfigurePreset& operator=(const ConfigurePreset& /*other*/) = default;
+    // assignment operator throwing an exception when it shouldn't.
+    ConfigurePreset& operator=(ConfigurePreset&& /*other*/) = delete;
 #endif
 
     std::string Generator;
@@ -142,14 +146,18 @@ public:
   class BuildPreset : public Preset
   {
   public:
-#if __cplusplus < 201703L && (!defined(_MSVC_LANG) || _MSVC_LANG < 201703L)
+    BuildPreset() = default;
+    BuildPreset(BuildPreset&& /*other*/) = default;
+    BuildPreset(const BuildPreset& /*other*/) = default;
+    BuildPreset& operator=(const BuildPreset& /*other*/) = default;
+    ~BuildPreset() override = default;
+#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
+    BuildPreset& operator=(BuildPreset&& /*other*/) = default;
+#else
     // The move assignment operators for several STL classes did not become
     // noexcept until C++17, which causes some tools to warn about this move
-    // assignment operator throwing an exception when it shouldn't. Disable the
-    // move assignment operator until C++17 is enabled.
-    // Explicitly defining a copy assignment operator prevents the compiler
-    // from automatically generating a move assignment operator.
-    BuildPreset& operator=(const BuildPreset& /*other*/) = default;
+    // assignment operator throwing an exception when it shouldn't.
+    BuildPreset& operator=(BuildPreset&& /*other*/) = delete;
 #endif
 
     std::string ConfigurePreset;
@@ -168,14 +176,18 @@ public:
   class TestPreset : public Preset
   {
   public:
-#if __cplusplus < 201703L && (!defined(_MSVC_LANG) || _MSVC_LANG < 201703L)
+    TestPreset() = default;
+    TestPreset(TestPreset&& /*other*/) = default;
+    TestPreset(const TestPreset& /*other*/) = default;
+    TestPreset& operator=(const TestPreset& /*other*/) = default;
+    ~TestPreset() override = default;
+#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
+    TestPreset& operator=(TestPreset&& /*other*/) = default;
+#else
     // The move assignment operators for several STL classes did not become
     // noexcept until C++17, which causes some tools to warn about this move
-    // assignment operator throwing an exception when it shouldn't. Disable the
-    // move assignment operator until C++17 is enabled.
-    // Explicitly defining a copy assignment operator prevents the compiler
-    // from automatically generating a move assignment operator.
-    TestPreset& operator=(const TestPreset& /*other*/) = default;
+    // assignment operator throwing an exception when it shouldn't.
+    TestPreset& operator=(TestPreset&& /*other*/) = delete;
 #endif
 
     struct OutputOptions

+ 1 - 0
Source/cmXMLParser.h

@@ -21,6 +21,7 @@ class cmXMLParser
 {
 public:
   cmXMLParser();
+  cmXMLParser(const cmXMLParser& /*other*/) = default;
   virtual ~cmXMLParser();
 
   //! Parse given XML string