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
Copy file name to clipboardExpand all lines: docs/code-quality/c6031.md
+14
Original file line number
Diff line number
Diff line change
@@ -83,6 +83,20 @@ void test_f()
83
83
}
84
84
```
85
85
86
+
In cases where it is necessary to ignore the return value of a function, assign the returned value to `std::ignore`. Assigning to `std::ignore` clearly indicates developer intent and helps in future code maintenance.
87
+
88
+
```cpp
89
+
#include<tuple>
90
+
#include<ctime>
91
+
#include<stdio.h>
92
+
voidf()
93
+
{
94
+
std::srand(static_cast(std::time(nullptr))); // set initial seed value to system clock
95
+
std::ignore = std::rand(); // Discard the first result as the few random results are always small.
0 commit comments