AsyncBerkeley
Asynchronous Berkeley sockets. Simple.
Loading...
Searching...
No Matches
Public Types | Public Member Functions | List of all members
io::socket::socket_option< T > Class Template Reference

A generic wrapper for socket options. More...

#include <io/socket/socket_option.hpp>

Inheritance diagram for io::socket::socket_option< T >:
io::socket::socket_address< Addr >

Public Types

using value_type = std::decay_t< T >
 The type of the socket option value.
 
using size_type = std::size_t
 The size type for the socket option.
 

Public Member Functions

template<size_type Size = sizeof(value_type)>
requires (Size <= sizeof(value_type))
constexpr socket_option (size_type size=Size) noexcept
 Constructs a socket_option with a given size.
 
 socket_option (const socket_option &)=default
 Default copy constructor.
 
 socket_option (socket_option &&)=default
 Default move constructor.
 
 socket_option (const value_type &val) noexcept
 Constructs a socket_option from a value.
 
template<size_type Size>
requires (Size <= sizeof(value_type) || Size == std::dynamic_extent)
 socket_option (std::span< const std::byte, Size > option) noexcept
 Constructs a socket_option from a span of bytes.
 
template<size_type Size>
requires (Size <= sizeof(value_type) || Size == std::dynamic_extent)
 socket_option (std::span< std::byte, Size > option) noexcept
 Constructs a socket_option from a span of bytes.
 
auto operator= (const socket_option &) -> socket_option &=default
 Default copy assignment operator.
 
auto operator= (socket_option &&) -> socket_option &=default
 Default move assignment operator.
 
 ~socket_option ()=default
 Default destructor.
 
constexpr auto operator* () noexcept -> value_type &
 Dereferences the socket option to its value.
 
constexpr auto operator-> () noexcept -> value_type *
 Accesses the socket option's value.
 
constexpr auto begin () noexcept -> std::byte *
 Gets an iterator to the beginning of the option's byte representation.
 
constexpr auto begin () const noexcept -> const std::byte *
 Gets a const iterator to the beginning of the option's byte representation.
 
constexpr auto end () noexcept -> std::byte *
 Gets an iterator to the end of the option's byte representation.
 
constexpr auto end () const noexcept -> const std::byte *
 Gets a const iterator to the end of the option's byte representation.
 
auto operator<=> (const socket_option &other) const noexcept -> bool
 Compares this socket_option with another for ordering.
 
auto operator== (const socket_option &other) const noexcept -> bool
 Compares two socket_option objects for equality.
 

Detailed Description

template<typename T>
requires std::is_trivially_copyable_v<T>
class io::socket::socket_option< T >

A generic wrapper for socket options.

Template Parameters
TThe type of the socket option value.

Constructor & Destructor Documentation

◆ socket_option() [1/4]

template<typename T >
template<size_type Size = sizeof(value_type)>
requires (Size <= sizeof(value_type))
constexpr io::socket::socket_option< T >::socket_option ( size_type  size = Size)
inlineconstexprnoexcept

Constructs a socket_option with a given size.

Template Parameters
SizeThe size of the option.
Parameters
sizeThe size of the option in bytes.

◆ socket_option() [2/4]

template<typename T >
io::socket::socket_option< T >::socket_option ( const value_type val)
inlinenoexcept

Constructs a socket_option from a value.

Parameters
valThe value of the socket option.

◆ socket_option() [3/4]

template<typename T >
template<size_type Size>
requires (Size <= sizeof(value_type) || Size == std::dynamic_extent)
io::socket::socket_option< T >::socket_option ( std::span< const std::byte, Size >  option)
inlinenoexcept

Constructs a socket_option from a span of bytes.

Template Parameters
SizeThe size of the span.
Parameters
optionThe span of bytes representing the option.

◆ socket_option() [4/4]

template<typename T >
template<size_type Size>
requires (Size <= sizeof(value_type) || Size == std::dynamic_extent)
io::socket::socket_option< T >::socket_option ( std::span< std::byte, Size >  option)
inlinenoexcept

Constructs a socket_option from a span of bytes.

Template Parameters
SizeThe size of the span.
Parameters
optionThe span of bytes representing the option.

Member Function Documentation

◆ begin() [1/2]

template<typename T >
constexpr auto io::socket::socket_option< T >::begin ( ) const -> const std::byte *
inlineconstexprnoexcept

Gets a const iterator to the beginning of the option's byte representation.

Returns
A const pointer to the beginning of the byte storage.

◆ begin() [2/2]

template<typename T >
constexpr auto io::socket::socket_option< T >::begin ( ) -> std::byte *
inlineconstexprnoexcept

Gets an iterator to the beginning of the option's byte representation.

Returns
A pointer to the beginning of the byte storage.

◆ end() [1/2]

template<typename T >
constexpr auto io::socket::socket_option< T >::end ( ) const -> const std::byte *
inlineconstexprnoexcept

Gets a const iterator to the end of the option's byte representation.

Returns
A const pointer to the end of the byte storage.

◆ end() [2/2]

template<typename T >
constexpr auto io::socket::socket_option< T >::end ( ) -> std::byte *
inlineconstexprnoexcept

Gets an iterator to the end of the option's byte representation.

Returns
A pointer to the end of the byte storage.

◆ operator*()

template<typename T >
constexpr auto io::socket::socket_option< T >::operator* ( ) -> value_type &
inlineconstexprnoexcept

Dereferences the socket option to its value.

Returns
A reference to the socket option's value.

◆ operator->()

template<typename T >
constexpr auto io::socket::socket_option< T >::operator-> ( ) -> value_type *
inlineconstexprnoexcept

Accesses the socket option's value.

Returns
A pointer to the socket option's value.

◆ operator<=>()

template<typename T >
auto io::socket::socket_option< T >::operator<=> ( const socket_option< T > &  other) const -> bool
inlinenoexcept

Compares this socket_option with another for ordering.

Parameters
otherThe other socket_option to compare with.
Returns
The result of the lexicographical comparison, first by size, then by the raw byte data.

◆ operator=() [1/2]

template<typename T >
auto io::socket::socket_option< T >::operator= ( const socket_option< T > &  ) -> socket_option &=default
default

Default copy assignment operator.

Returns
A reference to this object.

◆ operator=() [2/2]

template<typename T >
auto io::socket::socket_option< T >::operator= ( socket_option< T > &&  ) -> socket_option &=default
default

Default move assignment operator.

Returns
A reference to this object.

◆ operator==()

template<typename T >
auto io::socket::socket_option< T >::operator== ( const socket_option< T > &  other) const -> bool
inlinenoexcept

Compares two socket_option objects for equality.

Parameters
otherThe other socket_option to compare against.
Returns
True if the options are equal, false otherwise.

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