basic_osyncstream::rdbuf needs a const_cast
Tim Song

Created on 2018-06-29.00:00:00 last changed 40 months ago


Date: 2018-11-12.04:39:29

Proposed resolution:

This wording is relative to N4750.

  1. Change [syncstream.osyncstream.overview], class template basic_osyncstream synopsis, as indicated:

    namespace std {
      template<class charT, class traits, class Allocator>
      class basic_osyncstream : public basic_ostream<charT, traits> {
        // [syncstream.osyncstream.members], member functions
        void emit();
        streambuf_type* get_wrapped() const noexcept;
        syncbuf_type* rdbuf() const noexcept { return const_cast<syncbuf_type*>(&sb); }
Date: 2018-11-12.04:39:29

[ 2018-11, Adopted in San Diego ]

Date: 2018-07-20.00:00:00

[ 2018-07-20 Status set to Tentatively Ready after five positive votes on the reflector. ]

Date: 2018-06-29.00:00:00

The current specification of basic_osyncstream::rdbuf() is

    syncbuf_type* rdbuf() const noexcept { return &sb; }

This is ill-formed because the exposition-only member sb is const inside this const member function, but the return type is a pointer to non-const syncbuf_type. It needs to cast away the constness, consistent with the other streams with embedded stream buffers (such as string and file streams).

Date User Action Args
2021-02-25 10:48:01adminsetstatus: wp -> c++20
2018-11-12 04:39:29adminsetmessages: + msg10196
2018-11-12 04:39:29adminsetstatus: voting -> wp
2018-10-08 05:13:59adminsetstatus: ready -> voting
2018-07-20 21:06:57adminsetmessages: + msg10034
2018-07-20 21:06:57adminsetstatus: new -> ready
2018-06-29 21:35:39adminsetmessages: + msg9998
2018-06-29 00:00:00admincreate