libfly  6.2.2
C++20 utility library for Linux, macOS, and Windows
fly::net::Endpoint< IPAddressType > Class Template Reference

#include <endpoint.hpp>

Public Types

using address_type = IPAddressType
 

Public Member Functions

 Endpoint ()=default
 
constexpr Endpoint (const IPAddressType &address, port_type port) noexcept
 
constexpr Endpoint (IPAddressType &&address, port_type port) noexcept
 
 Endpoint (const Endpoint &)=default
 
 Endpoint (Endpoint &&)=default
 
Endpointoperator= (const Endpoint &)=default
 
Endpointoperator= (Endpoint &&)=default
 
constexpr const IPAddressType & address () const
 
constexpr port_type port () const
 
auto operator<=> (const Endpoint &) const =default
 

Static Public Member Functions

static constexpr bool is_ipv4 ()
 
static constexpr bool is_ipv6 ()
 
static constexpr std::optional< Endpointfrom_string (std::string_view endpoint)
 

Detailed Description

template<IPAddress IPAddressType>
class fly::net::Endpoint< IPAddressType >

Class to store a version-independent IP address and port, and to provide convenient access to its data as required by various network APIs.

Author
Timothy Flynn (trfly.nosp@m.nn89.nosp@m.@pm.m.nosp@m.e)
Version
February 13, 2021

Constructor & Destructor Documentation

◆ Endpoint() [1/3]

template<IPAddress IPAddressType>
fly::net::Endpoint< IPAddressType >::Endpoint ( )
default

Default constructor.

◆ Endpoint() [2/3]

template<IPAddress IPAddressType>
constexpr fly::net::Endpoint< IPAddressType >::Endpoint ( const IPAddressType &  address,
port_type  port 
)
constexprnoexcept

Constructor. Create an endpoint from an IP address and port.

Parameters
addressThe IP address to initialize the endpoint with.
portThe port to initialize the endpoint with.

◆ Endpoint() [3/3]

template<IPAddress IPAddressType>
constexpr fly::net::Endpoint< IPAddressType >::Endpoint ( IPAddressType &&  address,
port_type  port 
)
constexprnoexcept

Constructor. Create an endpoint from an IP address and port.

Parameters
addressThe IP address to initialize the endpoint with.
portThe port to initialize the endpoint with.

Member Function Documentation

◆ address()

template<IPAddress IPAddressType>
constexpr const IPAddressType & fly::net::Endpoint< IPAddressType >::address
constexpr
Returns
The endoint's IP address.

◆ from_string()

template<IPAddress IPAddressType>
constexpr std::optional< Endpoint< IPAddressType > > fly::net::Endpoint< IPAddressType >::from_string ( std::string_view  endpoint)
staticconstexpr

Construct an endpoint from a string containing an IP address and a port.

The provided string should begin with the IP address and end with the port, separated by a single colon. IPv6 addressses should be surrounded by square brackets (e.g. "[::1]:80");

Parameters
endpointThe string to initialize the endpoint from.
Returns
If successful, the constructed endpoint. Otherwise, an uninitialized value.

◆ is_ipv4()

template<IPAddress IPAddressType>
constexpr bool fly::net::Endpoint< IPAddressType >::is_ipv4
staticconstexpr
Returns
True if this is an IPv4 endpoint.

◆ is_ipv6()

template<IPAddress IPAddressType>
constexpr bool fly::net::Endpoint< IPAddressType >::is_ipv6
staticconstexpr
Returns
True if this is an IPv6 endpoint.

◆ operator<=>()

template<IPAddress IPAddressType>
auto fly::net::Endpoint< IPAddressType >::operator<=> ( const Endpoint< IPAddressType > &  ) const
default

Three-way-comparison operator. Defaulted to perform the comparison on the underlying IP address and port.

◆ port()

template<IPAddress IPAddressType>
constexpr port_type fly::net::Endpoint< IPAddressType >::port
constexpr
Returns
The endoint's IP port.

The documentation for this class was generated from the following file: