Skip to content

Commit c8f2ee7

Browse files
committed
Learn Editor: Update attributes.md
1 parent b2be6f2 commit c8f2ee7

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

docs/cpp/attributes.md

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ f1_keywords: ["deprecated", "no_return", "carries_dependency", "fallthrough", "n
55
helpviewer_keywords: ["deprecated", "no_return", "carries_dependency", "fallthrough", "nodiscard", "maybe_unused", "likely", "unlikely", "gsl::suppress", "msvc::intrinsic", "msvc::no_tls_guard"]
66
ms.date: 4/13/2023
77
---
8+
89
# Attributes in C++
910

1011
The C++ Standard defines a common set of attributes. It also allows compiler vendors to define their own attributes within a vendor-specific namespace. However, compilers are only required to recognize the attributes defined in the standard.
@@ -134,14 +135,14 @@ The first call to `foo`, and both calls to `bar`, are treated as if they were de
134135

135136
### `[[msvc::intrinsic]]`
136137

137-
The Microsoft-specific `[[msvc::intrinsic]]` attribute tells the compiler to inline a metafunction that acts as a named cast from the parameter type to the return type. When the attribute is present on a function definition, the compiler replaces all calls to that function with a simple cast. The `[[msvc::intrinsic]]` attribute is available in Visual Studio 2022 version 17.5 preview 2 and later versions. This attribute applies only to the specific function that follows it.
138-
139138
The `[[msvc::intrinsic]]` attribute has three constraints on the function it's applied to:
140139

141-
- The function can't be recursive; its body must only have a return statement with a cast.
140+
- The function can't be recursive; its body must only have a return statement with a `static_cast` from the parameter type to the return type.
142141
- The function can only accept a single parameter.
143142
- The **`/permissive-`** compiler option is required. (The **`/std:c++20`** and later options imply **`/permissive-`** by default.)
144143

144+
The Microsoft-specific `[[msvc::intrinsic]]` attribute tells the compiler to inline a metafunction that acts as a named cast from the parameter type to the return type. When the attribute is present on a function definition, the compiler replaces all calls to that function with a simple cast. The `[[msvc::intrinsic]]` attribute is available in Visual Studio 2022 version 17.5 preview 2 and later versions. This attribute applies only to the specific function that follows it.
145+
145146
#### Example
146147

147148
In this sample code, the `[[msvc::intrinsic]]` attribute applied to the `my_move` function makes the compiler replace calls to the function with the inlined static cast in its body:

0 commit comments

Comments
 (0)