Skip to content

Commit 849f7af

Browse files
author
Colin Robertson
authored
Merge pull request #3953 from MicrosoftDocs/main637898744477064019
Repo sync for protected CLA branch
2 parents eb8b7fd + fc82cf5 commit 849f7af

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

44 files changed

+880
-826
lines changed

docs/atl/reference/cwindowimpl-class.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -276,7 +276,7 @@ virtual void OnFinalMessage(HWND hWnd);
276276

277277
### Remarks
278278

279-
The default implementation of `OnFinalMessage` does nothing, but you can override this function to handle cleanup before destroying a window. If you want to automatically delete your object upon the window destruction, you can call **delete this;** in this function.
279+
The default implementation of `OnFinalMessage` does nothing, but you can override this function to handle cleanup before destroying a window. If you want to automatically delete your object upon the window destruction, you can call `delete this;` in this function.
280280

281281
## <a name="subclasswindow"></a> CWindowImpl::SubclassWindow
282282

docs/cpp/function-overloading.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -368,7 +368,7 @@ Even though the second one requires both a standard conversion and the user-defi
368368
> [!NOTE]
369369
> User-defined conversions are considered conversion by construction or conversion by initialization (conversion function). Both methods are considered equal when considering the best match.
370370
371-
## Argument matching and the this pointer
371+
## Argument matching and the `this` pointer
372372
373373
Class member functions are treated differently, depending on whether they are declared as **`static`**. Because nonstatic functions have an implicit argument that supplies the **`this`** pointer, nonstatic functions are considered to have one more argument than static functions; otherwise, they are declared identically.
374374

docs/cpp/object-lifetime-and-resource-management-modern-cpp.md

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
22
title: "Object lifetime and resource management (RAII)"
33
description: "Follow the principle of RAII in modern C++ to avoid resource leaks."
4-
ms.date: "11/19/2019"
4+
ms.date: 06/02/2022
55
ms.topic: "conceptual"
66
ms.assetid: 8aa0e1a1-e04d-46b1-acca-1d548490700f
77
---
88
# Object lifetime and resource management (RAII)
99

10-
Unlike managed languages, C++ doesn't have automatic *garbage collection*. That's an internal process that releases heap memory and other resources as a program runs. A C++ program is responsible for returning all acquired resources to the operating system. Failure to release an unused resource is called a *leak*. Leaked resources are unavailable to other programs until the process exits. Memory leaks in particular are a common cause of bugs in C-style programming.
10+
Unlike managed languages, C++ doesn't have automatic *garbage collection*, an internal process that releases heap memory and other resources as a program runs. A C++ program is responsible for returning all acquired resources to the operating system. Failure to release an unused resource is called a *leak*. Leaked resources are unavailable to other programs until the process exits. Memory leaks in particular are a common cause of bugs in C-style programming.
1111

1212
Modern C++ avoids using heap memory as much as possible by declaring objects on the stack. When a resource is too large for the stack, then it should be *owned* by an object. As the object gets initialized, it acquires the resource it owns. The object is then responsible for releasing the resource in its destructor. The owning object itself is declared on the stack. The principle that *objects own resources* is also known as "resource acquisition is initialization," or RAII.
1313

@@ -48,7 +48,7 @@ public:
4848
};
4949
5050
void functionUsingWidget() {
51-
widget w(1000000); // lifetime automatically tied to enclosing scope
51+
widget w(1000000); // lifetime automatically tied to enclosing scope
5252
// constructs w, including the w.data member
5353
w.do_something();
5454
@@ -63,20 +63,19 @@ Since C++11, there's a better way to write the previous example: by using a smar
6363
class widget
6464
{
6565
private:
66-
std::unique_ptr<int> data;
66+
std::unique_ptr<int[]> data;
6767
public:
68-
widget(const int size) { data = std::make_unique<int>(size); }
68+
widget(const int size) { data = std::make_unique<int[]>(size); }
6969
void do_something() {}
7070
};
7171

7272
void functionUsingWidget() {
73-
widget w(1000000); // lifetime automatically tied to enclosing scope
74-
// constructs w, including the w.data gadget member
73+
widget w(1000000); // lifetime automatically tied to enclosing scope
74+
// constructs w, including the w.data gadget member
7575
// ...
7676
w.do_something();
7777
// ...
7878
} // automatic destruction and deallocation for w and w.data
79-
8079
```
8180

8281
By using smart pointers for memory allocation, you may eliminate the potential for memory leaks. This model works for other resources, such as file handles or sockets. You can manage your own resources in a similar way in your classes. For more information, see [Smart pointers](smart-pointers-modern-cpp.md).
@@ -85,6 +84,6 @@ The design of C++ ensures objects are destroyed when they go out of scope. That
8584

8685
## See also
8786

88-
[Welcome back to C++](../cpp/welcome-back-to-cpp-modern-cpp.md)<br/>
89-
[C++ Language Reference](../cpp/cpp-language-reference.md)<br/>
87+
[Welcome back to C++](../cpp/welcome-back-to-cpp-modern-cpp.md)\
88+
[C++ language reference](../cpp/cpp-language-reference.md)\
9089
[C++ Standard Library](../standard-library/cpp-standard-library-reference.md)

docs/cpp/this-pointer.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
---
2-
title: "this pointer"
2+
title: "The this pointer"
33
description: "The this pointer is a compiler-generated pointer to the current object in nonstatic member functions."
44
ms.date: "01/22/2020"
55
f1_keywords: ["this_cpp"]
66
helpviewer_keywords: ["nonstatic member functions [C++]", "pointers, to class instance", "this pointer"]
77
ms.assetid: 92e3256a-4ad9-4d46-8be1-d77fad90791f
88
no-loc: [this, class, struct, union, sizeof, const, volatile]
99
---
10-
# this pointer
10+
# The `this` pointer
1111

1212
The **`this`** pointer is a pointer accessible only within the nonstatic member functions of a **`class`**, **`struct`**, or **`union`** type. It points to the object for which the member function is called. Static member functions don't have a **`this`** pointer.
1313

@@ -131,7 +131,7 @@ my buffer
131131
your buffer
132132
```
133133

134-
## Type of the this pointer
134+
## Type of the `this` pointer
135135

136136
The **`this`** pointer's type can be modified in the function declaration by the **`const`** and **`volatile`** keywords. To declare a function that has either of these attributes, add the keyword(s) after the function argument list.
137137

@@ -161,15 +161,15 @@ int main()
161161
}
162162
```
163163

164-
The type of **`this`** in a member function is described by the following syntax. The *cv-qualifier-list* is determined from the member function's declarator. It can be **`const`** or **`volatile`** (or both). *class-type* is the name of the class:
164+
The type of **`this`** in a member function is described by the following syntax. The *`cv-qualifier-list`* is determined from the member function's declarator. It can be **`const`** or **`volatile`** (or both). *`class-type`* is the name of the class:
165165

166-
[*cv-qualifier-list*] *class-type* **\* const this**
166+
[*`cv-qualifier-list`*] *`class-type`* **`* const this`**
167167

168-
In other words, the **`this`** pointer is always a const pointer. It can't be reassigned. The **`const`** or **`volatile`** qualifiers used in the member function declaration apply to the class instance the **`this`** pointer points at, in the scope of that function.
168+
In other words, the **`this`** pointer is always a **`const`** pointer. It can't be reassigned. The **`const`** or **`volatile`** qualifiers used in the member function declaration apply to the class instance the **`this`** pointer points at, in the scope of that function.
169169

170170
The following table explains more about how these modifiers work.
171171

172-
### Semantics of this modifiers
172+
### Semantics of `this` modifiers
173173

174174
|Modifier|Meaning|
175175
|--------------|-------------|

docs/cpp/welcome-back-to-cpp-modern-cpp.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
title: "Welcome back to C++ - Modern C++"
33
description: "Describes the new programming idioms in Modern C++ and their rationale."
4-
ms.date: 02/07/2022
4+
ms.date: 06/02/2022
55
ms.topic: "conceptual"
66
ms.assetid: 1cb1b849-ed9c-4721-a972-fd8f3dab42e2
77
---
@@ -24,15 +24,15 @@ To support easy adoption of RAII principles, the C++ Standard Library provides t
2424
class widget
2525
{
2626
private:
27-
std::unique_ptr<int> data;
27+
std::unique_ptr<int[]> data;
2828
public:
29-
widget(const int size) { data = std::make_unique<int>(size); }
29+
widget(const int size) { data = std::make_unique<int[]>(size); }
3030
void do_something() {}
3131
};
3232

3333
void functionUsingWidget() {
34-
widget w(1000000); // lifetime automatically tied to enclosing scope
35-
// constructs w, including the w.data gadget member
34+
widget w(1000000); // lifetime automatically tied to enclosing scope
35+
// constructs w, including the w.data gadget member
3636
// ...
3737
w.do_something();
3838
// ...

docs/error-messages/compiler-errors-1/compiler-error-c2107.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ A subscript is applied to an expression that does not evaluate to a pointer.
1414

1515
## Example
1616

17-
C2107 can occur if you incorrectly use the **`this`** pointer of a value type to access the type's default indexer. For more information, see [Semantics of the this pointer](../../dotnet/how-to-define-and-consume-classes-and-structs-cpp-cli.md#BKMK_Semantics_of_the_this_pointer).
17+
C2107 can occur if you incorrectly use the **`this`** pointer of a value type to access the type's default indexer. For more information, see [Semantics of the `this` pointer](../../dotnet/how-to-define-and-consume-classes-and-structs-cpp-cli.md#BKMK_Semantics_of_the_this_pointer).
1818

1919
The following sample generates C2107.
2020

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
---
22
description: "Learn more about: Compiler Error C2834"
33
title: "Compiler Error C2834"
4-
ms.date: "11/04/2016"
4+
ms.date: 06/01/2022
55
f1_keywords: ["C2834"]
66
helpviewer_keywords: ["C2834"]
77
ms.assetid: 28f9f6eb-ab2a-4e64-aaaa-9d14f955de41
88
---
99
# Compiler Error C2834
1010

11-
'operator operator' must be globally qualified
11+
> 'operator *operator-name*' must be globally qualified
1212
1313
The `new` and `delete` operators are tied to the class where they reside. Scope resolution cannot be used to select a version of `new` or `delete` from a different class. To implement multiple forms of the `new` or `delete` operator, create a version of the operator with extra formal parameters.
14+
15+
This error is obsolete in Visual Studio 2022 and later versions.
Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
---
22
description: "Learn more about: Compiler Error C2858"
33
title: "Compiler Error C2858"
4-
ms.date: "11/04/2016"
4+
ms.date: 06/01/2022
55
f1_keywords: ["C2858"]
66
helpviewer_keywords: ["C2858"]
77
ms.assetid: 1fb1d770-307e-476e-9984-a1d8f8ce2820
88
---
99
# Compiler Error C2858
1010

11-
command-line option '/Yc (/Fdfilename)' inconsistent with precompiled header, which used '/Fdfilename'
11+
> command-line option '/Yc (/Fd*filename1*)' inconsistent with precompiled header, which used '/Fd*filename2*'
1212
13-
The program database specified by the Use Precompiled Header ([/Yu](../../build/reference/yu-use-precompiled-header-file.md)) option is not the one specified by the previous Create Precompiled Header ([/Yc](../../build/reference/yc-create-precompiled-header-file.md)) option.
13+
The program database specified by the Use Precompiled Header ([`/Yu`](../../build/reference/yu-use-precompiled-header-file.md)) option is not the one specified by the previous Create Precompiled Header ([`/Yc`](../../build/reference/yc-create-precompiled-header-file.md)) option.
14+
15+
This error is obsolete in Visual Studio 2022 and later versions.

docs/error-messages/compiler-errors-2/compiler-error-c2875.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,12 @@ ms.assetid: d589fc0c-08b2-4a79-bc0e-dca5eb80bdd5
88
---
99
# Compiler Error C2875
1010

11-
using-declaration causes a multiple declaration of 'class::identifier'
11+
> using-declaration causes a multiple declaration of 'class::identifier'
1212
1313
The declaration causes the same item to be defined twice.
1414

15+
This error is obsolete in Visual Studio 2022 and later versions.
16+
1517
The following sample generates C2875:
1618

1719
```cpp

docs/error-messages/compiler-errors-2/compiler-error-c2896.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
---
22
description: "Learn more about: Compiler Error C2896"
33
title: "Compiler Error C2896"
4-
ms.date: "11/04/2016"
4+
ms.date: 06/01/2022
55
f1_keywords: ["C2896"]
66
helpviewer_keywords: ["C2896"]
77
ms.assetid: b600407b-cb05-42e3-9069-2aa6960f0eaa
88
---
99
# Compiler Error C2896
1010

11-
'function1' : cannot use function template 'function2' as argument
11+
> '*function1*' : cannot use function template '*function2*' as argument
1212
13-
A function template cannot be an argument to another function template.
13+
A function template can't be an argument to another function template.
14+
15+
This error is obsolete in Visual Studio 2022 and later versions.
1416

1517
The following sample generates C2896:
1618

docs/error-messages/compiler-errors-2/compiler-error-c2902.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
---
22
description: "Learn more about: Compiler Error C2902"
33
title: "Compiler Error C2902"
4-
ms.date: "11/04/2016"
4+
ms.date: 06/01/2022
55
f1_keywords: ["C2902"]
66
helpviewer_keywords: ["C2902"]
77
ms.assetid: 89d78d0e-78e5-4c2c-a0f9-a60110e9395e
88
---
99
# Compiler Error C2902
1010

11-
'token' : unexpected token following 'template', identifier expected
11+
> '*token*' : unexpected token following '*template*', identifier expected
1212
1313
The token following the keyword **`template`** was not an identifier.
1414

15+
This error is obsolete in Visual Studio 2022 and later versions.
16+
1517
The following sample generates C2902:
1618

1719
```cpp

docs/error-messages/compiler-errors-2/compiler-error-c2917.md

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
---
22
description: "Learn more about: Compiler Error C2917"
33
title: "Compiler Error C2917"
4-
ms.date: "11/04/2016"
4+
ms.date: 06/01/2022
55
f1_keywords: ["C2917"]
66
helpviewer_keywords: ["C2917"]
77
ms.assetid: ec9da9ee-0f37-47b3-87dd-19ef5a14dc4c
88
---
99
# Compiler Error C2917
1010

11-
'name' : invalid template-parameter
11+
> '*name*' : invalid template-parameter
1212
13-
A template parameter list contains an identifier that was not a template parameter.
13+
## Remarks
14+
15+
A template parameter list contains an identifier that wasn't a template parameter.
16+
17+
This error is obsolete in Visual Studio 2022 and later versions.
1418

1519
## Example
1620

docs/error-messages/compiler-errors-2/compiler-error-c2931.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
---
22
description: "Learn more about: Compiler Error C2931"
33
title: "Compiler Error C2931"
4-
ms.date: "11/04/2016"
4+
ms.date: 06/01/2022
55
f1_keywords: ["C2931"]
66
helpviewer_keywords: ["C2931"]
77
ms.assetid: 33430407-b149-4ba3-baf8-b0dae1ea3a5d
88
---
99
# Compiler Error C2931
1010

11-
'class' : type-class-id redefined as a member function of 'identifier'
11+
'*class*' : type-class-id redefined as a member function of '*identifier*'
1212

13-
You cannot use a generic or template class as a member function of another class.
13+
You can't use a generic or template class as a member function of another class.
14+
15+
This error is obsolete in Visual Studio 2022 and later versions.
1416

1517
This error can be caused if braces are improperly matched.
1618

docs/error-messages/compiler-errors-2/compiler-error-c2932.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ ms.assetid: c28e88d9-e654-4367-bfb4-13c780bca9bd
88
---
99
# Compiler Error C2932
1010

11-
'class' : type-class-id redefined as a data member of 'identifier'
11+
> '*class*' : type-class-id redefined as a data member of '*identifier*'
1212
13-
You cannot use a generic or template class as a data member.
13+
You can't use a generic or template class as a data member.
14+
15+
This error is obsolete in Visual Studio 2022 and later versions.
1416

1517
The following sample generates C2932:
1618

docs/error-messages/compiler-errors-2/compiler-error-c2933.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
---
22
description: "Learn more about: Compiler Error C2933"
33
title: "Compiler Error C2933"
4-
ms.date: "11/04/2016"
4+
ms.date: 06/01/2022
55
f1_keywords: ["C2933"]
66
helpviewer_keywords: ["C2933"]
77
ms.assetid: 394891e3-6b52-4b61-83d2-a1c5125d9bd5
88
---
99
# Compiler Error C2933
1010

11-
'class' : type-class-id redefined as a typedef member of 'identifier'
11+
> '*class*' : type-class-id redefined as a typedef member of '*identifier*'
1212
13-
You cannot use a generic or template class as a **`typedef`** member.
13+
You can't use a generic or template class as a **`typedef`** member.
14+
15+
This error is obsolete in Visual Studio 2022 and later versions.
1416

1517
The following sample generates C2933:
1618

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
---
22
description: "Learn more about: Compiler Error C2934"
33
title: "Compiler Error C2934"
4-
ms.date: "11/04/2016"
4+
ms.date: 06/01/2022
55
f1_keywords: ["C2934"]
66
helpviewer_keywords: ["C2934"]
77
ms.assetid: b7f7e7aa-2d4c-4e17-8564-2c005ab81fd5
88
---
99
# Compiler Error C2934
1010

11-
'class' : type-class-id redefined as a nested 'item' of 'identifier'
11+
'*class*' : type-class-id redefined as a nested 'item' of '*identifier*'
1212

13-
You cannot use a generic or template class as a nested item.
13+
You can't use a generic or template class as a nested item.
14+
15+
This error is obsolete in Visual Studio 2022 and later versions.

docs/error-messages/compiler-errors-2/compiler-error-c2935.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
---
22
description: "Learn more about: Compiler Error C2935"
33
title: "Compiler Error C2935"
4-
ms.date: "11/04/2016"
4+
ms.date: 06/01/2022
55
f1_keywords: ["C2935"]
66
helpviewer_keywords: ["C2935"]
77
ms.assetid: e11ef90d-0756-4e43-8a09-4974c6aa72a3
88
---
99
# Compiler Error C2935
1010

11-
'class' : type-class-id redefined as a global function
11+
> '*class*' : type-class-id redefined as a global function
1212
13-
You cannot use a generic or template class as a global function.
13+
You can't use a generic or template class as a global function.
14+
15+
This error is obsolete in Visual Studio 2022 and later versions.
1416

1517
This error can be caused if braces are improperly matched.
1618

docs/error-messages/compiler-errors-2/compiler-error-c2936.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,18 @@
11
---
22
description: "Learn more about: Compiler Error C2936"
33
title: "Compiler Error C2936"
4-
ms.date: "11/04/2016"
4+
ms.date: 06/01/2022
55
f1_keywords: ["C2936"]
66
helpviewer_keywords: ["C2936"]
77
ms.assetid: 5d1ba0fc-0c78-4a37-a83b-1ef8527763be
88
---
99
# Compiler Error C2936
1010

11-
'class' : type-class-id redefined as a global data variable
11+
> '*class*' : type-class-id redefined as a global data variable
1212
13-
You cannot use a generic or template class as a global data variable.
13+
You can't use a generic or template class as a global data variable.
14+
15+
This error is obsolete in Visual Studio 2022 and later versions.
1416

1517
This error can be caused if braces are improperly matched.
1618

0 commit comments

Comments
 (0)