The move assignment operator allows your class to move values instead of copying, when the source is an rvalue.
- [Instructor] Along with the move constructor,…the move assignment operator is also an important…part of supporting move semantics in your code.…Here, I have a working copy of rational-02…from chapter four of the exercise files.…This includes the move constructor…we added earlier in this chapter.…First thing I'm going to do is I'm going to come down here…to our assignment operator, and I just want to put in…a message so that we know when it's being called,…and now we'll come down here and call it inside of main,…and when I build and run, you'll notice that D…is being assigned the value of B,…and we call the assignment operator in order to do that.…
Now, if I change this assignment to a move assignment,…and I build and run, you'll notice that the regular…assignment operator is still being called…because we don't have a move assignment operator,…and so let's go ahead and build one.…So, I'm going to our take regular assignment operator here,…and I'm just going to make a copy of it, and make some changes.…We can't do this with a const because we're going…
Author
Released
12/20/2018- Classes and objects
- Constructors and conversion operators
- Class inheritance
- Smart pointers
- Move semantics
- Lambda syntax
- The C preprocessor
- Unit tests
- Building a custom string library
Skill Level Advanced
Duration
Views
Related Courses
-
Learning C++
with Erin Colvin2h 26m Beginner -
Code Clinic: C++
with Bill Weinman2h 4m Intermediate -
C++: Smart Pointers
with Bill Weinman29m 6s Intermediate -
C++ Design Patterns: Creational
with Olivia Chiu Stone2h 26m Beginner -
Learning C++ Pointers
with Peggy Fisher53m 55s Intermediate
-
Introduction
-
1. Classes and Objects
-
Defining a class4m 31s
-
Data members2m 50s
-
Function members4m 51s
-
Constructors and destructors8m 55s
-
Explicit constructors2m 45s
-
Namespaces1m 47s
-
Self-referencing pointer2m 46s
-
Operator overloads6m 27s
-
Non-member operators4m 59s
-
Conversion operators4m 30s
-
Allocating object memory3m 29s
-
Functors1m 40s
-
Example: numword7m 12s
-
-
2. Class Inheritance
-
Overview of inheritance1m 55s
-
Simple inheritance3m 16s
-
Accessing the base class2m 40s
-
Friendship4m 13s
-
Multiple inheritance2m 56s
-
Polymorphism4m 1s
-
-
3. Smart Pointers
-
Why smart pointers2m 6s
-
Unique pointer6m 27s
-
Shared pointer3m 56s
-
Weak pointer3m 41s
-
Using a custom deleter2m 25s
-
Choosing a smart pointer1m 38s
-
-
4. Move Semantics
-
What is move semantics2m 13s
-
Using std::move3m 19s
-
The move constructor6m 11s
-
The move assignment operator3m 18s
-
The copy-and-swap idiom5m 26s
-
Rule of five1m 9s
-
-
5. Lambda Functions
-
Lambda syntax3m 37s
-
Captures3m 14s
-
Polymorphic lambdas2m 28s
-
-
6. The C Preprocessor
-
About the preprocessor2m 32s
-
Macros as constants4m 56s
-
Including files2m 1s
-
Conditional compilation2m 52s
-
Defining macros4m 25s
-
Including files only once3m 45s
-
-
7. Unit Tests
-
A unit test library2m 58s
-
8. Custom String Library
-
Why non-STL strings?2m 53s
-
Overview of BWString3m 51s
-
Constructors4m 34s
-
Memory management5m 30s
-
Operators3m 43s
-
Utility methods3m 22s
-
Find and replace2m 56s
-
Splitting strings4m 55s
-
Using the BWString library2m 43s
-
-
Conclusion
-
Next steps1m 22s
-
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.
CancelTake notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.
Share this video
Embed this video
Video: The move assignment operator