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
A **`mutable`** specifier was used in a declaration, but the specifier is not allowed in this context.
14
+
A **`mutable`** specifier was used in a declaration, but the specifier is not allowed in this context. It can only be applied to non-static, non-const, and non-reference data members. For more information, see [Mutable Data Members](../../cpp/mutable-data-members-cpp.md).
15
15
16
-
The**`mutable`** specifier can be applied only to names of class data members, and cannot be applied to names declared **`const`**or **`static`**, and cannot be applied to reference members.
16
+
A**`consteval`** specifier was used on a [destructor](../../cpp/destructors-cpp.md), allocation function, or deallocation function.
17
17
18
-
## Example
18
+
## Example: `mutable`
19
19
20
-
The following example shows how C2178 may occur, and how to fix it.
20
+
The following example shows how C2178 may occur with the **`mutable`** specifier, and how to resolve it:
21
21
22
22
```cpp
23
-
//C2178.cpp
24
-
// compile with: cl /c /W4 C2178.cpp
23
+
//C2178_mutable.cpp
24
+
// compile with: /c
25
25
26
-
classS {
27
-
mutable const int i; // C2178
28
-
// To fix, declare either const or mutable, not both.
26
+
structS
27
+
{
28
+
mutable const int i; // C2178, remove mutable or const to resolve
29
29
};
30
30
31
-
mutable int x = 4; // C2178
32
-
// To fix, remove mutable keyword
31
+
mutableint x = 4; // C2178, remove mutable to resolve
32
+
```
33
+
34
+
## Example: `consteval`
35
+
36
+
The following example shows how C2178 may occur with the **`consteval`** specifier. To resolve this error, remove all **`consteval`** specifiers:
0 commit comments