libstdc++: Fix socket option classes
authorJonathan Wakely <jwakely@redhat.com>
Mon, 26 Apr 2021 20:16:21 +0000 (21:16 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Mon, 26 Apr 2021 20:16:21 +0000 (21:16 +0100)
commit06c86a4f210c76a157512a2963e6c31302d161cb
tree53e2126bff13e0a82f5f78dbe9018a11831c6bf2
parent49adc066729bda093b0658e3926bbf64cd4628b3
libstdc++: Fix socket option classes

This fixes some flaws in the socket option types defined in
net::socket_base:

- The constructors were not noexcept.
- The __sockopt_base<T>::value() member function was present
  unconditionally (so was defined for socket_base::linger which is
  incorrect).
- The __socket_crtp<C, T>::operator=(T) assignment operator was not
  noexcept, and was hidden in the derived classes.

Also:

- Use class instead of struct for the socket option types.
- Define the _S_level and _S_name constants as private.
- Declare the __socket_crtp base as a friend.

libstdc++-v3/ChangeLog:

* include/experimental/bits/net.h (__socket_base): Add
bool template parameter to allow BooleanSocketOption and
IntegerSocketOption to have different __socket_base<int>
base classes.
(__socket_base<bool>): Adjust base class.
(__socket_base<int>): Add partial specialization.
(__socket_crtp::operator=(_Tp)): Add noexcept-specifier.
* include/experimental/socket (socket_base::broadcast)
(socket_base::debug, socket_base::do_not_route)
(socket_base::keep_alive, socket_base::linger)
(socket_base::out_of_band_inline)
(socket_base::receive_buffer_size)
(socket_base::receive_low_watermark)
(socket_base::reuse_address, socket_base::send_buffer_size)
(socket_base::send_low_watermark): Add using-declaration for
__socket_crtp::operator=(_Tp).
* testsuite/experimental/net/socket/socket_base.cc: Check
properties of socket option types.
libstdc++-v3/include/experimental/bits/net.h
libstdc++-v3/include/experimental/socket
libstdc++-v3/testsuite/experimental/net/socket/socket_base.cc