18 Sockets [socket]

18.6 Class template basic_socket [socket.basic]

18.6.3 basic_socket assignment [socket.basic.assign]

basic_socket& operator=(basic_socket&& rhs);

Effects: If is_open() is true, cancels all outstanding asynchronous operations associated with this socket. Completion handlers for canceled operations are passed an error code ec such that ec == errc::operation_canceled yields true. Disables the linger socket option to prevent the assignment from blocking, and releases socket resources as if by POSIX close(native_handle()). Moves into *this the state originally represented by rhs.

Postconditions:

  • get_executor() == rhs.get_executor().

  • is_open() returns the same value as rhs.is_open() prior to the assignment.

  • non_blocking() returns the same value as rhs.non_blocking() prior to the assignment.

  • protocol_ is the prior value of rhs.protocol_.

  • rhs.is_open() == false.

Returns: *this.

template<class OtherProtocol> basic_socket& operator=(basic_socket<OtherProtocol>&& rhs);

Requires: OtherProtocol is implicitly convertible to Protocol.

Effects: If is_open() is true, cancels all outstanding asynchronous operations associated with this socket. Completion handlers for canceled operations are passed an error code ec such that ec == errc::operation_canceled yields true. Disables the linger socket option to prevent the assignment from blocking, and releases socket resources as if by POSIX close(native_handle()). Moves into *this the state originally represented by rhs.

Postconditions:

  • get_executor() == rhs.get_executor().

  • is_open() returns the same value as rhs.is_open() prior to the assignment.

  • non_blocking() returns the same value as rhs.non_blocking() prior to the assignment.

  • protocol_ is the result of converting the prior value of rhs.protocol_.

  • rhs.is_open() == false.

Returns: *this.

Remarks: This assignment operator shall not participate in overload resolution unless OtherProtocol is implicitly convertible to Protocol.