Skip to content

Commit 1abc1cf

Browse files
author
Colin Robertson
authored
Merge pull request #2531 from MicrosoftDocs/master637382083280066027
Repo sync for protected CLA branch
2 parents ccb1721 + 43cee7a commit 1abc1cf

33 files changed

+102
-102
lines changed

docs/c-runtime-library/potential-errors-passing-crt-objects-across-dll-boundaries.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Because each copy of the CRT library has its own heap manager, allocating memory
2626

2727
The DLL and its clients normally use the same copy of the CRT library only if both are linked at load time to the same version of the CRT DLL. Because the DLL version of the Universal CRT library used by Visual Studio 2015, and later on Windows 10, is now a centrally deployed Windows component (ucrtbase.dll), it's the same for apps built with Visual Studio 2015 and later versions. However, even when the CRT code is identical, you can't give memory allocated in one heap to a component that uses a different heap.
2828

29-
## Example
29+
## Example: Pass file handle across DLL boundary
3030

3131
### Description
3232

@@ -68,7 +68,7 @@ int main(void)
6868
this is a string
6969
```
7070

71-
## Example
71+
## Example: Pass environment variables across DLL boundary
7272

7373
### Description
7474

docs/c-runtime-library/reference/malloca.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ In addition to the above restrictions, when using the [/clr (Common Language Run
5757
|-------------|---------------------|
5858
|**_malloca**|\<malloc.h>|
5959

60-
## Example
60+
## Example: malloca
6161

6262
```C
6363
// crt_malloca_simple.c
@@ -77,7 +77,7 @@ int main()
7777
}
7878
```
7979

80-
## Example
80+
## Example: malloca exception
8181

8282
```C
8383
// crt_malloca_exception.c

docs/c-runtime-library/reference/set-se-translator.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ When using **_set_se_translator** from managed code (code compiled with /clr) or
6060
6161
For more compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
6262
63-
## Example
63+
## Example: Catch __try exception error
6464
6565
This sample wraps the calls to set a structured exception translator and to restore the old one in an RAII class, `Scoped_SE_Translator`. This class lets you introduce a scope-specific translator as a single declaration. The class destructor restores the original translator when control leaves the scope.
6666
@@ -133,7 +133,7 @@ In __finally
133133
Caught a __try exception, error c0000094.
134134
```
135135

136-
## Example
136+
## Example: Catch SE_Exception error
137137

138138
Although the functionality provided by **_set_se_translator** is not available in managed code, it is possible to use this mapping in native code, even if that native code is in a compilation under the **/clr** switch, as long as the native code is indicated using `#pragma unmanaged`. If a structured exception is being thrown in managed code that is to be mapped, the code that generates and handles the exception must be marked `#pragma unmanaged`. The following code shows a possible use. For more information, see [Pragma Directives and the __Pragma Keyword](../../preprocessor/pragma-directives-and-the-pragma-keyword.md).
139139

docs/c-runtime-library/reference/setmode.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ By default, this function's global state is scoped to the application. To change
6262

6363
For more compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
6464

65-
## Example
65+
## Example: Use _setmode to change stdin
6666

6767
```C
6868
// crt_setmode.c
@@ -90,7 +90,7 @@ int main( void )
9090
'stdin' successfully changed to binary mode
9191
```
9292

93-
## Example
93+
## Example: Use _setmode to change stdout
9494

9595
```C
9696
// crt_setmodeunicode.c

docs/c-runtime-library/reference/sprintf-p-sprintf-p-l-swprintf-p-swprintf-p-l.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ The **_sprintf_p** function formats and stores a series of characters and values
9191

9292
For additional compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
9393

94-
## Example
94+
## Example: Use _sprintf_p to format data
9595

9696
```C
9797
// crt_sprintf_p.c
@@ -134,7 +134,7 @@ Output:
134134
character count = 79
135135
```
136136

137-
## Example
137+
## Example: Error code handling
138138

139139
```C
140140
// crt_swprintf_p.c

docs/c-runtime-library/reference/sprintf-s-sprintf-s-l-swprintf-s-swprintf-s-l.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ There are versions of **sprintf_s** that offer additional control over what happ
111111

112112
For additional compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
113113

114-
## Example
114+
## Example: Use sprintf_s to format data
115115

116116
```C
117117
// crt_sprintf_s.c
@@ -147,7 +147,7 @@ Output:
147147
character count = 79
148148
```
149149

150-
## Example
150+
## Example: Error code handling
151151

152152
```C
153153
// crt_swprintf_s.c

docs/c-runtime-library/reference/sprintf-sprintf-l-swprintf-swprintf-l-swprintf-l.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ In C++, these functions have template overloads that invoke the newer, secure co
115115

116116
For additional compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
117117

118-
## Example
118+
## Example: Use sprintf to format data
119119

120120
```C
121121
// crt_sprintf.c
@@ -152,7 +152,7 @@ Output:
152152
character count = 79
153153
```
154154

155-
## Example
155+
## Example: Error code handling
156156

157157
```C
158158
// crt_swprintf.c

docs/c-runtime-library/reference/strncpy-s-strncpy-s-l-wcsncpy-s-wcsncpy-s-l-mbsncpy-s-mbsncpy-s-l.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ By default, this function's global state is scoped to the application. To change
187187

188188
For additional compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
189189

190-
## Example
190+
## Example: Copy chars to a buffer
191191

192192
```cpp
193193
// crt_strncpy_s_1.cpp
@@ -314,7 +314,7 @@ Invalid parameter handler invoked: (L"Buffer is too small" && 0)
314314
new contents of dest: ''
315315
```
316316

317-
## Example
317+
## Example: strncpy and strncpy_s
318318

319319
```C
320320
// crt_strncpy_s_2.c

docs/c-runtime-library/reference/vsnprintf-vsnprintf-vsnprintf-l-vsnwprintf-vsnwprintf-l.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,7 @@ In C++, these functions have template overloads that invoke the newer, secure co
153153

154154
The **_vsnprintf**, **_vsnprintf_l**, **_vsnwprintf** and **_vsnwprintf_l** functions are Microsoft-specific. For additional compatibility information, see [Compatibility](../../c-runtime-library/compatibility.md).
155155

156-
## Example
156+
## Example: Use wide characters with `_vsnwprintf()`
157157

158158
```C
159159
// crt_vsnwprintf.c
@@ -195,7 +195,7 @@ nSize: -1, buff: Hi there!
195195

196196
The behavior changes if you use vsnprintf instead, along with narrow-string parameters. The *count* parameter can be the entire size of the buffer, and the return value is the number of characters that would have been written if *count* was large enough:
197197

198-
## Example
198+
## Example: Use `vsnprintf()` with narrow strings
199199

200200
```C
201201
// crt_vsnprintf.c

docs/cpp/member-function-templates.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ The term member template refers to both member function templates and nested cla
1010

1111
Member functions can be function templates in several contexts. All functions of class templates are generic but are not referred to as member templates or member function templates. If these member functions take their own template arguments, they are considered to be member function templates.
1212

13-
## Example
13+
## Example: Declare member function templates
1414

1515
Member function templates of nontemplate or template classes are declared as function templates with their template parameters.
1616

@@ -29,7 +29,7 @@ int main()
2929
}
3030
```
3131

32-
## Example
32+
## Example: Member function template of template class
3333

3434
The following example shows a member function template of a template class.
3535

@@ -50,7 +50,7 @@ int main()
5050
}
5151
```
5252

53-
## Example
53+
## Example: Define member templates outside class
5454

5555
```cpp
5656
// defining_member_templates_outside_class.cpp
@@ -72,7 +72,7 @@ int main()
7272
}
7373
```
7474

75-
## Example
75+
## Example: Templated user-defined conversion
7676

7777
Local classes are not allowed to have member templates.
7878

docs/cpp/move-constructors-and-move-assignment-operators-cpp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ The following procedures describe how to write a move constructor and a move ass
161161
return *this;
162162
```
163163
164-
## Example
164+
## Example: Complete move constructor and assignment operator
165165
166166
The following example shows the complete move constructor and move assignment operator for the `MemoryBlock` class:
167167
@@ -210,7 +210,7 @@ MemoryBlock& operator=(MemoryBlock&& other) noexcept
210210
}
211211
```
212212

213-
## Example
213+
## Example Use move semantics to improve performance
214214

215215
The following example shows how move semantics can improve the performance of your applications. The example adds two elements to a vector object and then inserts a new element between the two existing elements. The `vector` class uses move semantics to perform the insertion operation efficiently by moving the elements of the vector instead of copying them.
216216

docs/cpp/name-resolution-for-locally-declared-names.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ ms.assetid: 743b88f3-de11-48f4-ae83-931449ea3886
77

88
The template's name itself can be referred to with or without the template arguments. In the scope of a class template, the name itself refers to the template. In the scope of a template specialization or partial specialization, the name alone refers to the specialization or partial specialization. Other specializations or partial specializations of the template can also be referenced, with the appropriate template arguments.
99

10-
## Example
10+
## Example: Specialization versus partial specialization
1111

1212
The following code shows that the class template's name A is interpreted differently in the scope of a specialization or partial specialization.
1313

@@ -29,7 +29,7 @@ template<> class A<int> {
2929
};
3030
```
3131
32-
## Example
32+
## Example: Name conflict between template parameter and object
3333
3434
In the case of a name conflict between a template parameter and another object, the template parameter can or cannot be hidden. The following rules will help determine precedence.
3535
@@ -49,7 +49,7 @@ int main() {
4949
}
5050
```
5151

52-
## Example
52+
## Example: Define member function outside class template
5353

5454
When defining a template's member functions outside the class template, a different template parameter name can be used. If the template member function definition uses a different name for the template parameter than the declaration does, and the name used in the definition conflicts with another member of the declaration, the member in the template declaration takes precedence.
5555

@@ -84,7 +84,7 @@ int main() {
8484
Z::Z()
8585
```
8686

87-
## Example
87+
## Example: Define template or member function outside namespace
8888

8989
When defining a template function or member function outside the namespace in which the template was declared, the template argument takes precedence over the names of other members of the namespace.
9090

@@ -118,7 +118,7 @@ int main() {
118118
C<T>::g
119119
```
120120

121-
## Example
121+
## Example: Base class or member name hides template argument
122122

123123
In definitions that are outside of the template class declaration, if a template class has a base class that does not depend on a template argument and if the base class or one of its members has the same name as a template argument, then the base class or member name hides the template argument.
124124

docs/cpp/new-operator-cpp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Specifies type to be allocated; it can be either a built-in or user-defined type
6363
*initializer*<br/>
6464
Provides a value for the initialized object. Initializers cannot be specified for arrays. The **`new`** operator will create arrays of objects only if the class has a default constructor.
6565

66-
## Example
66+
## Example: Allocate and free a character array
6767

6868
The following code example allocates a character array and an object of class `CName` and then frees them.
6969

@@ -108,7 +108,7 @@ int main() {
108108
}
109109
```
110110
111-
## Example
111+
## Example: `new` operator
112112
113113
If you use the placement new form of the **`new`** operator, the form with arguments in addition to the size of the allocation, the compiler does not support a placement form of the **`delete`** operator if the constructor throws an exception. For example:
114114

docs/cpp/overload-resolution-of-function-template-calls.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ ms.assetid: a2918748-2cbb-4fc6-a176-e256f120bee4
88

99
A function template can overload nontemplate functions of the same name. In this scenario, function calls are resolved by first using template argument deduction to instantiate the function template with a unique specialization. If template argument deduction fails, the other function overloads are considered to resolve the call. These other overloads, also known as the candidate set, include nontemplate functions and other instantiated function templates. If template argument deduction succeeds, then the generated function is compared with the other functions to determine the best match, following the rules for overload resolution. For more information, see [Function Overloading](function-overloading.md).
1010

11-
## Example
11+
## Example: Choose a nontemplate function
1212

1313
If a nontemplate function is an equally good match to a template function, the nontemplate function is chosen (unless the template arguments were explicitly specified), as in the call `f(1, 1)` in the following example.
1414

@@ -41,7 +41,7 @@ void f(T1, T2)
4141
void f(T1, T2)
4242
```
4343

44-
## Example
44+
## Example: Exact match template function preferred
4545

4646
The next example illustrates that the exactly matching template function is preferred if the nontemplate function requires a conversion.
4747

docs/cpp/selectany.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ A global data item can normally be initialized only once in an EXE or DLL projec
2828
> [!NOTE]
2929
> **`selectany`** can only be applied to the actual initialization of global data items that are externally visible.
3030
31-
## Example
31+
## Example: `selectany` attribute
3232

3333
This code shows how to use the **`selectany`** attribute:
3434

@@ -62,7 +62,7 @@ int i;
6262
__declspec(selectany) X x(1);
6363
```
6464
65-
## Example
65+
## Example: Use `selectany` attribute to ensure data COMDAT folding
6666
6767
This code shows how to use the **`selectany`** attribute to ensure data COMDAT folding when you also use the [`/OPT:ICF`](../build/reference/opt-optimizations.md) linker option. Note that data must be marked with **`selectany`** and placed in a **`const`** (readonly) section. You must explicitly specify the read-only section.
6868

docs/cpp/static-assert.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,21 +35,21 @@ The compiler examines the **`static_assert`** declaration for syntax errors when
3535

3636
You can use the **`static_assert`** keyword at namespace, class, or block scope. (The **`static_assert`** keyword is technically a declaration, even though it does not introduce new name into your program, because it can be used at namespace scope.)
3737

38-
## Description of static_assert with namespace scope
38+
## Description of `static_assert` with namespace scope
3939

4040
In the following example, the **`static_assert`** declaration has namespace scope. Because the compiler knows the size of type `void *`, the expression is evaluated immediately.
4141

42-
## Example of static_assert with namespace scope
42+
## Example: `static_assert` with namespace scope
4343

4444
```cpp
4545
static_assert(sizeof(void *) == 4, "64-bit code generation is not supported.");
4646
```
4747
48-
## Description of static_assert with class scope
48+
## Description of `static_assert` with class scope
4949
5050
In the following example, the **`static_assert`** declaration has class scope. The **`static_assert`** verifies that a template parameter is a *plain old data* (POD) type. The compiler examines the **`static_assert`** declaration when it is declared, but does not evaluate the *constant-expression* parameter until the `basic_string` class template is instantiated in `main()`.
5151
52-
## Example of static_assert with class scope
52+
## Example: `static_assert` with class scope
5353
5454
```cpp
5555
#include <type_traits>
@@ -74,11 +74,11 @@ int main()
7474
}
7575
```
7676

77-
## Description
77+
## Description of `static_assert` with block scope
7878

7979
In the following example, the **`static_assert`** declaration has block scope. The **`static_assert`** verifies that the size of the VMPage structure is equal to the virtual memory pagesize of the system.
8080

81-
## Example
81+
## Example: `static_assert` at block scope
8282

8383
```cpp
8484
#include <sys/param.h> // defines PAGESIZE

docs/cpp/template-specialization-cpp.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Class templates can be partially specialized, and the resulting class is still a
1212

1313
- A template has only one type, but a specialization is needed for pointer, reference, pointer to member, or function pointer types. The specialization itself is still a template on the type pointed to or referenced.
1414

15-
## Example
15+
## Example: Partial specialization of class templates
1616

1717
```cpp
1818
// partial_specialization_of_class_templates.cpp
@@ -59,7 +59,7 @@ PTS<S*>::IsPointer == 1 PTS<S*>::IsPointerToDataMember ==0
5959
PTS<int S::*>::IsPointer == 0 PTS<int S::*>::IsPointerToDataMember == 1
6060
```
6161

62-
## Example
62+
## Example: Partial specialization for pointer types
6363

6464
If you have a template collection class that takes any type `T`, you can create a partial specialization that takes any pointer type `T*`. The following code demonstrates a collection class template `Bag` and a partial specialization for pointer types in which the collection dereferences the pointer types before copying them to the array. The collection then stores the values that are pointed to. With the original template, only the pointers themselves would have been stored in the collection, leaving the data vulnerable to deletion or modification. In this special pointer version of the collection, code to check for a null pointer in the `add` method is added.
6565

@@ -171,7 +171,7 @@ Null pointer!
171171
3 87 8 100
172172
```
173173

174-
## Example
174+
## Example: Define partial specialization so one type is `int`
175175

176176
The following example defines a template class that takes pairs of any two types and then defines a partial specialization of that template class specialized so that one of the types is **`int`**. The specialization defines an additional sort method that implements a simple bubble sort based on the integer.
177177

0 commit comments

Comments
 (0)