Title
Should std::basic_osyncstream's move assignment operator be noexcept?
Status
c++23
Section
[syncstream.osyncstream.overview]
Submitter
Jiang An

Created on 2023-01-29.00:00:00 last changed 5 months ago

Messages

Date: 2023-02-13.10:17:57

Proposed resolution:

This wording is relative to N4928.

  1. Modify [syncstream.osyncstream.overview] as indicated:

    namespace std {
      template<class charT, class traits = char_traits<charT>, class Allocator = allocator<charT>>
      class basic_osyncstream : public basic_ostream<charT, traits> {
      public:
        […]
        using syncbuf_type = basic_syncbuf<charT, traits, Allocator>;
        […]
        
        // assignment
        basic_osyncstream& operator=(basic_osyncstream&&) noexcept;
    
        […]
      
      private:
        syncbuf_type sb; // exposition only
      };
    }
    
Date: 2023-02-13.00:00:00

[ 2023-02-13 Approved at February 2023 meeting in Issaquah. Status changed: Voting → WP. ]

Date: 2023-02-15.00:00:00

[ 2023-02-06; Reflector poll ]

Set status to Tentatively Ready after seven votes in favour during reflector poll.

Date: 2023-01-29.00:00:00

The synopsis of std::basic_osyncstream ([syncstream.osyncstream.overview]) indicates that it's member functions behave as if it hold a std::basic_syncbuf as its subobject, and according to [functions.within.classes], std::basic_osyncstream's move assignment operator should call std::basic_syncbuf's move assignment operator.

However, currently std::basic_osyncstream's move assignment operator is noexcept, while std::basic_syncbuf's is not. So when an exception is thrown from move assignment between std::basic_syncbuf objects, std::terminate should be called.

It's clarified in LWG 3498 that an exception can escape from std::basic_syncbuf's move assignment operator. Is there any reason that an exception shouldn't escape from std::basic_osyncstream's move assignment operator?

History
Date User Action Args
2023-11-22 15:47:43adminsetstatus: wp -> c++23
2023-02-13 10:17:57adminsetmessages: + msg13376
2023-02-13 10:17:57adminsetstatus: voting -> wp
2023-02-06 15:33:48adminsetstatus: ready -> voting
2023-02-06 15:13:50adminsetmessages: + msg13268
2023-02-06 15:13:50adminsetstatus: new -> ready
2023-01-29 12:22:38adminsetmessages: + msg13233
2023-01-29 00:00:00admincreate