And now we're going to have yet a new and surprisingly interesting new idea in C++ 11. It's going to be called the 'Move' Constructor. And low and behold, you're going to get some more completely confusing syntax. So again, one of the hallmarks as the great C and C+ programmer is we have one of the most obscure esoteric languages, and here's yet more esoterica. So, for anybody who really loves this kind of language, this is a great addition. So what's going on here? What's going on is you can now use &&, and it no longer means reference to. Instead, it means, What might be called right side reference. So the traditional ampersand of b is what we call a left side semantics. And what you have to think about is a = b. When you have an expression a = b, this is the left-hand side, and this is the right-hand side. And they mean different things, the b over here and the a over there mean two different things. So this has a different meaning to the ordinary copy constructor and as now something called the 'Move' Constructor. And let's see some of the ideas. Now first off I'll just explain the noexcept keyword, and other C++ 11. And this just means that I promise no exceptions will be thrown. I do not want exceptions thrown with this constructor because it would lead to a big mess, all right. That would be too hard to clean up. So I'm going to promise that I won't do anything that will create an exception. Now this stuff is what we call referential copying, or shallow copying. Notice what happens. The new a points at the material in the old a. The old a which was really the b of a is going, this is again nullptr. Nullptr is what we used to use as the 0. The nullptr again in C++ 11 is a special keyword that's universal and meant to be the null pointer special value. The universal special value meaning null pointer, or as the zero address. And it's much, it's more type safe than just using an ordinary zero. You couldn't use an ordinary zero there. So by referential copy, it means what was in b is moved to a. What was in b disappears. That's why it's a shallow copy, b disappears. b is made null. A retains the information. What happens in this instance? Well, this is very efficient, let's say I had a million elements sitting in b. How many operations am I executing? I'm executing a simple address. Assignment. So I have a single assignment operator here, so a few cycles on a machine, and then a second assignment, sessions. So I have two very simple assignments, they're typically going to be executed in machine level with low store. So they're going to occur in nanoseconds. So they'll be a few nanoseconds. So I can have a billion elements sitting in memory, and the copy is occurring in a couple of nanoseconds, it's not occurring proportionately to how large an aggregate I'm moving. What's the price I pay? The price is I have to know that the old name for the thing is no longer applicable. It's like I gave the thing a new name, I moved it. I didn't recreate it, I didn't clone it, I moved it. The ordinary copy constructor clones it. The old stuff is retained, remember in the pre-existing copy constructor, I had a big false statement, and big false statement acts proportionally to the size of the aggregate. So, move semantics are extraordinarily efficient that is trivial, constant time algorithm, no matter what the size of the aggregate is. So again, one thing that you now can take away is rvalue semantics, and that's your new piece of esoteric knowledge. And indeed, if you really understand this, you're going to be very, very valuable to a company that wants to do SQL like libraries. This is what you'll need to effectively create the next SQL like aggregate entity. Here are some of the things to review to really understand those semantics. Addresses and Declarations. We have to really understand what is it when you write in C or C++ a assigned b. On the left-hand side, we have a, that really means an address of. On the right-hand side you have b, that means the value stored at, and you get the value stored at b assigned to the item whose address is being pointed at by a. So, a and b are not symmetric when you have assignment, it's not a mathematical operation that's going on here. It's what in computer technical talk is a side effect operation, and it's indeed what make these kinds of languages hard to debug. When you use the reference, so you again have to understand all of these kinds of declarations, now there's yet another one, we could say that we could also have int a, all three of these things. Int a, int& a, int* ptr_a, int && b, well this is the new one. All have important different uses. And when we use this new rvalue reference, think of it as binding to a temporary object, and that object's going to go away. It will not be used again, it's going to go away. That's when we want it used. Otherwise, we want to stay with what we had in the C world and in the early C++ world. Now, when we have move semantics with a 'Move' Constructor, we almost always also add to our class, so this is again telling you how to build your new C11 classes. You also typically want to overload the assignment, to have move semantics associated with assignment. We're going to see why, and this is a non-copying move assignment where the right-hand side gets destroyed. So, again look at this. So fixed cost to these operations. In technical terms this is what we call constant order one efficiency. So we do an assignment of a from the pre-existing b, no matter how big. B.a[n] could be very large and could be whatever size it want to be but all we're doing is assigning a base pointer value. And then we get rid of the right-hand side through the nullptr, and then, because the assignment operator can be used repeatedly, we return the dereferenced object value, the this pointer value. And this is a non-copying- move assignment with the right-hand side being destroyed. So again, take away, if I'm building with move semantics and I'm building a big aggregate, I'm not going to use this for a non-aggregate. It wouldn't make sense because then copying an assignment, they're in essence the same, if we have a simple aggregate like a single length, there is no value to using move semantics. You wouldn't get any efficiency out of that. Let's see where all this efficiency can work. And this is the classic case. It's going to be an efficient sense of swap. So we're always swapping things, think of Quick sort. Quick sort we swap two elements continuously to get a sorted order. Swapping is one of the foundational operations you find in algorithms. Now, generally speaking, when we're swapping two simple values, an a and b, it's a fixed amount of computing cost. We tend to have a temporary, we assign to the temporary, the value of the first object, then we re-assign the first object value from the second object. So the temporary is holding the original value, and now we use the original value and assign it to the second object. So that's why we need the temporary. We can't just, we can't instantly interchange the two objects. We could if we were like in the old Genie movies or Genie TV series, you can snap your fingers and they both jump into the other box. That doesn't happen. In the real world, in the C world, you need this intermediary. So first, copy it, place it safely here, now do the interchange, from one now take the copied thing and do the interchange, and that's a fixed set of operations on a simple data type like an int. But now if we have a huge aggregate, Where do move semantics show up? Move semantics let us get rid of the efficiency of using this little temporary box because we know that what's placed in there has no final use. So it can disappear on us without cause, perfect for move semantics, so let's think about that. We move, and by using the move operator, that means that this = is now going to use the overloaded up equals with move semantics. That's what this does for us. This basic move is actually a disguised way of saying that operator = is going to use the right-hand side signature. So, this gets moved into the container, it's going to disappear. b is now moved with the original, what you might call a, and then a gets the value that got placed in the temporary. Everything gets done by via shallow copy. So something with millions of elements, Avoids proportional to n, the size of the aggregate. In the swap for each of these steps. That's a great, great saving. Here by the way you can see what the move is really using, it's really using that kind of cast to get you the right type. All the assignments are referential, meaning they're all order one, they're all order one. Now this is an order one swap routine. That's just a fabulous saving. Since that's frequently something you need to do with big aggregates and the STL library, is littered with big aggregates, and now that we have all this big data that we're processing continually, this is going to lead to a highly efficient code. So, it's really great improvement. Okay, let me recommend some things for you in order to test out these very novel ideas. Take my container array and try to modify the code, and try and overload it so that you can select out an element. And when you go to overload this, it has to be overloaded as a non-static class method. That's key to overloading operator selection. Add iterator logic into my container. This will again give you some sense of how to build an STL like class, okay. So that, I recommend you try and do those things on your own.