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
This function call %function% can use `constexpr` if compile-time evaluation is desired. See [C++ Core Guidelines con.5](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#Rconst-constexpr).
10
+
This rule helps to enforce Con.5 from the [C++ Core Guidelines](https://github.com/isocpp/CppCoreGuidelines/blob/master/CppCoreGuidelines.md#con5-use-constexpr-for-values-that-can-be-computed-at-compile-time): use constexpr for values that can be computed at compile time.
11
+
12
+
## Remarks
13
+
14
+
The warning is triggered by assigning the result of a **`constexpr`** function to any non-**`constexpr`** variable whose value doesn't change after the initial assignment.
15
+
16
+
## Example
17
+
18
+
This sample code shows where C26498 may appear, and how to avoid it:
19
+
20
+
```cpp
21
+
constexprintgetMyValue()
22
+
{
23
+
return 1;
24
+
}
25
+
26
+
voidfoo()
27
+
{
28
+
constexpr int val0 = getMyValue(); // no C26498
29
+
const int val1 = getMyValue(); // C26498, C26814
30
+
int val2 = getMyValue(); // C26498, value is never modified
31
+
int val3 = getMyValue(); // no C26498, val3 is assigned to below.
0 commit comments