libfly  6.2.2
C++20 utility library for Linux, macOS, and Windows
fly::net::IPv6Address Class Reference

#include <ipv6_address.hpp>

Public Types

using address_type = std::array< std::uint8_t, 16 >
 

Public Member Functions

 IPv6Address ()=default
 
constexpr IPv6Address (const address_type &address) noexcept
 
constexpr IPv6Address (address_type &&address) noexcept
 
constexpr IPv6Address (const address_type::value_type(&address)[16]) noexcept
 
 IPv6Address (const IPv6Address &)=default
 
 IPv6Address (IPv6Address &&)=default
 
IPv6Addressoperator= (const IPv6Address &)=default
 
IPv6Addressoperator= (IPv6Address &&)=default
 
constexpr void copy (address_type::value_type(&address)[16]) const
 
auto operator<=> (const IPv6Address &) const =default
 

Static Public Member Functions

static constexpr IPv6Address in_addr_any ()
 
static constexpr IPv6Address in_addr_loopback ()
 
static constexpr std::optional< IPv6Addressfrom_string (std::string_view address)
 

Detailed Description

Class to store an IPv6 address in an array, 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

◆ IPv6Address() [1/4]

fly::net::IPv6Address::IPv6Address ( )
default

Default constructor. Initializes the IPv6 address to ::.

◆ IPv6Address() [2/4]

constexpr fly::net::IPv6Address::IPv6Address ( const address_type &  address)
explicitconstexprnoexcept

Constructor. Create an IPv6 address from a 16-part array of octets. The array should be ordered such that index 0 is the first octet and index 15 is the sixteenth octet.

Parameters
addressThe 16-part array of octets to initialize the IPv6 address from.

◆ IPv6Address() [3/4]

constexpr fly::net::IPv6Address::IPv6Address ( address_type &&  address)
explicitconstexprnoexcept

Constructor. Create an IPv6 address from a 16-part array of octets. The array should be ordered such that index 0 is the first octet and index 15 is the sixteenth octet.

Parameters
addressThe 16-part array of octets to initialize the IPv6 address from.

◆ IPv6Address() [4/4]

constexpr fly::net::IPv6Address::IPv6Address ( const address_type::value_type(&)  address[16])
explicitconstexprnoexcept

Constructor. Create an IPv6 address from a 16-part array of octets. The array should be ordered such that index 0 is the first octet and index 15 is the sixteenth octet.

Parameters
addressThe 16-part array of octets to initialize the IPv6 address from.

Member Function Documentation

◆ copy()

constexpr void fly::net::IPv6Address::copy ( address_type::value_type(&)  address[16]) const
constexpr

Copy the IPv6 address into a 16-part array.

Parameters
addressThe 16-part array of octets to copy the IPv6 address into.

◆ from_string()

constexpr std::optional< IPv6Address > fly::net::IPv6Address::from_string ( std::string_view  address)
staticconstexpr

Construct an IPv6 address from a string of hexadectets.

The provided string must be fully formed or use shorthand form. In shorthand form, each hexadectet may have leading zeros removed (that is, the hexadectet "001a" may be provided as just "1a"). Further, consecutive hexadectets of zeros may be replaced with two colons (that is, the hexadectets "1:0:0:1" may be provided as "1::1"); this replacement may only be used once in the string.

Parameters
addressThe string to initialize the IPv6 address from.
Returns
If successful, the constructed IPv6 address. Otherwise, an uninitialized value.

◆ in_addr_any()

constexpr IPv6Address fly::net::IPv6Address::in_addr_any ( )
staticconstexpr
Returns
An IPv6 address representing IN6ADDR_ANY.

◆ in_addr_loopback()

constexpr IPv6Address fly::net::IPv6Address::in_addr_loopback ( )
staticconstexpr
Returns
An IPv6 address representing IN6ADDR_LOOPBACK.

◆ operator<=>()

auto fly::net::IPv6Address::operator<=> ( const IPv6Address ) const
default

Three-way-comparison operator. Defaulted to perform the comparison on the IPv6 array data.


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