Skip to content

Commit fa3c540

Browse files
author
mtx48109
committed
format-cpp-pr8
1 parent 8fc0df5 commit fa3c540

30 files changed

Lines changed: 179 additions & 179 deletions

docs/cpp/static-assert.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ ms.author: "mblome"
1313
ms.workload: ["cplusplus"]
1414
---
1515
# static_assert
16-
Tests a software assertion at compile time. If the specified constant expression is `false`, the compiler displays the specified message, if one is provided, and the compilation fails with error C2338; otherwise, the declaration has no effect.
16+
Tests a software assertion at compile time. If the specified constant expression is FALSE, the compiler displays the specified message, if one is provided, and the compilation fails with error C2338; otherwise, the declaration has no effect.
1717

1818
## Syntax
1919

@@ -28,20 +28,20 @@ static_assert( constant-expression );
2828

2929
|Parameter|Description|
3030
|---------------|-----------------|
31-
|`constant-expression`|An integral constant expression that can be converted to a Boolean.<br /><br /> If the evaluated expression is zero (false), the `string-literal` parameter is displayed and the compilation fails with an error. If the expression is nonzero (true), the `static_assert` declaration has no effect.|
31+
|`constant-expression`|An integral constant expression that can be converted to a Boolean.<br /><br /> If the evaluated expression is zero (false), the `string-literal` parameter is displayed and the compilation fails with an error. If the expression is nonzero (true), the **static_assert** declaration has no effect.|
3232
|`string-literal`|An message that is displayed if the `constant-expression` parameter is zero. The message is a string of characters in the [base character set](../c-language/ascii-character-set.md) of the compiler; that is, not [multibyte or wide characters](../c-language/multibyte-and-wide-characters.md).|
3333

3434
## Remarks
35-
The `constant-expression` parameter of a `static_assert` declaration represents a *software assertion*. A software assertion specifies a condition that you expect to be true at a particular point in your program. If the condition is true, the `static_assert` declaration has no effect. If the condition is false, the assertion fails, the compiler displays the message in `string-literal` parameter, and the compilation fails with an error. In Visual Studio 2017 and later, the string-literal parameter is optional.
35+
The `constant-expression` parameter of a **static_assert** declaration represents a *software assertion*. A software assertion specifies a condition that you expect to be true at a particular point in your program. If the condition is true, the **static_assert** declaration has no effect. If the condition is false, the assertion fails, the compiler displays the message in `string-literal` parameter, and the compilation fails with an error. In Visual Studio 2017 and later, the string-literal parameter is optional.
3636

37-
The `static_assert` declaration tests a software assertion at compile time. In contrast, the [assert Macro, _assert, _wassert](../c-runtime-library/reference/assert-macro-assert-wassert.md) macro tests a software assertion at run time and incurs a run time cost in space or time. The `static_assert` declaration is especially useful for debugging templates because template arguments can be included in the `constant-expression` parameter.
37+
The **static_assert** declaration tests a software assertion at compile time. In contrast, the [assert Macro, _assert, _wassert](../c-runtime-library/reference/assert-macro-assert-wassert.md) macro tests a software assertion at run time and incurs a run time cost in space or time. The **static_assert** declaration is especially useful for debugging templates because template arguments can be included in the `constant-expression` parameter.
3838

39-
The compiler examines the `static_assert` declaration for syntax errors when the declaration is encountered. The compiler evaluates the `constant-expression` parameter immediately if it does not depend on a template parameter. Otherwise, the compiler evaluates the `constant-expression` parameter when the template is instantiated. Consequently, the compiler might issue a diagnostic message once when the declaration is encountered, and again when the template is instantiated.
39+
The compiler examines the **static_assert** declaration for syntax errors when the declaration is encountered. The compiler evaluates the `constant-expression` parameter immediately if it does not depend on a template parameter. Otherwise, the compiler evaluates the `constant-expression` parameter when the template is instantiated. Consequently, the compiler might issue a diagnostic message once when the declaration is encountered, and again when the template is instantiated.
4040

41-
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.)
41+
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.)
4242

4343
## Description
44-
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.
44+
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.
4545

4646
## Example
4747

@@ -50,7 +50,7 @@ static_assert(sizeof(void *) == 4, "64-bit code generation is not supported.");
5050
```
5151

5252
## Description
53-
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()`.
53+
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()`.
5454

5555
## Example
5656

@@ -78,7 +78,7 @@ int main()
7878
```
7979

8080
## Description
81-
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.
81+
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.
8282

8383
## Example
8484

docs/cpp/static-cast-operator.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ static_cast <type-id> ( expression )
2424
## Remarks
2525
In standard C++, no run-time type check is made to help ensure the safety of the conversion. In C++/CX, a compile time and runtime check are performed. For more information, see [Casting](casting.md).
2626

27-
The `static_cast` operator can be used for operations such as converting a pointer to a base class to a pointer to a derived class. Such conversions are not always safe.
27+
The **static_cast** operator can be used for operations such as converting a pointer to a base class to a pointer to a derived class. Such conversions are not always safe.
2828

29-
In general you use `static_cast` when you want to convert numeric data types such as enums to ints or ints to floats, and you are certain of the data types involved in the conversion. `static_cast` conversions are not as safe as `dynamic_cast` conversions, because `static_cast` does no run-time type check, while `dynamic_cast` does. A `dynamic_cast` to an ambiguous pointer will fail, while a `static_cast` returns as if nothing were wrong; this can be dangerous. Although `dynamic_cast` conversions are safer, `dynamic_cast` only works on pointers or references, and the run-time type check is an overhead. For more information, see [dynamic_cast Operator](../cpp/dynamic-cast-operator.md).
29+
In general you use **static_cast** when you want to convert numeric data types such as enums to ints or ints to floats, and you are certain of the data types involved in the conversion. **static_cast** conversions are not as safe as **dynamic_cast** conversions, because **static_cast** does no run-time type check, while **dynamic_cast** does. A **dynamic_cast** to an ambiguous pointer will fail, while a **static_cast** returns as if nothing were wrong; this can be dangerous. Although **dynamic_cast** conversions are safer, **dynamic_cast** only works on pointers or references, and the run-time type check is an overhead. For more information, see [dynamic_cast Operator](../cpp/dynamic-cast-operator.md).
3030

3131
In the example that follows, the line `D* pd2 = static_cast<D*>(pb);` is not safe because `D` can have fields and methods that are not in `B`. However, the line `B* pb2 = static_cast<B*>(pd);` is a safe conversion because `D` always contains all of `B`.
3232

@@ -46,9 +46,9 @@ void f(B* pb, D* pd) {
4646
}
4747
```
4848
49-
In contrast to [dynamic_cast](../cpp/dynamic-cast-operator.md), no run-time check is made on the `static_cast` conversion of `pb`. The object pointed to by `pb` may not be an object of type `D`, in which case the use of `*pd2` could be disastrous. For instance, calling a function that is a member of the `D` class, but not the `B` class, could result in an access violation.
49+
In contrast to [dynamic_cast](../cpp/dynamic-cast-operator.md), no run-time check is made on the **static_cast** conversion of `pb`. The object pointed to by `pb` may not be an object of type `D`, in which case the use of `*pd2` could be disastrous. For instance, calling a function that is a member of the `D` class, but not the `B` class, could result in an access violation.
5050
51-
The `dynamic_cast` and `static_cast` operators move a pointer throughout a class hierarchy. However, `static_cast` relies exclusively on the information provided in the cast statement and can therefore be unsafe. For example:
51+
The **dynamic_cast** and **static_cast** operators move a pointer throughout a class hierarchy. However, **static_cast** relies exclusively on the information provided in the cast statement and can therefore be unsafe. For example:
5252
5353
```cpp
5454
// static_cast_Operator_2.cpp
@@ -67,13 +67,13 @@ void f(B* pb) {
6767

6868
If `pb` really points to an object of type `D`, then `pd1` and `pd2` will get the same value. They will also get the same value if `pb == 0`.
6969

70-
If `pb` points to an object of type `B` and not to the complete `D` class, then `dynamic_cast` will know enough to return zero. However, `static_cast` relies on the programmer's assertion that `pb` points to an object of type `D` and simply returns a pointer to that supposed `D` object.
70+
If `pb` points to an object of type `B` and not to the complete `D` class, then **dynamic_cast** will know enough to return zero. However, **static_cast** relies on the programmer's assertion that `pb` points to an object of type `D` and simply returns a pointer to that supposed `D` object.
7171

72-
Consequently, `static_cast` can do the inverse of implicit conversions, in which case the results are undefined. It is left to the programmer to verify that the results of a `static_cast` conversion are safe.
72+
Consequently, **static_cast** can do the inverse of implicit conversions, in which case the results are undefined. It is left to the programmer to verify that the results of a **static_cast** conversion are safe.
7373

74-
This behavior also applies to types other than class types. For instance, `static_cast` can be used to convert from an int to a `char`. However, the resulting `char` may not have enough bits to hold the entire `int` value. Again, it is left to the programmer to verify that the results of a `static_cast` conversion are safe.
74+
This behavior also applies to types other than class types. For instance, **static_cast** can be used to convert from an int to a **char**. However, the resulting **char** may not have enough bits to hold the entire **int** value. Again, it is left to the programmer to verify that the results of a **static_cast** conversion are safe.
7575

76-
The `static_cast` operator can also be used to perform any implicit conversion, including standard conversions and user-defined conversions. For example:
76+
The **static_cast** operator can also be used to perform any implicit conversion, including standard conversions and user-defined conversions. For example:
7777

7878
```cpp
7979
// static_cast_Operator_3.cpp
@@ -92,15 +92,15 @@ void f() {
9292
}
9393
```
9494

95-
The `static_cast` operator can explicitly convert an integral value to an enumeration type. If the value of the integral type does not fall within the range of enumeration values, the resulting enumeration value is undefined.
95+
The **static_cast** operator can explicitly convert an integral value to an enumeration type. If the value of the integral type does not fall within the range of enumeration values, the resulting enumeration value is undefined.
9696

97-
The `static_cast` operator converts a null pointer value to the null pointer value of the destination type.
97+
The **static_cast** operator converts a null pointer value to the null pointer value of the destination type.
9898

99-
Any expression can be explicitly converted to type void by the `static_cast` operator. The destination void type can optionally include the `const`, `volatile`, or `__unaligned` attribute.
99+
Any expression can be explicitly converted to type void by the **static_cast** operator. The destination void type can optionally include the **const**, **volatile**, or **__unaligned** attribute.
100100

101-
The `static_cast` operator cannot cast away the `const`, `volatile`, or `__unaligned` attributes. See [const_cast Operator](../cpp/const-cast-operator.md) for information on removing these attributes.
101+
The **static_cast** operator cannot cast away the **const**, **volatile**, or **__unaligned** attributes. See [const_cast Operator](../cpp/const-cast-operator.md) for information on removing these attributes.
102102

103-
Due to the danger of performing unchecked casts on top of a relocating garbage collector, the use of `static_cast` should only be in performance-critical code when you are certain it will work correctly. If you must use `static_cast` in release mode, substitute it with [safe_cast](../windows/safe-cast-cpp-component-extensions.md) in your debug builds to ensure success.
103+
Due to the danger of performing unchecked casts on top of a relocating garbage collector, the use of **static_cast** should only be in performance-critical code when you are certain it will work correctly. If you must use **static_cast** in release mode, substitute it with [safe_cast](../windows/safe-cast-cpp-component-extensions.md) in your debug builds to ensure success.
104104

105105
## See Also
106106
[Casting Operators](../cpp/casting-operators.md)

docs/cpp/static-members-cpp.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ long nBytes = Console.bytecount;
6565

6666
Static data members are subject to class-member access rules, so private access to static data members is allowed only for class-member functions and friends. These rules are described in [Member-Access Control](../cpp/member-access-control-cpp.md). The exception is that static data members must be defined in file scope regardless of their access restrictions. If the data member is to be explicitly initialized, an initializer must be provided with the definition.
6767

68-
The type of a static member is not qualified by its class name. Therefore, the type of `BufferedOutput::bytecount` is `long`.
68+
The type of a static member is not qualified by its class name. Therefore, the type of `BufferedOutput::bytecount` is **long**.
6969

7070
## See Also
7171
[Classes and Structs](../cpp/classes-and-structs-cpp.md)

docs/cpp/stdcall.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ ms.workload: ["cplusplus"]
1515
# __stdcall
1616
**Microsoft Specific**
1717

18-
The `__stdcall` calling convention is used to call Win32 API functions. The callee cleans the stack, so the compiler makes **vararg** functions `__cdecl`. Functions that use this calling convention require a function prototype.
18+
The **__stdcall** calling convention is used to call Win32 API functions. The callee cleans the stack, so the compiler makes **vararg** functions **__cdecl**. Functions that use this calling convention require a function prototype.
1919

2020
## Syntax
2121

@@ -35,11 +35,11 @@ return-type __stdcall function-name[(argument-list)]
3535
|Name-decoration convention|An underscore (_) is prefixed to the name. The name is followed by the at sign (@) followed by the number of bytes (in decimal) in the argument list. Therefore, the function declared as `int func( int a, double b )` is decorated as follows: `_func@12`|
3636
|Case-translation convention|None|
3737

38-
The [/Gz](../build/reference/gd-gr-gv-gz-calling-convention.md) compiler option specifies `__stdcall` for all functions not explicitly declared with a different calling convention.
38+
The [/Gz](../build/reference/gd-gr-gv-gz-calling-convention.md) compiler option specifies **__stdcall** for all functions not explicitly declared with a different calling convention.
3939

40-
Functions declared using the `__stdcall` modifier return values the same way as functions declared using [__cdecl](../cpp/cdecl.md).
40+
Functions declared using the **__stdcall** modifier return values the same way as functions declared using [__cdecl](../cpp/cdecl.md).
4141

42-
On ARM and x64 processors, `__stdcall` is accepted and ignored by the compiler; on ARM and x64 architectures, by convention, arguments are passed in registers when possible, and subsequent arguments are passed on the stack.
42+
On ARM and x64 processors, **__stdcall** is accepted and ignored by the compiler; on ARM and x64 architectures, by convention, arguments are passed in registers when possible, and subsequent arguments are passed on the stack.
4343

4444
For non-static class functions, if the function is defined out-of-line, the calling convention modifier does not have to be specified on the out-of-line definition. That is, for class non-static member methods, the calling convention specified during declaration is assumed at the point of definition. Given this class definition,
4545

0 commit comments

Comments
 (0)