net/AllocatedSocketAddress: add more "noexcept"
This commit is contained in:
@@ -45,7 +45,7 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
AllocatedSocketAddress &
|
AllocatedSocketAddress &
|
||||||
AllocatedSocketAddress::operator=(SocketAddress src)
|
AllocatedSocketAddress::operator=(SocketAddress src) noexcept
|
||||||
{
|
{
|
||||||
if (src.IsNull()) {
|
if (src.IsNull()) {
|
||||||
Clear();
|
Clear();
|
||||||
|
@@ -55,13 +55,13 @@ private:
|
|||||||
public:
|
public:
|
||||||
AllocatedSocketAddress() = default;
|
AllocatedSocketAddress() = default;
|
||||||
|
|
||||||
explicit AllocatedSocketAddress(SocketAddress src) {
|
explicit AllocatedSocketAddress(SocketAddress src) noexcept {
|
||||||
*this = src;
|
*this = src;
|
||||||
}
|
}
|
||||||
|
|
||||||
AllocatedSocketAddress(const AllocatedSocketAddress &) = delete;
|
AllocatedSocketAddress(const AllocatedSocketAddress &) = delete;
|
||||||
|
|
||||||
AllocatedSocketAddress(AllocatedSocketAddress &&src)
|
AllocatedSocketAddress(AllocatedSocketAddress &&src) noexcept
|
||||||
:address(src.address), size(src.size) {
|
:address(src.address), size(src.size) {
|
||||||
src.address = nullptr;
|
src.address = nullptr;
|
||||||
src.size = 0;
|
src.size = 0;
|
||||||
@@ -71,51 +71,51 @@ public:
|
|||||||
free(address);
|
free(address);
|
||||||
}
|
}
|
||||||
|
|
||||||
AllocatedSocketAddress &operator=(SocketAddress src);
|
AllocatedSocketAddress &operator=(SocketAddress src) noexcept;
|
||||||
|
|
||||||
AllocatedSocketAddress &operator=(const AllocatedSocketAddress &) = delete;
|
AllocatedSocketAddress &operator=(const AllocatedSocketAddress &) = delete;
|
||||||
|
|
||||||
AllocatedSocketAddress &operator=(AllocatedSocketAddress &&src) {
|
AllocatedSocketAddress &operator=(AllocatedSocketAddress &&src) noexcept {
|
||||||
std::swap(address, src.address);
|
std::swap(address, src.address);
|
||||||
std::swap(size, src.size);
|
std::swap(size, src.size);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
gcc_pure
|
gcc_pure
|
||||||
bool operator==(SocketAddress other) const {
|
bool operator==(SocketAddress other) const noexcept {
|
||||||
return (SocketAddress)*this == other;
|
return (SocketAddress)*this == other;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool operator!=(SocketAddress &other) const {
|
bool operator!=(SocketAddress &other) const noexcept {
|
||||||
return !(*this == other);
|
return !(*this == other);
|
||||||
}
|
}
|
||||||
|
|
||||||
gcc_const
|
gcc_const
|
||||||
static AllocatedSocketAddress Null() {
|
static AllocatedSocketAddress Null() noexcept {
|
||||||
return AllocatedSocketAddress(nullptr, 0);
|
return AllocatedSocketAddress(nullptr, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool IsNull() const {
|
bool IsNull() const noexcept {
|
||||||
return address == nullptr;
|
return address == nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
size_type GetSize() const {
|
size_type GetSize() const noexcept {
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
const struct sockaddr *GetAddress() const {
|
const struct sockaddr *GetAddress() const noexcept {
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
operator SocketAddress() const {
|
operator SocketAddress() const noexcept {
|
||||||
return SocketAddress(address, size);
|
return SocketAddress(address, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
operator const struct sockaddr *() const {
|
operator const struct sockaddr *() const noexcept {
|
||||||
return address;
|
return address;
|
||||||
}
|
}
|
||||||
|
|
||||||
int GetFamily() const {
|
int GetFamily() const noexcept {
|
||||||
return address->sa_family;
|
return address->sa_family;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -123,11 +123,11 @@ public:
|
|||||||
* Does the object have a well-defined address? Check !IsNull()
|
* Does the object have a well-defined address? Check !IsNull()
|
||||||
* before calling this method.
|
* before calling this method.
|
||||||
*/
|
*/
|
||||||
bool IsDefined() const {
|
bool IsDefined() const noexcept {
|
||||||
return GetFamily() != AF_UNSPEC;
|
return GetFamily() != AF_UNSPEC;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Clear() {
|
void Clear() noexcept {
|
||||||
free(address);
|
free(address);
|
||||||
address = nullptr;
|
address = nullptr;
|
||||||
size = 0;
|
size = 0;
|
||||||
|
Reference in New Issue
Block a user