瀏覽代碼

cmListFileContext: Simplify explicit rule-of-five members

Brad King 4 年之前
父節點
當前提交
61c46c95ae
共有 1 個文件被更改,包括 12 次插入8 次删除
  1. 12 8
      Source/cmListFileCache.h

+ 12 - 8
Source/cmListFileCache.h

@@ -80,6 +80,18 @@ public:
   cm::optional<std::string> DeferId;
 
   cmListFileContext() = default;
+  cmListFileContext(cmListFileContext&& /*other*/) = default;
+  cmListFileContext(const cmListFileContext& /*other*/) = default;
+  cmListFileContext& operator=(const cmListFileContext& /*other*/) = default;
+#if __cplusplus >= 201703L || (defined(_MSVC_LANG) && _MSVC_LANG >= 201703L)
+  cmListFileContext& operator=(cmListFileContext&& /*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.
+  cmListFileContext& operator=(cmListFileContext&& /*other*/) = delete;
+#endif
+
   cmListFileContext(std::string name, std::string filePath, long line)
     : Name(std::move(name))
     , FilePath(std::move(filePath))
@@ -87,14 +99,6 @@ public:
   {
   }
 
-#if __cplusplus < 201703L && (!defined(_MSVC_LANG) || _MSVC_LANG < 201703L)
-  cmListFileContext(const cmListFileContext& /*other*/) = default;
-  cmListFileContext(cmListFileContext&& /*other*/) = default;
-
-  cmListFileContext& operator=(const cmListFileContext& /*other*/) = default;
-  cmListFileContext& operator=(cmListFileContext&& /*other*/) = delete;
-#endif
-
   static cmListFileContext FromCommandContext(
     cmCommandContext const& lfcc, std::string const& fileName,
     cm::optional<std::string> deferId = {})