antred
Lt. Commander
- Registriert
- Juni 2010
- Beiträge
- 1.288
Miuwa schrieb:Da du intern bereits einen vektor zur verwaltung der Daten nutzt kannst du einfach die default Copy/Move - Konstruktor/Assignemnt operatoren verwenden, die der Compiler automatisch für dich anlegt. Deine manuelle Implementierung ist also unnötig. Move ist übrigens auch das Standardverhalten für den Rückgabewert.
Diesem Thread hier http://stackoverflow.com/questions/4819936/why-no-default-move-assignment-move-constructor zufolge ist deine Behauptung nicht korrekt. Wenn ich das richtig verstanden habe, gibt es keinen compiler-generierten default-move-constructor für benutzer-definierte Typen.
Sehe ich das falsch?
Ergänzung ()
Okay, cppreference.com sagt was anderes
If the implicitly-declared move constructor is neither deleted nor trivial, it is defined (that is, a function body is generated and compiled) by the compiler if odr-used. For union types, the implicitly-defined move constructor copies the object representation (as by std::memmove). For non-union class types (class and struct), the move constructor performs full member-wise move of the object's bases and non-static members, in their initialization order, using direct initialization with an xvalue argument.
Allerdings müßte er den erst mit
Code:
BigInteger( BigInteger && ) = default;
enablen, da er per Default in seinem Fall wegen folgender Restriktionen nicht generiert würde:
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 are no user-declared destructors
(until C++14) the implicitly-declared move constructor is not defined as deleted due to conditions detailed in the next section
then the compiler will declare a move constructor as an inline public member of its class with the signature T::T(T&&).
EDIT: Hmpf, nein müßte er nicht. Habe seine Klassen-Definition noch mal überprüft, und sie erfüllt automatisch alle Anforderugen für einen default move constructor.
@datalukas: Sorry dafür, deine Zeit verschwendet zu haben, aber wengistens haben wir beide was über move constructors gelernt.

Zuletzt bearbeitet: