Kaynağa Gözat

Add more move semantic support

Bryan Drewery 7 yıl önce
ebeveyn
işleme
5d6e3020d1
2 değiştirilmiş dosya ile 12 ekleme ve 13 silme
  1. 8 2
      src/EncryptedStream.h
  2. 4 11
      src/RfcString.h

+ 8 - 2
src/EncryptedStream.h

@@ -31,8 +31,14 @@ class EncryptedStream : public bd::Stream {
 
   public:
         EncryptedStream(const char* keyStr) : Stream(), key(bd::String(keyStr)), enc_flags(ENC_DEFAULT) {};
-        EncryptedStream(bd::String& keyStr) : Stream(), key(keyStr), enc_flags(ENC_DEFAULT) {};
-        EncryptedStream(EncryptedStream& stream) : Stream(stream), key(stream.key), enc_flags(ENC_DEFAULT) {};
+        EncryptedStream(const bd::String& keyStr) : Stream(), key(keyStr), enc_flags(ENC_DEFAULT) {};
+        EncryptedStream(bd::String&& keyStr) noexcept :
+          Stream(), key(std::move(keyStr)), enc_flags(ENC_DEFAULT) {};
+        EncryptedStream(const EncryptedStream& stream) : Stream(stream), key(stream.key), enc_flags(ENC_DEFAULT) {};
+        EncryptedStream(EncryptedStream&& stream) noexcept :
+          Stream(std::move(stream)),
+          key(std::move(stream.key)),
+          enc_flags(ENC_DEFAULT) {};
 
         inline void setFlags(const char _enc_flags) const noexcept {
           enc_flags = _enc_flags;

+ 4 - 11
src/RfcString.h

@@ -15,21 +15,14 @@ class RfcString : public bd::String {
   public:
     using String::String;
     RfcString() = default;
-    RfcString(const RfcString& str) : String(str) {}
-    RfcString(RfcString&& str) noexcept :
-      String(std::move(str)) {}
+    RfcString(const RfcString& str) = default;
+    RfcString(RfcString&& str) noexcept = default;
     RfcString(const String &str) : String(str) {}
     RfcString(String &&str) noexcept :
       String(std::move(str)) {}
     using String::operator=;
-    RfcString& operator=(const RfcString& rhs) {
-      String::operator=(rhs);
-      return *this;
-    }
-    RfcString& operator=(RfcString&& rhs) noexcept {
-      String::operator=(std::move(rhs));
-      return *this;
-    }
+    RfcString& operator=(const RfcString& rhs) = default;
+    RfcString& operator=(RfcString&& rhs) noexcept = default;
     RfcString& operator=(const String& rhs) {
       String::operator=(rhs);
       return *this;