net/AllocatedSocketAddress: add more "noexcept"

This commit is contained in:
Max Kellermann 2017-05-17 12:07:20 +02:00
parent 7b05df8d33
commit e7bebb0089
2 changed files with 16 additions and 16 deletions

View File

@ -45,7 +45,7 @@
#endif
AllocatedSocketAddress &
AllocatedSocketAddress::operator=(SocketAddress src)
AllocatedSocketAddress::operator=(SocketAddress src) noexcept
{
if (src.IsNull()) {
Clear();

View File

@ -55,13 +55,13 @@ private:
public:
AllocatedSocketAddress() = default;
explicit AllocatedSocketAddress(SocketAddress src) {
explicit AllocatedSocketAddress(SocketAddress src) noexcept {
*this = src;
}
AllocatedSocketAddress(const AllocatedSocketAddress &) = delete;
AllocatedSocketAddress(AllocatedSocketAddress &&src)
AllocatedSocketAddress(AllocatedSocketAddress &&src) noexcept
:address(src.address), size(src.size) {
src.address = nullptr;
src.size = 0;
@ -71,51 +71,51 @@ public:
free(address);
}
AllocatedSocketAddress &operator=(SocketAddress src);
AllocatedSocketAddress &operator=(SocketAddress src) noexcept;
AllocatedSocketAddress &operator=(const AllocatedSocketAddress &) = delete;
AllocatedSocketAddress &operator=(AllocatedSocketAddress &&src) {
AllocatedSocketAddress &operator=(AllocatedSocketAddress &&src) noexcept {
std::swap(address, src.address);
std::swap(size, src.size);
return *this;
}
gcc_pure
bool operator==(SocketAddress other) const {
bool operator==(SocketAddress other) const noexcept {
return (SocketAddress)*this == other;
}
bool operator!=(SocketAddress &other) const {
bool operator!=(SocketAddress &other) const noexcept {
return !(*this == other);
}
gcc_const
static AllocatedSocketAddress Null() {
static AllocatedSocketAddress Null() noexcept {
return AllocatedSocketAddress(nullptr, 0);
}
bool IsNull() const {
bool IsNull() const noexcept {
return address == nullptr;
}
size_type GetSize() const {
size_type GetSize() const noexcept {
return size;
}
const struct sockaddr *GetAddress() const {
const struct sockaddr *GetAddress() const noexcept {
return address;
}
operator SocketAddress() const {
operator SocketAddress() const noexcept {
return SocketAddress(address, size);
}
operator const struct sockaddr *() const {
operator const struct sockaddr *() const noexcept {
return address;
}
int GetFamily() const {
int GetFamily() const noexcept {
return address->sa_family;
}
@ -123,11 +123,11 @@ public:
* Does the object have a well-defined address? Check !IsNull()
* before calling this method.
*/
bool IsDefined() const {
bool IsDefined() const noexcept {
return GetFamily() != AF_UNSPEC;
}
void Clear() {
void Clear() noexcept {
free(address);
address = nullptr;
size = 0;