From bb9ffea53fb021580f069c431aee02f547039831 Mon Sep 17 00:00:00 2001 From: Shunsuke Shimizu Date: Thu, 1 May 2025 22:14:29 +0100 Subject: [PATCH] subprocess: Explicitly define move constructor of Streams class This suppresses the following warning caused by clang-20. ``` error: definition of implicit copy constructor for 'Streams' is deprecated because it has a user-declared copy assignment operator [-Werror,-Wdeprecated-copy] ``` Copy constructor or move constructor is called when std::vector re-allocates memory. In this case, move constructor should be called, because copying Streams instances breaks file-descriptor management. Communication class is modified as well, since it's instance is a member of Streams class. Github-Pull: arun11299/cpp-subprocess#107 Rebased-From: 38d98d9d20be50c7187b98ac9bc9a6e66920f6ef --- src/util/subprocess.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/util/subprocess.h b/src/util/subprocess.h index 6771632840a..91f84a290bd 100644 --- a/src/util/subprocess.h +++ b/src/util/subprocess.h @@ -770,7 +770,10 @@ class Communication public: Communication(Streams* stream): stream_(stream) {} - void operator=(const Communication&) = delete; + Communication(const Communication&) = delete; + Communication& operator=(const Communication&) = delete; + Communication(Communication&&) = default; + Communication& operator=(Communication&&) = default; public: int send(const char* msg, size_t length); int send(const std::vector& msg); @@ -807,7 +810,10 @@ class Streams { public: Streams():comm_(this) {} - void operator=(const Streams&) = delete; + Streams(const Streams&) = delete; + Streams& operator=(const Streams&) = delete; + Streams(Streams&&) = default; + Streams& operator=(Streams&&) = default; public: void setup_comm_channels();