Implement move constructor for RTPFragmentationHeader.
This allows returning RTPFragmentationHeader from a method and assigning
the results to a variable.
BUG=webrtc:7760
Review-Url: https://codereview.webrtc.org/3002283002
Cr-Original-Commit-Position: refs/heads/master@{#19556}
Cr-Mirrored-From: https://chromium.googlesource.com/external/webrtc
Cr-Mirrored-Commit: 34960de3fb4257a2bba9847e8df3ef76dee59e77
diff --git a/modules/include/module_common_types.h b/modules/include/module_common_types.h
index 23ed8f4..1ee428d 100644
--- a/modules/include/module_common_types.h
+++ b/modules/include/module_common_types.h
@@ -91,6 +91,11 @@
fragmentationTimeDiff(NULL),
fragmentationPlType(NULL) {}
+ RTPFragmentationHeader(RTPFragmentationHeader&& other)
+ : RTPFragmentationHeader() {
+ std::swap(*this, other);
+ }
+
~RTPFragmentationHeader() {
delete[] fragmentationOffset;
delete[] fragmentationLength;
@@ -98,6 +103,17 @@
delete[] fragmentationPlType;
}
+ void operator=(RTPFragmentationHeader&& other) { std::swap(*this, other); }
+
+ friend void swap(RTPFragmentationHeader& a, RTPFragmentationHeader& b) {
+ using std::swap;
+ swap(a.fragmentationVectorSize, b.fragmentationVectorSize);
+ swap(a.fragmentationOffset, b.fragmentationOffset);
+ swap(a.fragmentationLength, b.fragmentationLength);
+ swap(a.fragmentationTimeDiff, b.fragmentationTimeDiff);
+ swap(a.fragmentationPlType, b.fragmentationPlType);
+ }
+
void CopyFrom(const RTPFragmentationHeader& src) {
if (this == &src) {
return;