V
V
Viva88882022-03-17 18:40:48
C++ / C#
Viva8888, 2022-03-17 18:40:48

If there are any members of the class, the move constructor will not be generated automatically?

1) Custom explicit constructor
2) Custom move constructor
3) Custom copy constructor
4) Custom assignment operator
5) Custom move assignment operator
6) Custom destructor
7) Primitive type private field

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Mercury13, 2022-03-17
@BMinhoj

Implicitly-declared move constructor
If no user-defined move constructors are provided for a class type (struct, class, or union), and all of the following is true:
  • there are no user-declared copy constructors;
  • there are no user-declared copy assignment operators;
  • there are no user-declared move assignment operators;
  • there is no user-declared destructor.

then the compiler will declare a move constructor as a non-explicit inline public member of its class with the signature T::T(T&&).

Well, the custom move constructor excludes the automatic one.
So 2, 3, 4, 5, 6.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question