[PATCH] D45019: [ADT] NFC: Fix bogus StringSwitch rule-of-five boilerplate

David Zarzycki via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 29 05:48:04 PDT 2018


davezarzycki created this revision.
davezarzycki added a reviewer: jordan_rose.

Now that 'Str' is constant, the rule-of-five logic needs updating.


Repository:
  rL LLVM

https://reviews.llvm.org/D45019

Files:
  include/llvm/ADT/StringSwitch.h


Index: include/llvm/ADT/StringSwitch.h
===================================================================
--- include/llvm/ADT/StringSwitch.h
+++ include/llvm/ADT/StringSwitch.h
@@ -55,16 +55,13 @@
 
   // StringSwitch is not copyable.
   StringSwitch(const StringSwitch &) = delete;
+
+  // StringSwitch is not assignable due to 'Str' being 'const'.
   void operator=(const StringSwitch &) = delete;
+  void operator=(StringSwitch &&other) = delete;
 
-  StringSwitch(StringSwitch &&other) {
-    *this = std::move(other);
-  }
-  StringSwitch &operator=(StringSwitch &&other) {
-    Str = std::move(other.Str);
-    Result = std::move(other.Result);
-    return *this;
-  }
+  StringSwitch(StringSwitch &&other)
+    : Str(other.Str), Result(std::move(other.Result)) { }
 
   ~StringSwitch() = default;
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D45019.140213.patch
Type: text/x-patch
Size: 808 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20180329/ead98946/attachment.bin>


More information about the llvm-commits mailing list