Add noexcept qualifier to ip::basic_endpoint class.
diff --git a/asio/include/asio/ip/basic_endpoint.hpp b/asio/include/asio/ip/basic_endpoint.hpp
index 69c8e97..92e02a9 100644
--- a/asio/include/asio/ip/basic_endpoint.hpp
+++ b/asio/include/asio/ip/basic_endpoint.hpp
@@ -56,7 +56,7 @@
#endif
/// Default constructor.
- basic_endpoint()
+ basic_endpoint() ASIO_NOEXCEPT
: impl_()
{
}
@@ -78,7 +78,7 @@
* @endcode
*/
basic_endpoint(const InternetProtocol& internet_protocol,
- unsigned short port_num)
+ unsigned short port_num) ASIO_NOEXCEPT
: impl_(internet_protocol.family(), port_num)
{
}
@@ -86,27 +86,28 @@
/// Construct an endpoint using a port number and an IP address. This
/// constructor may be used for accepting connections on a specific interface
/// or for making a connection to a remote endpoint.
- basic_endpoint(const asio::ip::address& addr, unsigned short port_num)
+ basic_endpoint(const asio::ip::address& addr,
+ unsigned short port_num) ASIO_NOEXCEPT
: impl_(addr, port_num)
{
}
/// Copy constructor.
- basic_endpoint(const basic_endpoint& other)
+ basic_endpoint(const basic_endpoint& other) ASIO_NOEXCEPT
: impl_(other.impl_)
{
}
#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Move constructor.
- basic_endpoint(basic_endpoint&& other)
+ basic_endpoint(basic_endpoint&& other) ASIO_NOEXCEPT
: impl_(other.impl_)
{
}
#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Assign from another endpoint.
- basic_endpoint& operator=(const basic_endpoint& other)
+ basic_endpoint& operator=(const basic_endpoint& other) ASIO_NOEXCEPT
{
impl_ = other.impl_;
return *this;
@@ -114,7 +115,7 @@
#if defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// Move-assign from another endpoint.
- basic_endpoint& operator=(basic_endpoint&& other)
+ basic_endpoint& operator=(basic_endpoint&& other) ASIO_NOEXCEPT
{
impl_ = other.impl_;
return *this;
@@ -122,7 +123,7 @@
#endif // defined(ASIO_HAS_MOVE) || defined(GENERATING_DOCUMENTATION)
/// The protocol associated with the endpoint.
- protocol_type protocol() const
+ protocol_type protocol() const ASIO_NOEXCEPT
{
if (impl_.is_v4())
return InternetProtocol::v4();
@@ -130,19 +131,19 @@
}
/// Get the underlying endpoint in the native type.
- data_type* data()
+ data_type* data() ASIO_NOEXCEPT
{
return impl_.data();
}
/// Get the underlying endpoint in the native type.
- const data_type* data() const
+ const data_type* data() const ASIO_NOEXCEPT
{
return impl_.data();
}
/// Get the underlying size of the endpoint in the native type.
- std::size_t size() const
+ std::size_t size() const ASIO_NOEXCEPT
{
return impl_.size();
}
@@ -154,75 +155,75 @@
}
/// Get the capacity of the endpoint in the native type.
- std::size_t capacity() const
+ std::size_t capacity() const ASIO_NOEXCEPT
{
return impl_.capacity();
}
/// Get the port associated with the endpoint. The port number is always in
/// the host's byte order.
- unsigned short port() const
+ unsigned short port() const ASIO_NOEXCEPT
{
return impl_.port();
}
/// Set the port associated with the endpoint. The port number is always in
/// the host's byte order.
- void port(unsigned short port_num)
+ void port(unsigned short port_num) ASIO_NOEXCEPT
{
impl_.port(port_num);
}
/// Get the IP address associated with the endpoint.
- asio::ip::address address() const
+ asio::ip::address address() const ASIO_NOEXCEPT
{
return impl_.address();
}
/// Set the IP address associated with the endpoint.
- void address(const asio::ip::address& addr)
+ void address(const asio::ip::address& addr) ASIO_NOEXCEPT
{
impl_.address(addr);
}
/// Compare two endpoints for equality.
friend bool operator==(const basic_endpoint<InternetProtocol>& e1,
- const basic_endpoint<InternetProtocol>& e2)
+ const basic_endpoint<InternetProtocol>& e2) ASIO_NOEXCEPT
{
return e1.impl_ == e2.impl_;
}
/// Compare two endpoints for inequality.
friend bool operator!=(const basic_endpoint<InternetProtocol>& e1,
- const basic_endpoint<InternetProtocol>& e2)
+ const basic_endpoint<InternetProtocol>& e2) ASIO_NOEXCEPT
{
return !(e1 == e2);
}
/// Compare endpoints for ordering.
friend bool operator<(const basic_endpoint<InternetProtocol>& e1,
- const basic_endpoint<InternetProtocol>& e2)
+ const basic_endpoint<InternetProtocol>& e2) ASIO_NOEXCEPT
{
return e1.impl_ < e2.impl_;
}
/// Compare endpoints for ordering.
friend bool operator>(const basic_endpoint<InternetProtocol>& e1,
- const basic_endpoint<InternetProtocol>& e2)
+ const basic_endpoint<InternetProtocol>& e2) ASIO_NOEXCEPT
{
return e2.impl_ < e1.impl_;
}
/// Compare endpoints for ordering.
friend bool operator<=(const basic_endpoint<InternetProtocol>& e1,
- const basic_endpoint<InternetProtocol>& e2)
+ const basic_endpoint<InternetProtocol>& e2) ASIO_NOEXCEPT
{
return !(e2 < e1);
}
/// Compare endpoints for ordering.
friend bool operator>=(const basic_endpoint<InternetProtocol>& e1,
- const basic_endpoint<InternetProtocol>& e2)
+ const basic_endpoint<InternetProtocol>& e2) ASIO_NOEXCEPT
{
return !(e1 < e2);
}
diff --git a/asio/include/asio/ip/detail/endpoint.hpp b/asio/include/asio/ip/detail/endpoint.hpp
index e0c66ff..a422373 100644
--- a/asio/include/asio/ip/detail/endpoint.hpp
+++ b/asio/include/asio/ip/detail/endpoint.hpp
@@ -33,42 +33,43 @@
{
public:
// Default constructor.
- ASIO_DECL endpoint();
+ ASIO_DECL endpoint() ASIO_NOEXCEPT;
// Construct an endpoint using a family and port number.
- ASIO_DECL endpoint(int family, unsigned short port_num);
+ ASIO_DECL endpoint(int family,
+ unsigned short port_num) ASIO_NOEXCEPT;
// Construct an endpoint using an address and port number.
ASIO_DECL endpoint(const asio::ip::address& addr,
- unsigned short port_num);
+ unsigned short port_num) ASIO_NOEXCEPT;
// Copy constructor.
- endpoint(const endpoint& other)
+ endpoint(const endpoint& other) ASIO_NOEXCEPT
: data_(other.data_)
{
}
// Assign from another endpoint.
- endpoint& operator=(const endpoint& other)
+ endpoint& operator=(const endpoint& other) ASIO_NOEXCEPT
{
data_ = other.data_;
return *this;
}
// Get the underlying endpoint in the native type.
- asio::detail::socket_addr_type* data()
+ asio::detail::socket_addr_type* data() ASIO_NOEXCEPT
{
return &data_.base;
}
// Get the underlying endpoint in the native type.
- const asio::detail::socket_addr_type* data() const
+ const asio::detail::socket_addr_type* data() const ASIO_NOEXCEPT
{
return &data_.base;
}
// Get the underlying size of the endpoint in the native type.
- std::size_t size() const
+ std::size_t size() const ASIO_NOEXCEPT
{
if (is_v4())
return sizeof(asio::detail::sockaddr_in4_type);
@@ -80,33 +81,34 @@
ASIO_DECL void resize(std::size_t new_size);
// Get the capacity of the endpoint in the native type.
- std::size_t capacity() const
+ std::size_t capacity() const ASIO_NOEXCEPT
{
return sizeof(data_);
}
// Get the port associated with the endpoint.
- ASIO_DECL unsigned short port() const;
+ ASIO_DECL unsigned short port() const ASIO_NOEXCEPT;
// Set the port associated with the endpoint.
- ASIO_DECL void port(unsigned short port_num);
+ ASIO_DECL void port(unsigned short port_num) ASIO_NOEXCEPT;
// Get the IP address associated with the endpoint.
- ASIO_DECL asio::ip::address address() const;
+ ASIO_DECL asio::ip::address address() const ASIO_NOEXCEPT;
// Set the IP address associated with the endpoint.
- ASIO_DECL void address(const asio::ip::address& addr);
+ ASIO_DECL void address(
+ const asio::ip::address& addr) ASIO_NOEXCEPT;
// Compare two endpoints for equality.
- ASIO_DECL friend bool operator==(
- const endpoint& e1, const endpoint& e2);
+ ASIO_DECL friend bool operator==(const endpoint& e1,
+ const endpoint& e2) ASIO_NOEXCEPT;
// Compare endpoints for ordering.
- ASIO_DECL friend bool operator<(
- const endpoint& e1, const endpoint& e2);
+ ASIO_DECL friend bool operator<(const endpoint& e1,
+ const endpoint& e2) ASIO_NOEXCEPT;
// Determine whether the endpoint is IPv4.
- bool is_v4() const
+ bool is_v4() const ASIO_NOEXCEPT
{
return data_.base.sa_family == ASIO_OS_DEF(AF_INET);
}
diff --git a/asio/include/asio/ip/detail/impl/endpoint.ipp b/asio/include/asio/ip/detail/impl/endpoint.ipp
index 0947a79..8a750d6 100644
--- a/asio/include/asio/ip/detail/impl/endpoint.ipp
+++ b/asio/include/asio/ip/detail/impl/endpoint.ipp
@@ -31,7 +31,7 @@
namespace ip {
namespace detail {
-endpoint::endpoint()
+endpoint::endpoint() ASIO_NOEXCEPT
: data_()
{
data_.v4.sin_family = ASIO_OS_DEF(AF_INET);
@@ -39,7 +39,7 @@
data_.v4.sin_addr.s_addr = ASIO_OS_DEF(INADDR_ANY);
}
-endpoint::endpoint(int family, unsigned short port_num)
+endpoint::endpoint(int family, unsigned short port_num) ASIO_NOEXCEPT
: data_()
{
using namespace std; // For memcpy.
@@ -69,7 +69,7 @@
}
endpoint::endpoint(const asio::ip::address& addr,
- unsigned short port_num)
+ unsigned short port_num) ASIO_NOEXCEPT
: data_()
{
using namespace std; // For memcpy.
@@ -106,7 +106,7 @@
}
}
-unsigned short endpoint::port() const
+unsigned short endpoint::port() const ASIO_NOEXCEPT
{
if (is_v4())
{
@@ -120,7 +120,7 @@
}
}
-void endpoint::port(unsigned short port_num)
+void endpoint::port(unsigned short port_num) ASIO_NOEXCEPT
{
if (is_v4())
{
@@ -134,7 +134,7 @@
}
}
-asio::ip::address endpoint::address() const
+asio::ip::address endpoint::address() const ASIO_NOEXCEPT
{
using namespace std; // For memcpy.
if (is_v4())
@@ -155,18 +155,18 @@
}
}
-void endpoint::address(const asio::ip::address& addr)
+void endpoint::address(const asio::ip::address& addr) ASIO_NOEXCEPT
{
endpoint tmp_endpoint(addr, port());
data_ = tmp_endpoint.data_;
}
-bool operator==(const endpoint& e1, const endpoint& e2)
+bool operator==(const endpoint& e1, const endpoint& e2) ASIO_NOEXCEPT
{
return e1.address() == e2.address() && e1.port() == e2.port();
}
-bool operator<(const endpoint& e1, const endpoint& e2)
+bool operator<(const endpoint& e1, const endpoint& e2) ASIO_NOEXCEPT
{
if (e1.address() < e2.address())
return true;