4 - Compatibility features (normative) [depr]

-1- This clause describes features of the C++ Standard that are specified for compatibility with existing implementations.

-2- These are deprecated features, where deprecated is defined as: Normative for the current edition of the Standard, but not guaranteed to be part of the Standard in future revisions.

4.1 - Postfix increment operator [depr.post.incr]

-1- The use of an operand of type bool with the postfix ++ operator is deprecated (see expr.post.incr).

4.2 - static keyword [depr.static]

-1- The use of the static keyword is deprecated when declaring objects in namespace scope (see basic.scope.namespace).

4.3 - Access declarations [depr.access.dcl]

-1- Access declarations are deprecated (see class.access.dcl).

4.4 - Implicit conversion from const strings [depr.string]

-1- The implicit conversion from const to non-const qualification for string literals (conv.array) is deprecated.

4.5 - Standard C library headers [depr.c.headers]

-1- For compatibility with the Standard C library, the C++ Standard library provides the 18 C headers, as shown in Table ??:

C Headers
<assert.h><iso646.h><setjmp.h><stdio.h><wchar.h>
<ctype.h><limits.h><signal.h><stdlib.h><wctype.h>
<errno.h><locale.h><stdarg.h><string.h>
<float.h><math.h><stddef.h><time.h>

-2- Each C header, whose name has the form name .h, behaves as if each name placed in the Standard library namespace by the corresponding cname header is also placed within the namespace scope of the namespace std and is followed by an explicit using-declaration (namespace.udecl)

-3- [Example: The header <cstdlib> provides its declarations and definitions within the namespace std. The header <stdlib.h> makes these available in the global name space, much as in the C Standard.
--- end example]

4.6 - Old iostreams members [depr.ios.members]

-1- The following member names are in addition to names specified in clause lib.input.output:

namespace std {
  class ios_base {
  public:
    typedef T1  io_state;
    typedef T2 open_mode;
    typedef T3  seek_dir;
    typedef  OFF_T   streamoff;
    typedef  OFF_T   streampos;
    // remainder unchanged
  };
}

-2- The type io_state is a synonym for an integer type (indicated here as T1 ) that permits certain member functions to overload others on parameters of type iostate and provide the same behavior.

-3- The type open_mode is a synonym for an integer type (indicated here as T2 ) that permits certain member functions to overload others on parameters of type openmode and provide the same behavior.

-4- The type seek_dir is a synonym for an integer type (indicated here as T3 ) that permits certain member functions to overload others on parameters of type seekdir and provide the same behavior.

-5- The type streamoff is an implementation-defined type that satisfies the requirements of type OFF_T (lib.stream.types).

-6- The type streampos is an implementation-defined type that satisfies the requirements of type POS_T (lib.iostream.forward).

-7- An implementation may provide the following additional member function, which has the effect of calling sbumpc() (lib.streambuf.pub.get):

namespace std {
  template<class charT, class traits = char_traits<charT> >
  class basic_streambuf {
  public:
    void stossc();
    // remainder unchanged
  };
}

-8- An implementation may provide the following member functions that overload signatures specified in clause lib.input.output:

namespace std {
  template<class charT, class Traits> class basic_ios {
  public:
    void clear(io_state state);
    void setstate(io_state state);
    // remainder unchanged
  };
  class ios_base {
  public:
    void exceptions(io_state);
    // remainder unchanged
  };
  template<class charT, class traits = char_traits<charT> >
  class basic_streambuf {
  public:
    pos_type pubseekoff(off_type off, ios_base::seek_dir way,
              ios_base::open_mode which = ios_base::in | ios_base::out);
    pos_type pubseekpos(pos_type sp,
              ios_base::open_mode which = ios_base::in | ios_base::out);
    // remainder unchanged
  };
  template <class charT, class traits = char_traits<charT> >
  class basic_filebuf : public basic_streambuf<charT,traits> {
  public:
    basic_filebuf<charT,traits>* open
	(const char* s, ios_base::open_mode mode);
    // remainder unchanged
  };
  template <class charT, class traits = char_traits<charT> >
  class basic_ifstream : public basic_istream<charT,traits> {
  public:
    void open(const char* s, ios_base::open_mode mode = in);
    // remainder unchanged
  };
  template <class charT, class traits = char_traits<charT> >
  class basic_ofstream : public basic_ostream<charT,traits> {
  public:
    void open(const char* s, ios_base::open_mode mode = out | trunc);
    // remainder unchanged
  };
}

-9- The effects of these functions is to call the corresponding member function specified in clause lib.input.output.

4.7 - char* streams [depr.str.strstreams]

-1- The header <strstream> defines three types that associate stream buffers with character array objects and assist reading and writing such objects.

4.7.1 - Class strstreambuf [depr.strstreambuf]

namespace std {
  class strstreambuf : public basic_streambuf<char> {
  public:
    explicit strstreambuf(streamsize alsize_arg = 0);
    strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
    strstreambuf(char* gnext_arg, streamsize n, char* pbeg_arg = 0);
    strstreambuf(const char* gnext_arg, streamsize n);
    strstreambuf(signed char* gnext_arg, streamsize n,
                 signed char* pbeg_arg = 0);
    strstreambuf(const signed char* gnext_arg, streamsize n);
    strstreambuf(unsigned char* gnext_arg, streamsize n,
                 unsigned char* pbeg_arg = 0);
    strstreambuf(const unsigned char* gnext_arg, streamsize n);
    virtual ~strstreambuf();
    void  freeze(bool freezefl = true);
    char* str();
    int   pcount();
  protected:
    virtual int_type overflow (int_type c = EOF);
    virtual int_type pbackfail(int_type c = EOF);
    virtual int_type underflow();
    virtual pos_type seekoff(off_type off, ios_base::seekdir way,
                             ios_base::openmode which
                              = ios_base::in | ios_base::out);
    virtual pos_type seekpos(pos_type sp, ios_base::openmode which
                              = ios_base::in | ios_base::out);
    virtual streambuf<char>* setbuf(char* s, streamsize n);
  private:
//  typedef T1 strstate;		exposition only
//  static const strstate allocated;	exposition only
//  static const strstate constant;	exposition only
//  static const strstate dynamic;	exposition only
//  static const strstate frozen;	exposition only
//  strstate strmode;			exposition only
//  streamsize alsize;			exposition only
//  void* (*palloc)(size_t);		exposition only
//  void (*pfree)(void*);		exposition only
  };
}

-1- The class strstreambuf associates the input sequence, and possibly the output sequence, with an object of some character array type, whose elements store arbitrary values. The array object has several attributes.

-2- [Note: For the sake of exposition, these are represented as elements of a bitmask type (indicated here as T1) called strstate. The elements are:

-3- [Note: For the sake of exposition, the maintained data is presented here as:

-4- Each object of class strstreambuf has a seekable area, delimited by the pointers seeklow and seekhigh. If gnext is a null pointer, the seekable area is undefined. Otherwise, seeklow equals gbeg and seekhigh is either pend, if pend is not a null pointer, or gend.

4.7.1.1 - strstreambuf constructors [depr.strstreambuf.cons]

explicit strstreambuf(streamsize alsize_arg = 0);

-1- Effects: Constructs an object of class strstreambuf, initializing the base class with streambuf().
The postconditions of this function are indicated in Table ??:

strstreambuf(streamsize) effects
ElementValue
strmodedynamic
alsizealsize_arg
palloca null pointer
pfreea null pointer

strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));

-2- Effects: Constructs an object of class strstreambuf, initializing the base class with streambuf().
The postconditions of this function are indicated in Table ??:

strstreambuf(void* (*)(size_t),void (*)(void*) effects
ElementValue
strmodedynamic
alsizean unspecified value
pallocpalloc_arg
pfreepfree_arg

strstreambuf(char* gnext_arg, streamsize n, char *pbeg_arg = 0);
strstreambuf(signed char* gnext_arg, streamsize n,
                                           signed char *pbeg_arg = 0);
strstreambuf(unsigned char* gnext_arg, streamsize n,
                                           unsigned char *pbeg_arg = 0);

-3- Effects: Constructs an object of class strstreambuf, initializing the base class with streambuf().
The postconditions of this function are indicated in Table ??:

strstreambuf(charT*,streamsize,charT*) effects
ElementValue
strmode0
alsizean unspecified value
palloca null pointer
pfreea null pointer

-4- gnext_arg shall point to the first element of an array object whose number of elements N is determined as follows:

-5- If pbeg_arg is a null pointer, the function executes:

setg(gnext_arg, gnext_arg, gnext_arg + N);

-6- Otherwise, the function executes:

setg(gnext_arg, gnext_arg, pbeg_arg);
setp(pbeg_arg,  pbeg_arg + N);
strstreambuf(const char* gnext_arg, streamsize n);
strstreambuf(const signed char* gnext_arg, streamsize n);
strstreambuf(const unsigned char* gnext_arg, streamsize n);

-7- Effects: Behaves the same as strstreambuf((char*)gnext_arg,n), except that the constructor also sets constant in strmode.

virtual ~strstreambuf();

-8- Effects: Destroys an object of class strstreambuf. The function frees the dynamically allocated array object only if strmode & allocated != 0 and strmode & frozen == 0. (_lib.strstreambuf.virtuals_ describes how a dynamically allocated array object is freed.)

4.7.1.2 - Member functions [depr.strstreambuf.members]

void freeze(bool freezefl = true);

-1- Effects: If strmode & dynamic is non-zero, alters the freeze status of the dynamic array object as follows:

char* str();

-2- Effects: Calls freeze(), then returns the beginning pointer for the input sequence, gbeg.

-3- Notes: The return value can be a null pointer.

int pcount() const;

-4- Effects: If the next pointer for the output sequence, pnext, is a null pointer, returns zero. Otherwise, returns the current effective length of the array object as the next pointer minus the beginning pointer for the output sequence, pnext - pbeg.

4.7.1.3 - strstreambuf overridden virtual functions [depr.strstreambuf.virtuals]

int_type overflow(int_type c = EOF);

-1- Effects: Appends the character designated by c to the output sequence, if possible, in one of two ways:

-2- Returns EOF to indicate failure.

-3- Notes: The function can alter the number of write positions available as a result of any call.
To make a write position available, the function reallocates (or initially allocates) an array object with a sufficient number of elements n to hold the current array object (if any), plus at least one additional write position. How many additional write positions are made available is otherwise unspecified.*

[Footnote: An implementation should consider alsize in making this decision. --- end foonote]
If palloc is not a null pointer, the function calls (*palloc)(n) to allocate the new dynamic array object. Otherwise, it evaluates the expression new charT[n]. In either case, if the allocation fails, the function returns EOF. Otherwise, it sets allocated in strmode.

-4- To free a previously existing dynamic array object whose first element address is p: If pfree is not a null pointer, the function calls (*pfree)(p). Otherwise, it evaluates the expression delete[] p.

-5- If strmode & dynamic == 0, or if strmode & frozen != 0, the function cannot extend the array (reallocate it with greater length) to make a write position available.

int_type pbackfail(int_type c = EOF);

-6- Puts back the character designated by c to the input sequence, if possible, in one of three ways:

-7- Returns EOF to indicate failure.

-8- Notes: If the function can succeed in more than one of these ways, it is unspecified which way is chosen. The function can alter the number of putback positions available as a result of any call.

int_type underflow();

-9- Effects: Reads a character from the input sequence, if possible, without moving the stream position past it, as follows:

-10- Returns EOF to indicate failure.

-11- Notes: The function can alter the number of read positions available as a result of any call.

pos_type seekoff(off_type off, seekdir way, openmode which = in | out);

-12- Effects: Alters the stream position within one of the controlled sequences, if possible, as indicated in Table ??:



seekoff positioning
ConditionsResult
(which & ios::in) != 0positions the input sequence
(which & ios::out) != 0positions the output sequence
(which & (ios::in | ios::out)) == (ios::in | ios::out)) and way == either ios::beg or ios::end positions both the input and the output sequences
Otherwisethe positioning operation fails.

-13- For a sequence to be positioned, if its next pointer is a null pointer, the positioning operation fails. Otherwise, the function determines newoff as indicated in Table ??:



newoff values
Condition newoff Value
way == ios::beg0
way == ios::cur the next pointer minus the beginning pointer (xnext - xbeg)
way == ios::end seekhigh minus the beginning pointer (seekhigh - xbeg)
If (newoff + off) < (seeklow - xbeg),
or (seekhigh - xbeg) < (newoff + off)
the positioning operation fails

-14- Otherwise, the function assigns xbeg + newoff + off to the next pointer xnext.

-15- Returns: pos_type(newoff), constructed from the resultant offset newoff (of type off_type), that stores the resultant stream position, if possible. If the positioning operation fails, or if the constructed object cannot represent the resultant stream position, the object stores an invalid stream position.

pos_type seekpos(pos_type sp, ios_base::openmode which
                  = ios_base::in | ios_base::out);

-16- Effects: Alters the stream position within one of the controlled sequences, if possible, to correspond to the stream position stored in sp (as described below).

-17- For a sequence to be positioned, if its next pointer is a null pointer, the positioning operation fails. Otherwise, the function determines newoff from sp.offset():

-18- Returns: pos_type(newoff), constructed from the resultant offset newoff (of type off_type), that stores the resultant stream position, if possible. If the positioning operation fails, or if the constructed object cannot represent the resultant stream position, the object stores an invalid stream position.

streambuf<char>* setbuf(char* s, streamsize n);

-19- Effects: Performs an operation that is defined separately for each class derived from strstreambuf.

4.7.2 - Class istrstream [depr.istrstream]

namespace std {
  class istrstream : public basic_istream<char> {
  public:
    explicit istrstream(const char* s);
    explicit istrstream(char* s);
    istrstream(const char* s, streamsize n);
    istrstream(char* s, streamsize n);
    virtual ~istrstream();
    strstreambuf* rdbuf() const;
    char *str();
  private:
//  strstreambuf sb;	exposition only
  };
}

-1- The class istrstream supports the reading of objects of class strstreambuf. It supplies a strstreambuf object to control the associated array object. For the sake of exposition, the maintained data is presented here as:

4.7.2.1 - istrstream constructors [depr.istrstream.cons]

explicit istrstream(const char* s);
explicit istrstream(char* s);

-1- Effects: Constructs an object of class istrstream, initializing the base class with istream(&sb) and initializing sb with strstreambuf(s,0)). s shall designate the first element of an NTBS.

istrstream(const char* s, streamsize n);

-2- Effects: Constructs an object of class istrstream, initializing the base class with istream(&sb) and initializing sb with strstreambuf(s,n)). s shall designate the first element of an array whose length is n elements, and n shall be greater than zero.

4.7.2.2 - Member functions [depr.istrstream.members]

strstreambuf* rdbuf() const;

-1- Returns: (strstreambuf*)&sb .

char* str();

-2- Returns: rdbuf()->str().

4.7.3 - Class ostrstream [depr.ostrstream]

namespace std {
  class ostrstream : public basic_ostream<char> {
  public:
    ostrstream();
    ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);
    virtual ~ostrstream();
    strstreambuf* rdbuf() const;
    void freeze(bool freezefl = true);
    char* str();
    int pcount() const;
  private:
//  strstreambuf sb;	exposition only
  };
}

-1- The class ostrstream supports the writing of objects of class strstreambuf. It supplies a strstreambuf object to control the associated array object. For the sake of exposition, the maintained data is presented here as:

4.7.3.1 - ostrstream constructors [depr.ostrstream.cons]

    ostrstream();

-1- Effects: Constructs an object of class ostrstream, initializing the base class with ostream(&sb) and initializing sb with strstreambuf()).

ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);

-2- Effects: Constructs an object of class ostrstream, initializing the base class with ostream(&sb), and initializing sb with one of two constructors:

4.7.3.2 - Member functions [depr.ostrstream.members]

strstreambuf* rdbuf() const;

-1- Returns: (strstreambuf*)&sb .

void freeze(bool freezefl = true);

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

char* str();

-3- Returns: rdbuf()->str().

int pcount() const;

-4- Returns: rdbuf()->pcount().

4.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;
    //  consturctors/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
  };
}

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

4.7.4.1 - strstream constructors [depr.strstream.cons]

strstream();

-1- 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);

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

4.7.4.2 - strstream destructor [depr.strstream.dest]

virtual ~strstream()

-1- Effects: Destroys an object of class strstream.

strstreambuf* rdbuf() const;

-2- Returns: &sb.

4.7.4.3 - strstream operations [depr.strstream.oper]

void freeze(bool freezefl = true);

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

char* str();

-2- Returns: rdbuf()->str().

int pcount() const;

-3- Returns: rdbuf()->pcount().