Skip to content

Repo sync for protected CLA branch #2531

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 23 commits into from
Oct 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
ef42af1
1769497, fixed duplicate headings.
john-par Sep 28, 2020
0bd60e3
Merge branch 'master' of https://github.com/MicrosoftDocs/cpp-docs-pr…
john-par Sep 29, 2020
4e4e6aa
1769497, fixed typos.
john-par Sep 29, 2020
81431a9
1769497, fixed a few more typos.
john-par Sep 29, 2020
fe38fd6
1769497, fixed one more typo.
john-par Sep 29, 2020
397c07f
Merge branch 'master' into 1769497-fix-build-validation-issues-09-28
Oct 6, 2020
b977d16
1769497, incorporated author feedback.
john-par Oct 6, 2020
735ecb3
Merge branch 'master' of https://github.com/MicrosoftDocs/cpp-docs-pr…
john-par Oct 6, 2020
54f9dcb
1769497, started incorporating more author feedback.
john-par Oct 6, 2020
42c1a4f
169497, reverted multithreading-and-locales.md to reviewed state.
john-par Oct 6, 2020
e01b77b
Merge branch 'master' of https://github.com/MicrosoftDocs/cpp-docs-pr…
john-par Oct 7, 2020
608a1b5
1769497, incorporated author/SME feedback.
john-par Oct 7, 2020
ba940dc
1769497, fixed typos.
john-par Oct 7, 2020
baea511
1769497, fixed one more typo.
john-par Oct 7, 2020
f6920c3
Merge branch 'master' of https://github.com/MicrosoftDocs/cpp-docs-pr…
john-par Oct 9, 2020
eb8ce5f
1769497, incorporating author feedback.
john-par Oct 9, 2020
b595d43
1769497, incorporated author feedback.
john-par Oct 9, 2020
54920da
Merge branch 'master' of https://github.com/MicrosoftDocs/cpp-docs-pr…
john-par Oct 12, 2020
f543e34
1769497, incorporated author feedback.
john-par Oct 12, 2020
72f9c3f
1769497, incorporated author feedback.
john-par Oct 12, 2020
b9eea8b
Merge pull request #3204 from MicrosoftDocs/FromPublicMasterBranch
PRMerger16 Oct 12, 2020
94f9b03
Merge pull request #3173 from john-par/1769497-fix-build-validation-i…
v-shmck Oct 12, 2020
43cee7a
Merge pull request #3205 from MicrosoftDocs/master
Taojunshen Oct 13, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ Because each copy of the CRT library has its own heap manager, allocating memory

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.

## Example
## Example: Pass file handle across DLL boundary

### Description

Expand Down Expand Up @@ -68,7 +68,7 @@ int main(void)
this is a string
```

## Example
## Example: Pass environment variables across DLL boundary

### Description

Expand Down
4 changes: 2 additions & 2 deletions docs/c-runtime-library/reference/malloca.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ In addition to the above restrictions, when using the [/clr (Common Language Run
|-------------|---------------------|
|**_malloca**|\<malloc.h>|

## Example
## Example: malloca

```C
// crt_malloca_simple.c
Expand All @@ -77,7 +77,7 @@ int main()
}
```

## Example
## Example: malloca exception

```C
// crt_malloca_exception.c
Expand Down
4 changes: 2 additions & 2 deletions docs/c-runtime-library/reference/set-se-translator.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ When using **_set_se_translator** from managed code (code compiled with /clr) or

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

## Example
## Example: Catch __try exception error

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.

Expand Down Expand Up @@ -133,7 +133,7 @@ In __finally
Caught a __try exception, error c0000094.
```

## Example
## Example: Catch SE_Exception error

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).

Expand Down
4 changes: 2 additions & 2 deletions docs/c-runtime-library/reference/setmode.md
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ By default, this function's global state is scoped to the application. To change

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

## Example
## Example: Use _setmode to change stdin

```C
// crt_setmode.c
Expand Down Expand Up @@ -90,7 +90,7 @@ int main( void )
'stdin' successfully changed to binary mode
```

## Example
## Example: Use _setmode to change stdout

```C
// crt_setmodeunicode.c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ The **_sprintf_p** function formats and stores a series of characters and values

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

## Example
## Example: Use _sprintf_p to format data

```C
// crt_sprintf_p.c
Expand Down Expand Up @@ -134,7 +134,7 @@ Output:
character count = 79
```

## Example
## Example: Error code handling

```C
// crt_swprintf_p.c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ There are versions of **sprintf_s** that offer additional control over what happ

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

## Example
## Example: Use sprintf_s to format data

```C
// crt_sprintf_s.c
Expand Down Expand Up @@ -147,7 +147,7 @@ Output:
character count = 79
```

## Example
## Example: Error code handling

```C
// crt_swprintf_s.c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ In C++, these functions have template overloads that invoke the newer, secure co

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

## Example
## Example: Use sprintf to format data

```C
// crt_sprintf.c
Expand Down Expand Up @@ -152,7 +152,7 @@ Output:
character count = 79
```

## Example
## Example: Error code handling

```C
// crt_swprintf.c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ By default, this function's global state is scoped to the application. To change

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

## Example
## Example: Copy chars to a buffer

```cpp
// crt_strncpy_s_1.cpp
Expand Down Expand Up @@ -314,7 +314,7 @@ Invalid parameter handler invoked: (L"Buffer is too small" && 0)
new contents of dest: ''
```

## Example
## Example: strncpy and strncpy_s

```C
// crt_strncpy_s_2.c
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ In C++, these functions have template overloads that invoke the newer, secure co

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

## Example
## Example: Use wide characters with `_vsnwprintf()`

```C
// crt_vsnwprintf.c
Expand Down Expand Up @@ -195,7 +195,7 @@ nSize: -1, buff: Hi there!

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:

## Example
## Example: Use `vsnprintf()` with narrow strings

```C
// crt_vsnprintf.c
Expand Down
8 changes: 4 additions & 4 deletions docs/cpp/member-function-templates.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The term member template refers to both member function templates and nested cla

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.

## Example
## Example: Declare member function templates

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

Expand All @@ -29,7 +29,7 @@ int main()
}
```

## Example
## Example: Member function template of template class

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

Expand All @@ -50,7 +50,7 @@ int main()
}
```

## Example
## Example: Define member templates outside class

```cpp
// defining_member_templates_outside_class.cpp
Expand All @@ -72,7 +72,7 @@ int main()
}
```

## Example
## Example: Templated user-defined conversion

Local classes are not allowed to have member templates.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ The following procedures describe how to write a move constructor and a move ass
return *this;
```

## Example
## Example: Complete move constructor and assignment operator

The following example shows the complete move constructor and move assignment operator for the `MemoryBlock` class:

Expand Down Expand Up @@ -210,7 +210,7 @@ MemoryBlock& operator=(MemoryBlock&& other) noexcept
}
```

## Example
## Example Use move semantics to improve performance

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.

Expand Down
10 changes: 5 additions & 5 deletions docs/cpp/name-resolution-for-locally-declared-names.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ ms.assetid: 743b88f3-de11-48f4-ae83-931449ea3886

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.

## Example
## Example: Specialization versus partial specialization

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

Expand All @@ -29,7 +29,7 @@ template<> class A<int> {
};
```

## Example
## Example: Name conflict between template parameter and object

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.

Expand All @@ -49,7 +49,7 @@ int main() {
}
```

## Example
## Example: Define member function outside class template

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.

Expand Down Expand Up @@ -84,7 +84,7 @@ int main() {
Z::Z()
```

## Example
## Example: Define template or member function outside namespace

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.

Expand Down Expand Up @@ -118,7 +118,7 @@ int main() {
C<T>::g
```

## Example
## Example: Base class or member name hides template argument

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.

Expand Down
4 changes: 2 additions & 2 deletions docs/cpp/new-operator-cpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ Specifies type to be allocated; it can be either a built-in or user-defined type
*initializer*<br/>
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.

## Example
## Example: Allocate and free a character array

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

Expand Down Expand Up @@ -108,7 +108,7 @@ int main() {
}
```

## Example
## Example: `new` operator

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:

Expand Down
4 changes: 2 additions & 2 deletions docs/cpp/overload-resolution-of-function-template-calls.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ ms.assetid: a2918748-2cbb-4fc6-a176-e256f120bee4

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).

## Example
## Example: Choose a nontemplate function

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.

Expand Down Expand Up @@ -41,7 +41,7 @@ void f(T1, T2)
void f(T1, T2)
```

## Example
## Example: Exact match template function preferred

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

Expand Down
4 changes: 2 additions & 2 deletions docs/cpp/selectany.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ A global data item can normally be initialized only once in an EXE or DLL projec
> [!NOTE]
> **`selectany`** can only be applied to the actual initialization of global data items that are externally visible.

## Example
## Example: `selectany` attribute

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

Expand Down Expand Up @@ -62,7 +62,7 @@ int i;
__declspec(selectany) X x(1);
```

## Example
## Example: Use `selectany` attribute to ensure data COMDAT folding

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.

Expand Down
12 changes: 6 additions & 6 deletions docs/cpp/static-assert.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,21 +35,21 @@ The compiler examines the **`static_assert`** declaration for syntax errors when

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.)

## Description of static_assert with namespace scope
## Description of `static_assert` with namespace scope

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.

## Example of static_assert with namespace scope
## Example: `static_assert` with namespace scope

```cpp
static_assert(sizeof(void *) == 4, "64-bit code generation is not supported.");
```

## Description of static_assert with class scope
## Description of `static_assert` with class scope

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()`.

## Example of static_assert with class scope
## Example: `static_assert` with class scope

```cpp
#include <type_traits>
Expand All @@ -74,11 +74,11 @@ int main()
}
```

## Description
## Description of `static_assert` with block scope

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.

## Example
## Example: `static_assert` at block scope

```cpp
#include <sys/param.h> // defines PAGESIZE
Expand Down
6 changes: 3 additions & 3 deletions docs/cpp/template-specialization-cpp.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ Class templates can be partially specialized, and the resulting class is still a

- 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.

## Example
## Example: Partial specialization of class templates

```cpp
// partial_specialization_of_class_templates.cpp
Expand Down Expand Up @@ -59,7 +59,7 @@ PTS<S*>::IsPointer == 1 PTS<S*>::IsPointerToDataMember ==0
PTS<int S::*>::IsPointer == 0 PTS<int S::*>::IsPointerToDataMember == 1
```

## Example
## Example: Partial specialization for pointer types

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.

Expand Down Expand Up @@ -171,7 +171,7 @@ Null pointer!
3 87 8 100
```

## Example
## Example: Define partial specialization so one type is `int`

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.

Expand Down
Loading