Skip to content

Commit 789abc8

Browse files
authored
Merge pull request #2418 from mikeblome/mb-1596
fixes #1596
2 parents 830cf17 + 4759235 commit 789abc8

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

docs/cpp/constructors-cpp.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: "Constructors (C++)"
3-
ms.date: "09/05/2019"
3+
ms.date: "10/17/2019"
44
helpviewer_keywords: ["constructors [C++]", "objects [C++], creating", "instance constructors"]
55
ms.assetid: 3e9f7211-313a-4a92-9584-337452e061a9
66
---
@@ -197,13 +197,13 @@ Attempting to copy the object produces error *C2280: attempting to reference a d
197197
198198
## <a name="move_constructors"></a> Move constructors
199199
200-
A *move constructor* is a special member function that moves ownership of an existing object's data to a new variable without copying the original data. It takes an rvalue reference as its first parameter, and any additional parameters must have default values. Move constructors can significantly increase your program's efficiency when passing around large objects. A move constructor takes an rvalue reference as its first parameter. Any other parameters must have default values.
200+
A *move constructor* is a special member function that moves ownership of an existing object's data to a new variable without copying the original data. It takes an rvalue reference as its first parameter, and any additional parameters must have default values. Move constructors can significantly increase your program's efficiency when passing around large objects.
201201
202202
```cpp
203203
Box(Box&& other);
204204
```
205205

206-
The compiler chooses a move constructor in certain situations where the object is being initialized by another object of the same type that is about to be destroyed and no longer needs it resources. The following example shows one case when a move constructor is selected by overload resolution. The variable *box* returned by get_Box() is an *xvalue* (eXpiring value) which is about to go out of scope. To provide motivation for this example, let's give Box a large vector of strings that represent its contents. Rather than copying the vector and its strings, the move constructor "steals" it from the expiring value "box" so that the vector now belongs to the new object. The call to `std::move` is all that's needed because both `vector` and `string` classes implement their own move constructors.
206+
The compiler chooses a move constructor in certain situations where the object is being initialized by another object of the same type that is about to be destroyed and no longer needs its resources. The following example shows one case when a move constructor is selected by overload resolution. In the constructor that calls `get_Box()`, the returned value is an *xvalue* (eXpiring value). It is not assigned to any variable and is therefore about to go out of scope. To provide motivation for this example, let's give Box a large vector of strings that represent its contents. Rather than copying the vector and its strings, the move constructor "steals" it from the expiring value "box" so that the vector now belongs to the new object. The call to `std::move` is all that's needed because both `vector` and `string` classes implement their own move constructors.
207207

208208
```cpp
209209
#include <iostream>

0 commit comments

Comments
 (0)