This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of C++23 status.

3443. [networking.ts] net::basic_socket_iostream should use addressof

Section: 19.2.1 [networking.ts::socket.iostream.cons] Status: C++23 Submitter: Jonathan Wakely Opened: 2020-05-14 Last modified: 2023-11-22

Priority: 0

View all other issues in [networking.ts::socket.iostream.cons].

View all issues with C++23 status.

Discussion:

Addresses: networking.ts

19.2.1 [networking.ts::socket.iostream.cons] uses &sb_ which could find something bad via ADL.

[2020-07-17; Moved to Ready in telecon]

Jens suggested we should have blanket wording saying that when the library uses the & operator, it means std::addressof.

[2020-11-09 Approved In November virtual meeting. Status changed: Ready → WP.]

Proposed resolution:

This wording is relative to N4771.

  1. Modify 19.2.1 [networking.ts::socket.iostream.cons] as indicated:

    basic_socket_iostream();
    

    -1- Effects: Initializes the base class as basic_iostream<char>(&addressof(sb_)), value-initializes sb_, and performs setf(std::ios_base::unitbuf).

    explicit basic_socket_iostream(basic_stream_socket<protocol_type> s);
    

    -2- Effects: Initializes the base class as basic_iostream<char>(&addressof(sb_)), initializes sb_ with std::move(s), and performs setf(std::ios_base::unitbuf).

    basic_socket_iostream(basic_socket_iostream&& rhs);
    

    -3- Effects: Move constructs from the rvalue rhs. This is accomplished by move constructing the base class, and the contained basic_socket_streambuf. Next basic_iostream<char>::set_rdbuf(&addressof(sb_)) is called to install the contained basic_socket_streambuf.

    template<class... Args>
      explicit basic_socket_iostream(Args&&... args);
    

    -4- Effects: Initializes the base class as basic_iostream<char>(&addressof(sb_)), value-initializes sb_, and performs setf(std::ios_base::unitbuf). Then calls rdbuf()->connect(forward<Args>(args)...). If that function returns a null pointer, calls setstate(failbit).