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: cppguide.html
+22Lines changed: 22 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -2619,6 +2619,28 @@ <h3 id="Pass_By_Value">Pass by Value</h3>
2619
2619
<li><ahref="https://stackoverflow.com/questions/10231349/are-the-days-of-passing-const-stdstring-as-a-parameter-over">Stack Overflow: Are the days of passing const std::string& as a parameter over?</a></li>
2620
2620
</ul>
2621
2621
</p>
2622
+
2623
+
<h4id="Pass_By_Value_Primitives">Pass by Value: Primitives</h4>
2624
+
2625
+
<p>Prefer to pass primitives (e.g., <code>int</code> or <code>double</code>)
2626
+
by value, not by const reference.</p>
2627
+
2628
+
<p>The same goes for copyable types that are tantamount to primitives,
2629
+
such as type-safe integers (e.g., <code>drake::TypeSafeIndex</code> or
2630
+
<code>drake::Identifier</code>) and thin wrappers
2631
+
(e.g., <code>std::optional<double></code>, because it's akin to a
0 commit comments