Skip to content

Commit 45b0cf9

Browse files
committed
F.16 ("in" parameters): Remove Matrix example and notes on assignment
The `Matrix` example and the notes about assignment appear off-topic here, as rule F.16 is specifically about "in" parameters.
1 parent ddef6cd commit 45b0cf9

File tree

1 file changed

+2
-22
lines changed

1 file changed

+2
-22
lines changed

CppCoreGuidelines.md

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -2927,31 +2927,11 @@ For advanced uses (only), where you really need to optimize for rvalues passed t
29272927

29282928
void sink(unique_ptr<widget>); // input only, and moves ownership of the widget
29292929

2930-
Avoid "esoteric techniques" such as:
2931-
2932-
* Passing arguments as `T&&` "for efficiency".
2933-
Most rumors about performance advantages from passing by `&&` are false or brittle (but see [F.18](#Rf-consume) and [F.19](#Rf-forward)).
2934-
* Returning `const T&` from assignments and similar operations (see [F.47](#Rf-assignment-op).)
2935-
2936-
##### Example
2937-
2938-
Assuming that `Matrix` has move operations (possibly by keeping its elements in a `std::vector`):
2939-
2940-
Matrix operator+(const Matrix& a, const Matrix& b)
2941-
{
2942-
Matrix res;
2943-
// ... fill res with the sum ...
2944-
return res;
2945-
}
2946-
2947-
Matrix x = m1 + m2; // move constructor
2948-
2949-
y = m3 + m3; // move assignment
2930+
Avoid "esoteric techniques" such as passing arguments as `T&&` "for efficiency".
2931+
Most rumors about performance advantages from passing by `&&` are false or brittle (but see [F.18](#Rf-consume) and [F.19](#Rf-forward)).
29502932

29512933
##### Notes
29522934

2953-
The return value optimization doesn't handle the assignment case, but the move assignment does.
2954-
29552935
A reference can be assumed to refer to a valid object (language rule).
29562936
There is no (legitimate) "null reference."
29572937
If you need the notion of an optional value, use a pointer, `std::optional`, or a special value used to denote "no value."

0 commit comments

Comments
 (0)