Commit a3537a0f authored by Tudor Bosman's avatar Tudor Bosman Committed by Noam Lerner

Add cloning constructor to folly::IOBuf

Summary:
``` lang=cpp
folly::IOBuf buf(folly::IOBuf::CLONE, other);
```

is more convenient (and expression-friendly) than

``` lang=cpp
folly::IOBuf buf;
other.cloneInto(buf);
```

Test Plan: used it

Reviewed By: davejwatson@fb.com

Subscribers: net-systems@, folly-diffs@, yfeldblum, chalfant

FB internal diff: D2124605

Signature: t1:2124605:1433372767:c167a36ffdc6d20c740aa57895532e9445766fce
parent 26395e9b
......@@ -232,6 +232,7 @@ class IOBuf {
enum WrapBufferOp { WRAP_BUFFER };
enum TakeOwnershipOp { TAKE_OWNERSHIP };
enum CopyBufferOp { COPY_BUFFER };
enum CloneOp { CLONE };
typedef ByteRange value_type;
typedef Iterator iterator;
......@@ -397,6 +398,13 @@ class IOBuf {
IOBuf(CopyBufferOp op, ByteRange br,
uint64_t headroom=0, uint64_t minTailroom=0);
/**
* Clone an IOBuf. See the notes for cloneInto().
*/
IOBuf(CloneOp, const IOBuf& src) : IOBuf() {
src.cloneInto(*this);
}
/**
* Convenience function to create a new IOBuf object that copies data from a
* user-supplied string, optionally allocating a given amount of
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment