Procházet zdrojové kódy

telemetry: Default copy/move constructors and assignment operators

This provides the equivalent behavior, but without as much boilerplate.
While we're at it, explicitly default the move constructor, since we
have a move-assignment operator defined.
Lioncash před 8 roky
rodič
revize
3575d367a4
1 změnil soubory, kde provedl 4 přidání a 14 odebrání
  1. 4 14
      src/common/telemetry.h

+ 4 - 14
src/common/telemetry.h

@@ -58,21 +58,11 @@ public:
     Field(FieldType type, std::string name, T&& value)
         : name(std::move(name)), type(type), value(std::move(value)) {}
 
-    Field(const Field& other) : Field(other.type, other.name, other.value) {}
+    Field(const Field&) = default;
+    Field& operator=(const Field&) = default;
 
-    Field& operator=(const Field& other) {
-        type = other.type;
-        name = other.name;
-        value = other.value;
-        return *this;
-    }
-
-    Field& operator=(Field&& other) {
-        type = other.type;
-        name = std::move(other.name);
-        value = std::move(other.value);
-        return *this;
-    }
+    Field(Field&&) = default;
+    Field& operator=(Field&& other) = default;
 
     void Accept(VisitorInterface& visitor) const override;