Annex D (normative) Compatibility features [depr]

D.7 char* streams [depr.str.strstreams]

D.7.4 Class strstream [depr.strstream]

namespace std {
  class strstream
    : public basic_iostream<char> {
  public:
    // Types
    typedef char                                char_type;
    typedef typename char_traits<char>::int_type int_type;
    typedef typename char_traits<char>::pos_type pos_type;
    typedef typename char_traits<char>::off_type off_type;

    // constructors/destructor
    strstream();
    strstream(char* s, int n,
              ios_base::openmode mode = ios_base::in|ios_base::out);
    virtual ~strstream();

    // Members:
    strstreambuf* rdbuf() const;
    void freeze(bool freezefl = true);
    int pcount() const;
    char* str();

  private:
  strstreambuf sb;  // exposition only
  };
}

The class strstream supports reading and writing from objects of classs strstreambuf. It supplies a strstreambuf object to control the associated array object. For the sake of exposition, the maintained data is presented here as

  • sb, the strstreambuf object.

D.7.4.1 strstream constructors [depr.strstream.cons]

strstream();

Effects: Constructs an object of class strstream, initializing the base class with iostream(&sb).

strstream(char* s, int n, ios_base::openmode mode = ios_base::in|ios_base::out);

Effects: Constructs an object of class strstream, initializing the base class with iostream(&sb) and initializing sb with one of the two constructors:

  • If (mode & app) == 0, then s shall designate the first element of an array of n elements. The constructor is strstreambuf(s,n,s).

  • If (mode & app) != 0, then s shall designate the first element of an array of n elements that contains an ntbs whose first element is designated by s. The constructor is strstreambuf(s,n,s + std::strlen(s)).

D.7.4.2 strstream destructor [depr.strstream.dest]

virtual ~strstream()

Effects: Destroys an object of class strstream.

strstreambuf* rdbuf() const;

Returns: &sb.

D.7.4.3 strstream operations [depr.strstream.oper]

void freeze(bool freezefl = true);

Effects: Calls rdbuf()->freeze(freezefl).

char* str();

Returns: rdbuf()->str().

int pcount() const;

Returns: rdbuf()->pcount().