]> git.apps.os.sepia.ceph.com Git - ceph-ci.git/commitdiff
common/bl: introduce rvalue taking claim_append().
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 22 Jun 2020 21:08:49 +0000 (21:08 +0000)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Mon, 22 Jun 2020 22:08:20 +0000 (22:08 +0000)
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 <rzarzyns@redhat.com>
src/include/buffer.h

index 91caab2accb29934a7c4282e2a7141ce0d945773..37afb0e638cc7f02efac424e2ea229601dd9123a 100644 (file)
@@ -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);