Skip to content

Commit 3628707

Browse files
authored
Merge pull request #3089 from MicrosoftDocs/master
8/31 AM Publishing
2 parents c8f1605 + 5a8c741 commit 3628707

File tree

8 files changed

+875
-6
lines changed

8 files changed

+875
-6
lines changed

docs/code-quality/c26465.md

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,19 @@ ms.date: 03/22/2018
44
ms.topic: reference
55
f1_keywords: ["C26465"]
66
helpviewer_keywords: ["C26465"]
7+
description: CppCoreCheck rule that enforces C++ Core Guidelines Type.3
78
---
89
# C26465 NO_CONST_CAST_UNNECESSARY
910

10-
Don't use `const_cast` to cast away `const`. `const_cast` is not required; constness or volatility is not being removed by this conversion. See [C++ Core Guidelines Type.3](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-constcast).
11+
Don't use `const_cast` to cast away `const`. `const_cast` is not required; constness or volatility is not being removed by this conversion.
12+
13+
## See also
14+
[C++ Core Guidelines Type.3](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-constcast)
15+
16+
## Example
17+
```cpp
18+
void function(int* const constPtrToInt)
19+
{
20+
auto p = const_cast<int*>(constPtrToInt); // C26465, const is not being removed
21+
}
22+
```

docs/code-quality/c26466.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,37 @@ ms.date: 03/22/2018
44
ms.topic: reference
55
f1_keywords: ["C26466"]
66
helpviewer_keywords: ["C26466"]
7+
description: CppCoreCheck rule that enforces C++ Core Guidelines Type.2
78
---
89
# C26466 NO_STATIC_DOWNCAST_POLYMORPHIC
910

10-
Don't use `static_cast` downcasts. A cast from a polymorphic type should use dynamic_cast. See [C++ Core Guidelines Type.2](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-downcast).
11+
Don't use `static_cast` downcasts. A cast from a polymorphic type should use dynamic_cast.
12+
13+
## See also
14+
[C++ Core Guidelines Type.2](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-downcast)
15+
16+
## Example
17+
```cpp
18+
struct Base {
19+
virtual ~Base();
20+
};
21+
22+
struct Derived : Base {};
23+
24+
void bad(Base* pb)
25+
{
26+
Derived* test = static_cast<Derived*>(pb); // C26466
27+
}
28+
29+
void good(Base* pb)
30+
{
31+
if (Derived* pd = dynamic_cast<Derived*>(pb))
32+
{
33+
// ... do something with Derived*
34+
}
35+
else
36+
{
37+
// ... do something with Base*
38+
}
39+
}
40+
```

docs/code-quality/c26471.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,24 @@ ms.date: 03/22/2018
44
ms.topic: reference
55
f1_keywords: ["C26471"]
66
helpviewer_keywords: ["C26471"]
7+
description: CppCoreCheck rule that enforces C++ Core Guidelines Type.1
78
---
89
# C26471 NO_REINTERPRET_CAST_FROM_VOID_PTR
910

10-
Don't use `reinterpret_cast`. A cast from void* can use `static_cast`. See [C++ Core Guidelines Type.1](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-reinterpretcast).
11+
Don't use `reinterpret_cast`. A cast from void* can use `static_cast`.
12+
13+
## See also
14+
[C++ Core Guidelines Type.1](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Pro-type-reinterpretcast)
15+
16+
## Example
17+
```cpp
18+
void function(void* pValue)
19+
{
20+
{
21+
int* pointerToInt = reinterpret_cast<int*>(pValue); // C26471, use static_cast instead
22+
}
23+
{
24+
int* pointerToInt = static_cast<int*>(pValue); // Good
25+
}
26+
}
27+
```

docs/error-messages/compiler-warnings/compiler-warning-level-3-c4686.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
---
22
title: "Compiler Warning (level 3) C4686"
3-
ms.date: "08/27/2018"
3+
description: "Microsoft C++ compiler warning C4686."
4+
ms.date: 08/29/2020
45
f1_keywords: ["C4686"]
56
helpviewer_keywords: ["C4686"]
67
ms.assetid: 767c83c2-9e4b-4f9e-88c8-02128ba563f4
@@ -11,9 +12,9 @@ ms.assetid: 767c83c2-9e4b-4f9e-88c8-02128ba563f4
1112
1213
## Remarks
1314

14-
A class template specialization was not is defined before it was used in a return type. Anything that instantiates the class will resolve C4686; declaring an instance or accessing a member (C\<int>::anything) are also options.
15+
A class template specialization wasn't defined before it was used in a return type. Anything that instantiates the class resolves C4686; declaring an instance or accessing a member (for example, `C<int>::some_member`) are also options.
1516

16-
This warning is off by default. See [Compiler Warnings That Are Off by Default](../../preprocessor/compiler-warnings-that-are-off-by-default.md) for more information.
17+
This warning is off by default. For more information, see [Compiler warnings that are off by default](../../preprocessor/compiler-warnings-that-are-off-by-default.md).
1718

1819
## Example
1920

docs/standard-library/bit-enum.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
---
2+
title: "endian enum"
3+
description: "enum used to specify the endianness of scalar types"
4+
ms.date: "08/27/2020"
5+
f1_keywords: ["bit/std::endian"]
6+
helpviewer_keywords: ["std::endian"]
7+
---
8+
# endian enum
9+
10+
Indicates the endianness of all scalar types.
11+
12+
## Syntax
13+
14+
```cpp
15+
enum class endian {
16+
little = 0,
17+
big = 1,
18+
native = little
19+
};
20+
```
21+
22+
### Members
23+
24+
|Element|Description|
25+
|-|-|
26+
| `little` | Indicates that scalar types are little-endian. That is, the least significant byte is stored in the smallest address. For example, `0x1234` is stored `0x34` `0x12`. |
27+
| `big` | Indicates that scalar types are big-endian, that is, the most significant byte is stored in the smallest address. For example, `0x1234` is stored `0x12` `0x34`. |
28+
29+
## Remarks
30+
31+
All native scalar types are little-endian for the platforms that Microsoft Visual C++ targets (x86, x64, ARM, ARM64).
32+
33+
## Requirements
34+
35+
**Header:** \<bit>
36+
37+
**Namespace:** std
38+
39+
`/std:c++latest` is required
40+
41+
## See also
42+
43+
[\<bit>](../standard-library/bit.md)

0 commit comments

Comments
 (0)