You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/cpp/trivial-standard-layout-and-pod-types.md
+1-5Lines changed: 1 addition & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,6 @@ struct Trivial2
41
41
private:
42
42
int j; // Different access control
43
43
};
44
-
45
44
```
46
45
47
46
## Standard layout types
@@ -74,7 +73,6 @@ struct SL
74
73
int j;
75
74
SL(int a, int b) : i(a), j(b) {} // User-defined constructor OK
76
75
};
77
-
78
76
```
79
77
80
78
The last two requirements can perhaps be better illustrated with code. In the next example, even though Base is standard-layout, `Derived` is not standard layout because both it (the most derived class) and `Base` have non-static data members:
@@ -180,7 +178,6 @@ int main()
180
178
181
179
return 0;
182
180
}
183
-
184
181
```
185
182
186
183
## <aname="literal_types"></a> Literal types
@@ -193,6 +190,5 @@ A literal type is one whose layout can be determined at compile time. The follow
193
190
- Arrays of void, scalar types or references
194
191
- A class that has a trivial destructor, and one or more constexpr constructors that are not move or copy constructors. Additionally, all its non-static data members and base classes must be literal types and not volatile.
Copy file name to clipboardExpand all lines: docs/cpp/try-finally-statement.md
+6-6Lines changed: 6 additions & 6 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,7 @@ ms.workload: ["cplusplus"]
15
15
# try-finally Statement
16
16
**Microsoft Specific**
17
17
18
-
The following syntax describes the `try-finally` statement:
18
+
The following syntax describes the **try-finally** statement:
19
19
20
20
```cpp
21
21
__try {
@@ -32,7 +32,7 @@ __finally {
32
32
33
33
**__finally***compound-statement*
34
34
35
-
The `try-finally` statement is a Microsoft extension to the C and C++ languages that enables target applications to guarantee execution of cleanup code when execution of a block of code is interrupted. Cleanup consists of such tasks as deallocating memory, closing files, and releasing file handles. The `try-finally` statement is especially useful for routines that have several places where a check is made for an error that could cause premature return from the routine.
35
+
The **try-finally** statement is a Microsoft extension to the C and C++ languages that enables target applications to guarantee execution of cleanup code when execution of a block of code is interrupted. Cleanup consists of such tasks as deallocating memory, closing files, and releasing file handles. The **try-finally** statement is especially useful for routines that have several places where a check is made for an error that could cause premature return from the routine.
36
36
37
37
For related information and a code sample, see [try-except Statement](../cpp/try-except-statement.md). For more information on structured exception handling in general, see [Structured Exception Handling](../cpp/structured-exception-handling-c-cpp.md). For more information on handling exceptions in managed applications, see [Exception Handling under /clr](../windows/exception-handling-cpp-component-extensions.md).
38
38
@@ -60,20 +60,20 @@ Order of Termination-Handler Execution
60
60
> The behavior of try-finally is different from some other languages that support the use of **finally**, such as C#. A single **__try** may have either, but not both, of **__finally** and **__except**. If both are to be used together, an outer try-except statement must enclose the inner try-finally statement. The rules specifying when each block executes are also different.
61
61
62
62
## The __leave Keyword
63
-
The **__leave** keyword is valid only within the guarded section of a `try-finally` statement, and its effect is to jump to the end of the guarded section. Execution continues at the first statement in the termination handler.
63
+
The **__leave** keyword is valid only within the guarded section of a **try-finally** statement, and its effect is to jump to the end of the guarded section. Execution continues at the first statement in the termination handler.
64
64
65
65
A **goto** statement can also jump out of the guarded section, but it degrades performance because it invokes stack unwinding. The **__leave** statement is more efficient because it does not cause stack unwinding.
66
66
67
67
## Abnormal Termination
68
-
Exiting a `try-finally` statement using the [longjmp](../c-runtime-library/reference/longjmp.md) run-time function is considered abnormal termination. It is illegal to jump into a **__try** statement, but legal to jump out of one. All **__finally** statements that are active between the point of departure (normal termination of the **__try** block) and the destination (the **__except** block that handles the exception) must be run. This is called a local unwind.
68
+
Exiting a **try-finally** statement using the [longjmp](../c-runtime-library/reference/longjmp.md) run-time function is considered abnormal termination. It is illegal to jump into a **__try** statement, but legal to jump out of one. All **__finally** statements that are active between the point of departure (normal termination of the **__try** block) and the destination (the **__except** block that handles the exception) must be run. This is called a local unwind.
69
69
70
70
If a **try** block is prematurely terminated for any reason, including a jump out of the block, the system executes the associated **finally** block as a part of the process of unwinding the stack. In such cases, the [AbnormalTermination](http://msdn.microsoft.com/library/windows/desktop/ms679265) function returns **true** if called from within the **finally** block; otherwise, it returns **false**.
71
71
72
-
The termination handler is not called if a process is killed in the middle of executing a `try-finally` statement.
72
+
The termination handler is not called if a process is killed in the middle of executing a **try-finally** statement.
73
73
74
74
**END Microsoft Specific**
75
75
76
-
## See Also
76
+
## See also
77
77
[Writing a Termination Handler](../cpp/writing-a-termination-handler.md)
Copy file name to clipboardExpand all lines: docs/cpp/type-conversions-and-type-safety-modern-cpp.md
+1-9Lines changed: 1 addition & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -66,15 +66,13 @@ num2 = -1;
66
66
num = num2;
67
67
cout << "unsigned val = " << num << " signed val = " << num2 << endl;
68
68
// Prints: unsigned val = 65535 signed val = -1
69
-
70
69
```
71
70
72
71
Notice that values are reinterpreted in both directions. If your program produces odd results in which the sign of the value seems inverted from what you expect, look for implicit conversions between signed and unsigned integral types. In the following example, the result of the expression ( 0 - 1) is implicitly converted from **int** to **unsigned int** when it's stored in `num`. This causes the bit pattern to be reinterpreted.
73
72
74
73
```cpp
75
74
unsignedint u3 = 0 - 1;
76
75
cout << u3 << endl; // prints 4294967295
77
-
78
76
```
79
77
80
78
The compiler does not warn about implicit conversions between signed and unsigned integral types. Therefore, we recommend that you avoid signed-to-unsigned conversions altogether. If you can't avoid them, then add to your code a runtime check to detect whether the value being converted is greater than or equal to zero and less than or equal to the maximum value of the signed type. Values in this range will transfer from signed to unsigned or from unsigned to signed without being reinterpreted.
The C-style cast operator is identical to the call operator () and is therefore inconspicuous in code and easy to overlook. Both are bad because they're difficult to recognize at a glance or search for, and they're disparate enough to invoke any combination of **static**, **const**, and **reinterpret_cast**. Figuring out what an old-style cast actually does can be difficult and error-prone. For all these reasons, when a cast is required, we recommend that you use one of the following C++ cast operators, which in some cases are significantly more type-safe, and which express much more explicitly the programming intent:
Copy file name to clipboardExpand all lines: docs/cpp/type-info-class.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -13,9 +13,9 @@ ms.author: "mblome"
13
13
ms.workload: ["cplusplus"]
14
14
---
15
15
# type_info Class
16
-
The `type_info` class describes type information generated within the program by the compiler. Objects of this class effectively store a pointer to a name for the type. The `type_info` class also stores an encoded value suitable for comparing two types for equality or collating order. The encoding rules and collating sequence for types are unspecified and may differ between programs.
16
+
The **type_info** class describes type information generated within the program by the compiler. Objects of this class effectively store a pointer to a name for the type. The **type_info** class also stores an encoded value suitable for comparing two types for equality or collating order. The encoding rules and collating sequence for types are unspecified and may differ between programs.
17
17
18
-
The `<typeinfo>` header file must be included in order to use the `type_info` class. The interface for the `type_info` class is:
18
+
The `<typeinfo>` header file must be included in order to use the **type_info** class. The interface for the **type_info** class is:
19
19
20
20
```cpp
21
21
classtype_info {
@@ -30,11 +30,11 @@ public:
30
30
};
31
31
```
32
32
33
-
You cannot instantiate objects of the `type_info` class directly, because the class has only a private copy constructor. The only way to construct a (temporary) `type_info` object is to use the [typeid](../cpp/typeid-operator.md) operator. Since the assignment operator is also private, you cannot copy or assign objects of class `type_info`.
33
+
You cannot instantiate objects of the **type_info** class directly, because the class has only a private copy constructor. The only way to construct a (temporary) **type_info** object is to use the [typeid](../cpp/typeid-operator.md) operator. Since the assignment operator is also private, you cannot copy or assign objects of class **type_info**.
34
34
35
-
`type_info::hash_code` defines a hash function suitable for mapping values of type `typeinfo` to a distribution of index values.
35
+
`type_info::hash_code` defines a hash function suitable for mapping values of type **typeinfo** to a distribution of index values.
36
36
37
-
The operators `==` and `!=` can be used to compare for equality and inequality with other `type_info` objects, respectively.
37
+
The operators `==` and `!=` can be used to compare for equality and inequality with other **type_info** objects, respectively.
38
38
39
39
There is no link between the collating order of types and inheritance relationships. Use the `type_info::before` member function to determine the collating sequence of types. There is no guarantee that `type_info::before` will yield the same result in different programs or even different runs of the same program. In this manner, `type_info::before` is similar to the address-of `(&)` operator.
40
40
@@ -44,5 +44,5 @@ public:
44
44
45
45
Type information is generated for polymorphic classes only if the [/GR (Enable Run-Time Type Information)](../build/reference/gr-enable-run-time-type-information.md) compiler option is specified.
46
46
47
-
## See Also
48
-
[Run-Time Type Information](../cpp/run-time-type-information.md)
47
+
## See also
48
+
[Run-Time Type Information](../cpp/run-time-type-information.md)
0 commit comments