Skip to content

Commit bb9ffea

Browse files
grafi-tthebasto
authored andcommitted
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
1 parent 174bd43 commit bb9ffea

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

src/util/subprocess.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -770,7 +770,10 @@ class Communication
770770
public:
771771
Communication(Streams* stream): stream_(stream)
772772
{}
773-
void operator=(const Communication&) = delete;
773+
Communication(const Communication&) = delete;
774+
Communication& operator=(const Communication&) = delete;
775+
Communication(Communication&&) = default;
776+
Communication& operator=(Communication&&) = default;
774777
public:
775778
int send(const char* msg, size_t length);
776779
int send(const std::vector<char>& msg);
@@ -807,7 +810,10 @@ class Streams
807810
{
808811
public:
809812
Streams():comm_(this) {}
810-
void operator=(const Streams&) = delete;
813+
Streams(const Streams&) = delete;
814+
Streams& operator=(const Streams&) = delete;
815+
Streams(Streams&&) = default;
816+
Streams& operator=(Streams&&) = default;
811817

812818
public:
813819
void setup_comm_channels();

0 commit comments

Comments
 (0)