mirror of
https://github.com/mfontanini/libtins
synced 2026-01-23 02:35:57 +01:00
DNSRecords are now movable.!
This commit is contained in:
@@ -33,6 +33,7 @@
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <stdint.h>
|
||||
#include "cxxstd.h"
|
||||
|
||||
namespace Tins {
|
||||
class DNSRRImpl;
|
||||
@@ -97,6 +98,18 @@ public:
|
||||
*/
|
||||
DNSResourceRecord& operator=(const DNSResourceRecord &rhs);
|
||||
|
||||
#if TINS_IS_CXX11
|
||||
/**
|
||||
* Move constructor.
|
||||
*/
|
||||
DNSResourceRecord(DNSResourceRecord &&rhs);
|
||||
|
||||
/**
|
||||
* Move assignment operator.
|
||||
*/
|
||||
DNSResourceRecord& operator=(DNSResourceRecord &&rhs);
|
||||
#endif // TINS_IS_CXX11
|
||||
|
||||
/**
|
||||
* \brief Destructor.
|
||||
*
|
||||
|
||||
@@ -106,6 +106,22 @@ DNSResourceRecord& DNSResourceRecord::operator=(const DNSResourceRecord &rhs)
|
||||
return *this;
|
||||
}
|
||||
|
||||
#if TINS_IS_CXX11
|
||||
DNSResourceRecord::DNSResourceRecord(DNSResourceRecord &&rhs)
|
||||
: info_(rhs.info_), data(std::move(rhs.data)), impl(0) {
|
||||
std::swap(impl, rhs.impl);
|
||||
}
|
||||
|
||||
DNSResourceRecord& DNSResourceRecord::operator=(DNSResourceRecord &&rhs) {
|
||||
info_ = rhs.info_;
|
||||
data = std::move(rhs.data);
|
||||
delete impl;
|
||||
impl = 0;
|
||||
std::swap(impl, rhs.impl);
|
||||
return *this;
|
||||
}
|
||||
#endif
|
||||
|
||||
DNSResourceRecord::~DNSResourceRecord() {
|
||||
delete impl;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user