M
M
Mercury132021-09-28 19:28:30
C++ / C#
Mercury13, 2021-09-28 19:28:30

What should I write to prevent copying and transferring by all means?

The "frontal" code is quite complex.

class C {
  C(const C&) = delete;
  C(C&&) = delete;
  C& operator = (const C&) = delete;
  C& operator = (C&&) = delete;
};

Are there any ways in C++ to shorten this miracle?
C++17, if anything.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
maaGames, 2021-09-28
@maaGames

If I'm not mistaken, if there is a copy constructor, then the move constructor will not be created automatically. That is, both C&& can be removed. and write two lines less.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question