[committed 2/2] libstdc++: Fix internet socket option classes

Jonathan Wakely jwakely@redhat.com
Mon Apr 26 20:22:06 GMT 2021

Similar to the previous commit, this fixes various problems with the
socket options classes in the <internet> header:

- The constructors were not noexcept.
- The __sockopt_base<T>::value() member function was present
   unconditionally (so was defined for socket_base::linger which is
- The __socket_crtp<C, T>::operator=(T) assignment operator was not
   noexcept, and was hidden in the derived classes.
- The MulticastSocketOptions incorrectly used a union, incorrectly
   defined resize and const data() member functions, and their
   constructors were unimplemented.

Also, where appropriate:

- 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.


         * include/experimental/internet (tcp::no_delay, v6_only)
         (unicast::hops, multicast::hops, multicast::enable_loopback):
         Change access of base class and static data members. Add
         using-declaration for __socket_crtp::operator=(_Tp).
         (multicast::__mcastopt): New type.
         (multicast::join_group, multicast::leave_group): Derive from
         __mcastopt for common implementation.
         * include/experimental/socket: Add comment.
         * testsuite/experimental/net/internet/socket/opt.cc: New test.
         * testsuite/experimental/net/socket/socket_base.cc: Check for
         protected constructor/destructor of socket_base. Check for
         explicit constructors of socket option classes.

Tested powerpc64le-linux and powerpc-aix. Committed to trunk.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: patch.txt
Type: text/x-patch
Size: 19190 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/libstdc++/attachments/20210426/4003bd58/attachment-0001.bin>

More information about the Libstdc++ mailing list