Skip to content

Commit 76cd173

Browse files
authored
Merge pull request MicrosoftDocs#310 from MicrosoftDocs/FromPublicMasterBranch
Confirm merge from FromPublicMasterBranch to master to sync with https://github.com/MicrosoftDocs/cpp-docs (branch master)
2 parents ba91b1b + fb0980c commit 76cd173

File tree

7 files changed

+95
-95
lines changed

7 files changed

+95
-95
lines changed

docs/build/msbuild-visual-cpp-overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ MSBuild is the standard build system for Visual C++ projects. When you build a p
4040

4141
Read the following documents about MSBuild.
4242

43-
- [MSBuild](/visualstudio/msbuild/msbuild1)
43+
- [MSBuild](/visualstudio/msbuild/msbuild)
4444
Overview of MSBuild concepts.
4545

4646
- [MSBuild Reference](/visualstudio/msbuild/msbuild-reference)
@@ -154,4 +154,4 @@ The following table lists several useful user-oriented targets.
154154

155155
## See Also
156156

157-
[MSBuild (Visual C++)](../build/msbuild-visual-cpp.md)
157+
[MSBuild (Visual C++)](../build/msbuild-visual-cpp.md)

docs/cpp/class-member-overview.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ translation.priority.ht:
3636
- "zh-tw"
3737
---
3838
# Class Member Overview
39-
A class or struct consists of its members. The work that a class does is performed by its member functions. The state that it maintains is stored in its data members. Initialization of members is done by constructors, and cleanup work such as freeing of memory and releasing of resources is done by constructors. In C++11 and later, data members can (and usually should) be initialized at the point of declaration.
39+
A class or struct consists of its members. The work that a class does is performed by its member functions. The state that it maintains is stored in its data members. Initialization of members is done by constructors, and cleanup work such as freeing of memory and releasing of resources is done by destructors. In C++11 and later, data members can (and usually should) be initialized at the point of declaration.
4040

4141
## Kinds of class members
4242
The full list of member categories is as follows:
@@ -186,4 +186,4 @@ int CanInit2::j = i;
186186
> The class name, `CanInit2`, must precede `i` to specify that the `i` being defined is a member of class `CanInit2`.
187187
188188
## See Also
189-
[Classes and Structs](../cpp/classes-and-structs-cpp.md)
189+
[Classes and Structs](../cpp/classes-and-structs-cpp.md)

docs/cpp/noalias.md

Lines changed: 86 additions & 86 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@ ms.custom: ""
44
ms.date: "11/04/2016"
55
ms.reviewer: ""
66
ms.suite: ""
7-
ms.technology:
7+
ms.technology:
88
- "cpp-language"
99
ms.tgt_pltfrm: ""
1010
ms.topic: "language-reference"
11-
f1_keywords:
11+
f1_keywords:
1212
- "noalias"
1313
- "noalias_cpp"
14-
dev_langs:
14+
dev_langs:
1515
- "C++"
16-
helpviewer_keywords:
16+
helpviewer_keywords:
1717
- "noalias __declspec keyword"
1818
- "__declspec keyword [C++], noalias"
1919
ms.assetid: efafa8b0-7f39-4edc-a81e-d287ae882c9b
2020
caps.latest.revision: 12
2121
author: "mikeblome"
2222
ms.author: "mblome"
2323
manager: "ghogen"
24-
translation.priority.ht:
24+
translation.priority.ht:
2525
- "cs-cz"
2626
- "de-de"
2727
- "es-es"
@@ -37,85 +37,85 @@ translation.priority.ht:
3737
- "zh-tw"
3838
---
3939
# noalias
40-
**Microsoft Specific**
41-
42-
`noalias` means that a function call does not modify or reference visible global state and only modifies the memory pointed to `directly` by pointer parameters (first-level indirections).
43-
44-
If a function is annotated as `noalias`, the optimizer can assume that, in addition to the parameters themselves, only first-level indirections of pointer parameters are referenced or modified inside the function. The visible global state is the set of all data that is not defined or referenced outside of the compilation scope, and their address is not taken. The compilation scope is all source files ([/LTCG (Link-time Code Generation)](../build/reference/ltcg-link-time-code-generation.md) builds) or a single source file (non-**/LTCG** build).
45-
46-
## Example
47-
The following sample demonstrates using `__declspec(restrict)` and `__declspec(noalias)`. Normally, memory returned from `malloc` is `restrict` and `noalias` because the CRT headers are decorated appropriately.
48-
49-
However, in this example, the pointers `mempool` and `memptr` are global so the compiler has no assurance that the memory is not subject to aliasing. Decorating the functions that return pointers with `__declspec(restrict)` tells the compiler that the memory pointed to by the return value is not aliased.
50-
51-
Decorating the function in the example that accesses memory with `__declspec(noalias)` tells the compiler that this function does not interfere with the global state except through the pointers in its parameter list.
52-
53-
```
54-
// declspec_noalias.c
55-
#include <stdio.h>
56-
#include <stdlib.h>
57-
58-
#define M 800
59-
#define N 600
60-
#define P 700
61-
62-
float * mempool, * memptr;
63-
64-
__declspec(restrict) float * ma(int size)
65-
{
66-
float * retval;
67-
retval = memptr;
68-
memptr += size;
69-
return retval;
70-
}
71-
72-
__declspec(restrict) float * init(int m, int n)
73-
{
74-
float * a;
75-
int i, j;
76-
int k=1;
77-
78-
a = ma(m * n);
79-
if (!a) exit(1);
80-
for (i=0; i<m; i++)
81-
for (j=0; j<n; j++)
82-
a[i*n+j] = 0.1/k++;
83-
return a;
84-
}
85-
86-
__declspec(noalias) void multiply(float * a, float * b, float * c)
87-
{
88-
int i, j, k;
89-
90-
for (j=0; j<P; j++)
91-
for (i=0; i<M; i++)
92-
for (k=0; k<N; k++)
93-
c[i * P + j] =
94-
a[i * N + k] *
95-
b[k * P + j];
96-
}
97-
98-
int main()
99-
{
100-
float * a, * b, * c;
101-
102-
mempool = (float *) malloc(sizeof(float) * (M*N + N*P + M*P));
103-
104-
if (!mempool)
105-
{
106-
puts("ERROR: Malloc returned null");
107-
exit(1);
108-
}
109-
110-
memptr = mempool;
111-
a = init(M, N);
112-
b = init(N, P);
113-
c = init(M, P);
114-
115-
multiply(a, b, c);
116-
}
117-
```
118-
119-
## See Also
120-
[__declspec](../cpp/declspec.md)
40+
**Microsoft Specific**
41+
42+
`noalias` means that a function call does not modify or reference visible global state and only modifies the memory pointed to *directly* by pointer parameters (first-level indirections).
43+
44+
If a function is annotated as `noalias`, the optimizer can assume that, in addition to the parameters themselves, only first-level indirections of pointer parameters are referenced or modified inside the function. The visible global state is the set of all data that is not defined or referenced outside of the compilation scope, and their address is not taken. The compilation scope is all source files ([/LTCG (Link-time Code Generation)](../build/reference/ltcg-link-time-code-generation.md) builds) or a single source file (non-**/LTCG** build).
45+
46+
## Example
47+
The following sample demonstrates using `__declspec(restrict)` and `__declspec(noalias)`. Normally, memory returned from `malloc` is `restrict` because the CRT headers are decorated appropriately.
48+
49+
However, in this example, the pointers `mempool` and `memptr` are global so the compiler has no assurance that the memory is not subject to aliasing. Decorating the functions that return pointers with `__declspec(restrict)` tells the compiler that the memory pointed to by the return value is not aliased.
50+
51+
Decorating the function in the example that accesses memory with `__declspec(noalias)` tells the compiler that this function does not interfere with the global state except through the pointers in its parameter list.
52+
53+
```
54+
// declspec_noalias.c
55+
#include <stdio.h>
56+
#include <stdlib.h>
57+
58+
#define M 800
59+
#define N 600
60+
#define P 700
61+
62+
float * mempool, * memptr;
63+
64+
__declspec(restrict) float * ma(int size)
65+
{
66+
float * retval;
67+
retval = memptr;
68+
memptr += size;
69+
return retval;
70+
}
71+
72+
__declspec(restrict) float * init(int m, int n)
73+
{
74+
float * a;
75+
int i, j;
76+
int k=1;
77+
78+
a = ma(m * n);
79+
if (!a) exit(1);
80+
for (i=0; i<m; i++)
81+
for (j=0; j<n; j++)
82+
a[i*n+j] = 0.1/k++;
83+
return a;
84+
}
85+
86+
__declspec(noalias) void multiply(float * a, float * b, float * c)
87+
{
88+
int i, j, k;
89+
90+
for (j=0; j<P; j++)
91+
for (i=0; i<M; i++)
92+
for (k=0; k<N; k++)
93+
c[i * P + j] =
94+
a[i * N + k] *
95+
b[k * P + j];
96+
}
97+
98+
int main()
99+
{
100+
float * a, * b, * c;
101+
102+
mempool = (float *) malloc(sizeof(float) * (M*N + N*P + M*P));
103+
104+
if (!mempool)
105+
{
106+
puts("ERROR: Malloc returned null");
107+
exit(1);
108+
}
109+
110+
memptr = mempool;
111+
a = init(M, N);
112+
b = init(N, P);
113+
c = init(M, P);
114+
115+
multiply(a, b, c);
116+
}
117+
```
118+
119+
## See Also
120+
[__declspec](../cpp/declspec.md)
121121
[Keywords](../cpp/keywords-cpp.md)

docs/cpp/special-member-functions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ The *special member functions* are class (or struct) member functions that, in c
4343

4444
You can explicitly declare a default special member function by using the `= default` keyword. This causes the compiler to define the function only if needed, in the same way as if the function was not declared at all.
4545

46-
In some cases, the compiler may generate *deleted* special member functions, which are not defined and therefore not callable. This can happen in cases where a call to a particular special member function on a class doesn't make sense, given other properties of the class. To explicitly prevent automatic generation of a special member function, you can declare it as deleted by using the `= deleted` keyword.
46+
In some cases, the compiler may generate *deleted* special member functions, which are not defined and therefore not callable. This can happen in cases where a call to a particular special member function on a class doesn't make sense, given other properties of the class. To explicitly prevent automatic generation of a special member function, you can declare it as deleted by using the `= delete` keyword.
4747

4848
The compiler generates a *default constructor*, a constructor that takes no arguments, only when you have not declared any other constructor. If you have declared only a constructor that takes parameters, code that attempts to call a default constructor causes the compiler to produce an error message. The compiler-generated default constructor performs simple member-wise [default initialization](initializers.md#default_initialization) of the object. Default initialization leaves all member variables in an indeterminate state.
4949

docs/cpp/template-specialization-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ PTS<int S::*>::IsPointer == 0 PTS<int S::*>::IsPointerToDataMember == 1
8989
```
9090

9191
## Example
92-
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.
92+
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.
9393

9494
```
9595
// partial_specialization_of_class_templates2.cpp

docs/preprocessor/hash-import-directive-cpp.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ using namespace MyLib;
194194
195195
You must determine which of the dependency comments are not otherwise provided for by system headers and then provide an `#import` directive at some point before the `#import` directive of the dependent type library to resolve the errors.
196196
197-
For more information, see the Knowledge Base article "#import Wrapper Methods May Cause Access Violation" (Q242527) or "Compiler Errors When You Use #import with XML" (Q269194). You can find Knowledge Base articles on the MSDN Library media or at [http://support.microsoft.com/support/](http://support.microsoft.com/support/).
197+
For more information, see the Knowledge Base article "#import Wrapper Methods May Cause Access Violation" (Q242527) or "Compiler Errors When You Use #import with XML" (Q269194). You can find Knowledge Base articles on the MSDN Library media or at [Microsoft Support](https://support.microsoft.com/).
198198
199199
## <a name="_predir_the_23import_directive_import_attributes"></a> #import Attributes
200200
`#import` can optionally include one or more attributes. These attributes tell the compiler to modify the contents of the type-library headers. A backslash (**\\**) symbol can be used to include additional lines in a single `#import` statement. For example:
@@ -210,4 +210,4 @@ using namespace MyLib;
210210
211211
## See Also
212212
[Preprocessor Directives](../preprocessor/preprocessor-directives.md)
213-
[Compiler COM Support](../cpp/compiler-com-support.md)
213+
[Compiler COM Support](../cpp/compiler-com-support.md)

docs/windows/desktop-applications-visual-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,4 @@ A *desktop application* in C++ is a native application that can access the full
6565
|[Visual C++](../visual-cpp-in-visual-studio.md)|Describes key features of Visual C++ in Visual Studio and links to the rest of the Visual C++ documentation.|
6666

6767
## See Also
68-
[Visual C++](../visual-cpp-in-visual-studio.md)
68+
[Visual C++](../visual-cpp-in-visual-studio.md)

0 commit comments

Comments
 (0)