Skip to content

Commit 44d04ea

Browse files
net: Made net::tcp::Socket a literal type
1 parent 11edfff commit 44d04ea

1 file changed

Lines changed: 9 additions & 9 deletions

File tree

api/net/tcp/socket.hpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ class Socket {
3434
*
3535
* Intialize an empty socket <0.0.0.0:0>
3636
*/
37-
Socket() noexcept
37+
constexpr Socket() noexcept
3838
: address_{}
3939
, port_{}
4040
{}
@@ -50,7 +50,7 @@ class Socket {
5050
* @param port
5151
* The port associated with the process
5252
*/
53-
Socket(const Address address, const port_t port) noexcept
53+
constexpr Socket(const Address address, const port_t port) noexcept
5454
: address_{address}
5555
, port_{port}
5656
{}
@@ -60,15 +60,15 @@ class Socket {
6060
*
6161
* @return The socket's network address
6262
*/
63-
Address address() const noexcept
63+
constexpr Address address() const noexcept
6464
{ return address_; }
6565

6666
/**
6767
* Get the socket's port value
6868
*
6969
* @return The socket's port value
7070
*/
71-
port_t port() const noexcept
71+
constexpr port_t port() const noexcept
7272
{ return port_; }
7373

7474
/**
@@ -84,7 +84,7 @@ class Socket {
8484
*
8585
* @return true if this socket is empty, false otherwise
8686
*/
87-
bool is_empty() const noexcept
87+
constexpr bool is_empty() const noexcept
8888
{ return (address_ == 0) and (port_ == 0); }
8989

9090
/**
@@ -95,7 +95,7 @@ class Socket {
9595
*
9696
* @return true if the specified socket is equal, false otherwise
9797
*/
98-
bool operator==(const Socket& other) const noexcept
98+
constexpr bool operator==(const Socket& other) const noexcept
9999
{
100100
return (address() == other.address())
101101
and (port() == other.port());
@@ -109,7 +109,7 @@ class Socket {
109109
*
110110
* @return true if the specified socket is not equal, false otherwise
111111
*/
112-
bool operator!=(const Socket& other) const noexcept
112+
constexpr bool operator!=(const Socket& other) const noexcept
113113
{ return not (*this == other); }
114114

115115
/**
@@ -121,7 +121,7 @@ class Socket {
121121
* @return true if this socket is less-than the specified socket,
122122
* false otherwise
123123
*/
124-
bool operator<(const Socket& other) const noexcept
124+
constexpr bool operator<(const Socket& other) const noexcept
125125
{
126126
return (address() < other.address())
127127
or ((address() == other.address()) and (port() < other.port()));
@@ -136,7 +136,7 @@ class Socket {
136136
* @return true if this socket is greater-than the specified socket,
137137
* false otherwise
138138
*/
139-
bool operator>(const Socket& other) const noexcept
139+
constexpr bool operator>(const Socket& other) const noexcept
140140
{ return not (*this < other); }
141141
private:
142142
Address address_;

0 commit comments

Comments
 (0)