From cea965f610a1b7a9bade7ec597a2b1de937e683e Mon Sep 17 00:00:00 2001 From: hsutter Date: Mon, 16 Apr 2018 11:06:48 -0700 Subject: [PATCH] Reworded "consume" to "will-move-from" parameters To improve clarity since the wording was causing confusion --- CppCoreGuidelines.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/CppCoreGuidelines.md b/CppCoreGuidelines.md index 22c45e4..f0075bb 100644 --- a/CppCoreGuidelines.md +++ b/CppCoreGuidelines.md @@ -2285,7 +2285,7 @@ Parameter passing expression rules: * [F.15: Prefer simple and conventional ways of passing information](#Rf-conventional) * [F.16: For "in" parameters, pass cheaply-copied types by value and others by reference to `const`](#Rf-in) * [F.17: For "in-out" parameters, pass by reference to non-`const`](#Rf-inout) -* [F.18: For "consume" parameters, pass by `X&&` and `std::move` the parameter](#Rf-consume) +* [F.18: For "will-move-from" parameters, pass by `X&&` and `std::move` the parameter](#Rf-consume) * [F.19: For "forward" parameters, pass by `TP&&` and only `std::forward` the parameter](#Rf-forward) * [F.20: For "out" output values, prefer return values to output parameters](#Rf-out) * [F.21: To return multiple "out" values, prefer returning a tuple or struct](#Rf-out-multi) @@ -2835,7 +2835,7 @@ For advanced uses (only), where you really need to optimize for rvalues passed t * If the function is going to unconditionally move from the argument, take it by `&&`. See [F.18](#Rf-consume). * If the function is going to keep a copy of the argument, in addition to passing by `const&` (for lvalues), - add an overload that passes the parameter by `&&` (for rvalues) and in the body `std::move`s it to its destination. Essentially this overloads a "consume"; see [F.18](#Rf-consume). + add an overload that passes the parameter by `&&` (for rvalues) and in the body `std::move`s it to its destination. Essentially this overloads a "will-move-from"; see [F.18](#Rf-consume). * In special cases, such as multiple "input + copy" parameters, consider using perfect forwarding. See [F.19](#Rf-forward). ##### Example @@ -2845,7 +2845,7 @@ For advanced uses (only), where you really need to optimize for rvalues passed t // suffix is input-only but not as cheap as an int, pass by const& string& concatenate(string&, const string& suffix); - void sink(unique_ptr); // input only, and consumes the widget + void sink(unique_ptr); // input only, and moves ownership of the widget Avoid "esoteric techniques" such as: @@ -2918,7 +2918,7 @@ A bad logic error can happen if the writer of `g()` incorrectly assumes the size * (Moderate) ((Foundation)) Warn about functions regarding reference to non-`const` parameters that do *not* write to them. * (Simple) ((Foundation)) Warn when a non-`const` parameter being passed by reference is `move`d. -### F.18: For "consume" parameters, pass by `X&&` and `std::move` the parameter +### F.18: For "will-move-from" parameters, pass by `X&&` and `std::move` the parameter ##### Reason @@ -9349,7 +9349,7 @@ Using `unique_ptr` in this way both documents and enforces the function call's o ##### Example - void sink(unique_ptr); // consumes the widget + void sink(unique_ptr); // takes ownership of the widget void uses(widget*); // just uses the widget