From: Radoslaw Zarzynski Date: Mon, 22 Jun 2020 21:08:49 +0000 (+0000) Subject: common/bl: introduce rvalue taking claim_append(). X-Git-Tag: wip-pdonnell-testing-20200918.022351~885^2~1 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=5d8fff13fc29cc3f379aae8e4437d0294b65f82b;p=ceph-ci.git common/bl: introduce rvalue taking claim_append(). The motivation is to stop prohibiting callers from directly passing temporaries. It was not infrequent to see constructs like: ```cpp { // ... auto tmp = produce_bl(); other_bl.claim_append(tmp); } ``` They were necessary because `claim_append(bufferlist&)` requires lvalue reference to which an rvalue can't bind. This patch fixes the problem by introducing `&&`-taking variant of `claim_append()`. In the future it could actually supersede the original one. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/include/buffer.h b/src/include/buffer.h index 91caab2accb..37afb0e638c 100644 --- a/src/include/buffer.h +++ b/src/include/buffer.h @@ -1066,6 +1066,9 @@ struct error_code; void claim(list& bl); void claim_append(list& bl); + void claim_append(list&& bl) { + claim_append(bl); + } // only for bl is bufferlist::page_aligned_appender void claim_append_piecewise(list& bl);