Annex D (normative) Compatibility features [depr]

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

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.

D.1 Increment operator with bool operand [depr.incr.bool]

The use of an operand of type bool with the ++ operator is deprecated (see [expr.pre.incr] and [expr.post.incr]).

D.2 register keyword [depr.register]

The use of the register keyword as a storage-class-specifier ([dcl.stc]) is deprecated.

D.3 Implicit declaration of copy functions [depr.impldec]

The implicit definition of a copy constructor as defaulted is deprecated if the class has a user-declared copy assignment operator or a user-declared destructor. The implicit definition of a copy assignment operator as defaulted is deprecated if the class has a user-declared copy constructor or a user-declared destructor ([class.dtor], [class.copy]). In a future revision of this International Standard, these implicit definitions could become deleted ([dcl.fct.def]).

D.4 Dynamic exception specifications [depr.except.spec]

The use of dynamic-exception-specifications is deprecated.

D.5 C standard library headers [depr.c.headers]

For compatibility with the C standard library and the C Unicode TR, the C++ standard library provides the 25 C headers, as shown in Table [tab:future.c.headers].

Table 154 — C headers
<assert.h> <inttypes.h> <signal.h> <stdio.h> <wchar.h>
<complex.h> <iso646.h> <stdalign.h> <stdlib.h> <wctype.h>
<ctype.h> <limits.h> <stdarg.h> <string.h>
<errno.h> <locale.h> <stdbool.h> <tgmath.h>
<fenv.h> <math.h> <stddef.h> <time.h>
<float.h> <setjmp.h> <stdint.h> <uchar.h>

Every C header, each of which has a name of the form name.h, behaves as if each name placed in the standard library namespace by the corresponding cname header is placed within the global namespace scope. It is unspecified whether these names are first declared or defined within namespace scope ([basic.scope.namespace]) of the namespace std and are then injected into the global namespace scope by explicit using-declarations ([namespace.udecl]).

Example: The header <cstdlib> assuredly provides its declarations and definitions within the namespace std. It may also provide these names within the global namespace. The header <stdlib.h> assuredly provides the same declarations and definitions within the global namespace, much as in the C Standard. It may also provide these names within the namespace std.  — end example ]

D.6 Old iostreams members [depr.ios.members]

The following member names are in addition to names specified in Clause [input.output]:

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

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.

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.

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.

The type streamoff is an implementation-defined type that satisfies the requirements of off_type in [iostreams.limits.pos].

The type streampos is an implementation-defined type that satisfies the requirements of pos_type in [iostreams.limits.pos].

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

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

An implementation may provide the following member functions that overload signatures specified in Clause [input.output]:

namespace std {
  template<class charT, class traits> class basic_ios {
  public:
    void clear(io_state state);
    void setstate(io_state state);
    void exceptions(io_state);
    // remainder unchanged
  };

  class ios_base {
  public:
    // 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);
    // 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);
    // 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);
    // remainder unchanged
  };
}

The effects of these functions is to call the corresponding member function specified in Clause [input.output].

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

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

D.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* 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
  };
}

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.

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

  • allocated, set when a dynamic array object has been allocated, and hence should be freed by the destructor for the strstreambuf object;

  • constant, set when the array object has const elements, so the output sequence cannot be written;

  • dynamic, set when the array object is allocated (or reallocated) as necessary to hold a character sequence that can change in length;

  • frozen, set when the program has requested that the array object not be altered, reallocated, or freed.

 — end note ]

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

  • strstate strmode, the attributes of the array object associated with the strstreambuf object;

  • int alsize, the suggested minimum size for a dynamic array object;

  • void* (*palloc(size_t), points to the function to call to allocate a dynamic array object;

  • void (*pfree)(void*), points to the function to call to free a dynamic array object.

 — end note ]

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.

D.7.1.1 strstreambuf constructors [depr.strstreambuf.cons]

explicit strstreambuf(streamsize alsize_arg = 0);

Effects: Constructs an object of class strstreambuf, initializing the base class with streambuf(). The postconditions of this function are indicated in Table [tab:future.strstreambuf.effects].

Table 155strstreambuf(streamsize) effects
ElementValue
strmode dynamic
alsize alsize_arg
palloc a null pointer
pfree a null pointer

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

Effects: Constructs an object of class strstreambuf, initializing the base class with streambuf(). The postconditions of this function are indicated in Table [tab:future.strstreambuf1.effects].

Table 156strstreambuf(void* (*)(size_t), void (*)(void*)) effects
ElementValue
strmode dynamic
alsize an unspecified value
palloc palloc_arg
pfree pfree_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);

Effects: Constructs an object of class strstreambuf, initializing the base class with streambuf(). The postconditions of this function are indicated in Table [tab:future.strstreambuf2.effects].

Table 157strstreambuf(charT*, streamsize, charT*) effects
ElementValue
strmode 0
alsize an unspecified value
palloc a null pointer
pfree a null pointer

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

  • If n > 0, N is n.

  • If n == 0, N is std::strlen(gnext_arg).

  • If n < 0, N is INT_MAX.338

If pbeg_arg is a null pointer, the function executes:

setg(gnext_arg, gnext_arg, gnext_arg + N);

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

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

virtual ~strstreambuf();

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

The function signature strlen(const char*) is declared in <cstring>. ([c.strings]). The macro INT_MAX is defined in <climits> ([support.limits]).

D.7.1.2 Member functions [depr.strstreambuf.members]

void freeze(bool freezefl = true);

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

  • If freezefl is true, the function sets frozen in strmode.

  • Otherwise, it clears frozen in strmode.

char* str();

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

Remarks: The return value can be a null pointer.

int pcount() const;

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.

D.7.1.3 strstreambuf overridden virtual functions [depr.strstreambuf.virtuals]

int_type overflow(int_type c = EOF);

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

  • If c != EOF and if either the output sequence has a write position available or the function makes a write position available (as described below), assigns c to *pnext++.

    Returns (unsigned char)c.

  • If c == EOF, there is no character to append.

    Returns a value other than EOF.

Returns EOF to indicate failure.

Remarks: 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.339 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.

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.

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

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

  • If c != EOF, if the input sequence has a putback position available, and if (char)c == gnext[-1], assigns gnext - 1 to gnext.

    Returns c.

  • If c != EOF, if the input sequence has a putback position available, and if strmode & constant is zero, assigns c to *--gnext.

    Returns c.

  • If c == EOF and if the input sequence has a putback position available, assigns gnext - 1 to gnext.

    Returns a value other than EOF.

Returns EOF to indicate failure.

Remarks: 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();

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

  • If the input sequence has a read position available, the function signals success by returning (unsigned char)*gnext.

  • Otherwise, if the current write next pointer pnext is not a null pointer and is greater than the current read end pointer gend, makes a read position available by assigning to gend a value greater than gnext and no greater than pnext.

    Returns (unsigned char*)gnext.

Returns EOF to indicate failure.

Remarks: 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);

Effects: Alters the stream position within one of the controlled sequences, if possible, as indicated in Table [tab:future.seekoff.positioning].

Table 158seekoff positioning
ConditionsResult
(which & ios::in) != 0 positions the input sequence
(which & ios::out) != 0 positions 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
Otherwise the positioning operation fails.

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 [tab:future.newoff.values].

Table 159newoff values
Conditionnewoff Value
way == ios::beg 0
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

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

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 return value is pos_type(off_type(-1)).

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

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

  • If (which & ios::in) != 0, positions the input sequence.

  • If (which & ios::out) != 0, positions the output sequence.

  • If the function positions neither sequence, the positioning operation fails.

    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():

  • If newoff is an invalid stream position, has a negative value, or has a value greater than (seekhigh - seeklow), the positioning operation fails

  • Otherwise, the function adds newoff to the beginning pointer xbeg and stores the result in the next pointer xnext.

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 return value is pos_type(off_type(-1)).

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

Effects: Implementation defined, except that setbuf(0, 0) has no effect.

An implementation should consider alsize in making this decision.

D.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
  };
}

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:

  • sb, the strstreambuf object.

D.7.2.1 istrstream constructors [depr.istrstream.cons]

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

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

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.

D.7.2.2 Member functions [depr.istrstream.members]

strstreambuf* rdbuf() const;

Returns: const_cast<strstreambuf*>(&sb).

char* str();

Returns: rdbuf()->str().

D.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
  };
}

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:

  • sb, the strstreambuf object.

D.7.3.1 ostrstream constructors [depr.ostrstream.cons]

ostrstream();

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

Effects: Constructs an object of class ostrstream, initializing the base class with ostream(&sb), and initializing sb with one of 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)).340

The function signature strlen(const char*) is declared in <cstring> ([c.strings]).

D.7.3.2 Member functions [depr.ostrstream.members]

strstreambuf* rdbuf() const;

Returns: (strstreambuf*)&sb .

void freeze(bool freezefl = true);

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

char* str();

Returns: rdbuf()->str().

int pcount() const;

Returns: rdbuf()->pcount().

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

D.8 Function objects [depr.function.objects]

D.8.1 Base [depr.base]

The class templates unary_function and binary_function are deprecated. A program shall not declare specializations of these templates.

namespace std {
  template <class Arg, class Result>
  struct unary_function {
    typedef Arg    argument_type;
    typedef Result result_type;
  };
}

namespace std {
  template <class Arg1, class Arg2, class Result>
  struct binary_function {
    typedef Arg1   first_argument_type;
    typedef Arg2   second_argument_type;
    typedef Result result_type;
  };
}

D.8.2 Function adaptors [depr.adaptors]

The adaptors ptr_fun, mem_fun, mem_fun_ref, and their corresponding return types are deprecated. [ Note: The function template bind [func.bind] provides a better solution.  — end note ]

D.8.2.1 Adaptors for pointers to functions [depr.function.pointer.adaptors]

To allow pointers to (unary and binary) functions to work with function adaptors the library provides:

template <class Arg, class Result> class pointer_to_unary_function : public unary_function<Arg, Result> { public: explicit pointer_to_unary_function(Result (*f)(Arg)); Result operator()(Arg x) const; };

operator() returns f(x).

template <class Arg, class Result> pointer_to_unary_function<Arg, Result> ptr_fun(Result (*f)(Arg));

Returns: pointer_to_unary_function<Arg, Result>(f).

template <class Arg1, class Arg2, class Result> class pointer_to_binary_function : public binary_function<Arg1,Arg2,Result> { public: explicit pointer_to_binary_function(Result (*f)(Arg1, Arg2)); Result operator()(Arg1 x, Arg2 y) const; };

operator() returns f(x,y).

template <class Arg1, class Arg2, class Result> pointer_to_binary_function<Arg1,Arg2,Result> ptr_fun(Result (*f)(Arg1, Arg2));

Returns: pointer_to_binary_function<Arg1,Arg2,Result>(f).

Example:

int compare(const char*, const char*);
replace_if(v.begin(), v.end(),
  not1(bind2nd(ptr_fun(compare), "abc")), "def");

replaces each abc with def in sequence v.  — end example ]

D.8.2.2 Adaptors for pointers to members [depr.member.pointer.adaptors]

The purpose of the following is to provide the same facilities for pointer to members as those provided for pointers to functions in [depr.function.pointer.adaptors].

template <class S, class T> class mem_fun_t : public unary_function<T*, S> { public: explicit mem_fun_t(S (T::*p)()); S operator()(T* p) const; };

mem_fun_t calls the member function it is initialized with given a pointer argument.

template <class S, class T, class A> class mem_fun1_t : public binary_function<T*, A, S> { public: explicit mem_fun1_t(S (T::*p)(A)); S operator()(T* p, A x) const; };

mem_fun1_t calls the member function it is initialized with given a pointer argument and an additional argument of the appropriate type.

template<class S, class T> mem_fun_t<S,T> mem_fun(S (T::*f)()); template<class S, class T, class A> mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A));

mem_fun(&X::f) returns an object through which X::f can be called given a pointer to an X followed by the argument required for f (if any).

template <class S, class T> class mem_fun_ref_t : public unary_function<T, S> { public: explicit mem_fun_ref_t(S (T::*p)()); S operator()(T& p) const; };

mem_fun_ref_t calls the member function it is initialized with given a reference argument.

template <class S, class T, class A> class mem_fun1_ref_t : public binary_function<T, A, S> { public: explicit mem_fun1_ref_t(S (T::*p)(A)); S operator()(T& p, A x) const; };

mem_fun1_ref_t calls the member function it is initialized with given a reference argument and an additional argument of the appropriate type.

template<class S, class T> mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)()); template<class S, class T, class A> mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A));

mem_fun_ref(&X::f) returns an object through which X::f can be called given a reference to an X followed by the argument required for f (if any).

template <class S, class T> class const_mem_fun_t : public unary_function<const T*, S> { public: explicit const_mem_fun_t(S (T::*p)() const); S operator()(const T* p) const; };

const_mem_fun_t calls the member function it is initialized with given a pointer argument.

template <class S, class T, class A> class const_mem_fun1_t : public binary_function<const T*, A, S> { public: explicit const_mem_fun1_t(S (T::*p)(A) const); S operator()(const T* p, A x) const; };

const_mem_fun1_t calls the member function it is initialized with given a pointer argument and an additional argument of the appropriate type.

template<class S, class T> const_mem_fun_t<S,T> mem_fun(S (T::*f)() const); template<class S, class T, class A> const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const);

mem_fun(&X::f) returns an object through which X::f can be called given a pointer to an X followed by the argument required for f (if any).

template <class S, class T> class const_mem_fun_ref_t : public unary_function<T, S> { public: explicit const_mem_fun_ref_t(S (T::*p)() const); S operator()(const T& p) const; };

const_mem_fun_ref_t calls the member function it is initialized with given a reference argument.

template <class S, class T, class A> class const_mem_fun1_ref_t : public binary_function<T, A, S> { public: explicit const_mem_fun1_ref_t(S (T::*p)(A) const); S operator()(const T& p, A x) const; };

const_mem_fun1_ref_t calls the member function it is initialized with given a reference argument and an additional argument of the appropriate type.

template<class S, class T> const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const); template<class S, class T, class A> const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const);

mem_fun_ref(&X::f) returns an object through which X::f can be called given a reference to an X followed by the argument required for f (if any).

D.9 Binders [depr.lib.binders]

The binders binder1st, bind1st, binder2nd, and bind2nd are deprecated. [ Note: The function template bind ([bind]) provides a better solution. — end note ]

D.9.1 Class template binder1st [depr.lib.binder.1st]

template <class Fn> class binder1st : public unary_function<typename Fn::second_argument_type, typename Fn::result_type> { protected: Fn op; typename Fn::first_argument_type value; public: binder1st(const Fn& x, const typename Fn::first_argument_type& y); typename Fn::result_type operator()(const typename Fn::second_argument_type& x) const; typename Fn::result_type operator()(typename Fn::second_argument_type& x) const; };

The constructor initializes op with x and value with y.

operator() returns op(value,x).

D.9.2 bind1st [depr.lib.bind.1st]

template <class Fn, class T> binder1st<Fn> bind1st(const Fn& fn, const T& x);

Returns: binder1st<Fn>(fn, typename Fn::first_argument_type(x)).

D.9.3 Class template binder2nd [depr.lib.binder.2nd]

template <class Fn> class binder2nd : public unary_function<typename Fn::first_argument_type, typename Fn::result_type> { protected: Fn op; typename Fn::second_argument_type value; public: binder2nd(const Fn& x, const typename Fn::second_argument_type& y); typename Fn::result_type operator()(const typename Fn::first_argument_type& x) const; typename Fn::result_type operator()(typename Fn::first_argument_type& x) const; };

The constructor initializes op with x and value with y.

operator() returns op(x,value).

D.9.4 bind2nd [depr.lib.bind.2nd]

template <class Fn, class T> binder2nd<Fn> bind2nd(const Fn& op, const T& x);

Returns: binder2nd<Fn>(op, typename Fn::second_argument_type(x)).

Example:

find_if(v.begin(), v.end(), bind2nd(greater<int>(), 5));

finds the first integer in vector v greater than 5;

find_if(v.begin(), v.end(), bind1st(greater<int>(), 5));

finds the first integer in v less than 5.  — end example ]

D.10 auto_ptr [depr.auto.ptr]

The class template auto_ptr is deprecated. [ Note: The class template unique_ptr ([unique.ptr]) provides a better solution.  — end note ]

D.10.1 Class template auto_ptr [auto.ptr]

The class template auto_ptr stores a pointer to an object obtained via new and deletes that object when it itself is destroyed (such as when leaving block scope [stmt.dcl]).

The class template auto_ptr_ref is for exposition only. An implementation is permitted to provide equivalent functionality without providing a template with this name. The template holds a reference to an auto_ptr. It is used by the auto_ptr conversions to allow auto_ptr objects to be passed to and returned from functions.

namespace std {
  template <class Y> struct auto_ptr_ref;   // exposition only

  template <class X> class auto_ptr {
  public:
    typedef X element_type;

    // [auto.ptr.cons] construct/copy/destroy:
    explicit auto_ptr(X* p =0) throw();
    auto_ptr(auto_ptr&) throw();
    template<class Y> auto_ptr(auto_ptr<Y>&) throw();
    auto_ptr& operator=(auto_ptr&) throw();
    template<class Y> auto_ptr& operator=(auto_ptr<Y>&) throw();
    auto_ptr& operator=(auto_ptr_ref<X> r) throw();
   ~auto_ptr() throw();

    // [auto.ptr.members] members:
    X& operator*() const throw();
    X* operator->() const throw();
    X* get() const throw();
    X* release() throw();
    void reset(X* p =0) throw();

    // [auto.ptr.conv] conversions:
    auto_ptr(auto_ptr_ref<X>) throw();
    template<class Y> operator auto_ptr_ref<Y>() throw();
    template<class Y> operator auto_ptr<Y>() throw();
  };

  template <> class auto_ptr<void>
  {
  public:
    typedef void element_type;
  };
}

The class template auto_ptr provides a semantics of strict ownership. An auto_ptr owns the object it holds a pointer to. Copying an auto_ptr copies the pointer and transfers ownership to the destination. If more than one auto_ptr owns the same object at the same time the behavior of the program is undefined. [ Note: The uses of auto_ptr include providing temporary exception-safety for dynamically allocated memory, passing ownership of dynamically allocated memory to a function, and returning dynamically allocated memory from a function. Instances of auto_ptr meet the requirements of MoveConstructible and MoveAssignable, but do not meet the requirements of CopyConstructible and CopyAssignable.  — end note ]

D.10.1.1 auto_ptr constructors [auto.ptr.cons]

explicit auto_ptr(X* p =0) throw();

Postconditions: *this holds the pointer p.

auto_ptr(auto_ptr& a) throw();

Effects: Calls a.release().

Postconditions: *this holds the pointer returned from a.release().

template<class Y> auto_ptr(auto_ptr<Y>& a) throw();

Requires: Y* can be implicitly converted to X*.

Effects: Calls a.release().

Postconditions: *this holds the pointer returned from a.release().

auto_ptr& operator=(auto_ptr& a) throw();

Requires: The expression delete get() is well formed.

Effects: reset(a.release()).

Returns: *this.

template<class Y> auto_ptr& operator=(auto_ptr<Y>& a) throw();

Requires: Y* can be implicitly converted to X*. The expression delete get() is well formed.

Effects: reset(a.release()).

Returns: *this.

~auto_ptr() throw();

Requires: The expression delete get() is well formed.

Effects: delete get().

D.10.1.2 auto_ptr members [auto.ptr.members]

X& operator*() const throw();

Requires: get() != 0

Returns: *get()

X* operator->() const throw();

Returns: get()

X* get() const throw();

Returns: The pointer *this holds.

X* release() throw();

Returns: get()

Postcondition: *this holds the null pointer.

void reset(X* p=0) throw();

Effects: If get() != p then delete get().

Postconditions: *this holds the pointer p.

D.10.1.3 auto_ptr conversions [auto.ptr.conv]

auto_ptr(auto_ptr_ref<X> r) throw();

Effects: Calls p.release() for the auto_ptr p that r holds.

Postconditions: *this holds the pointer returned from release().

template<class Y> operator auto_ptr_ref<Y>() throw();

Returns: An auto_ptr_ref<Y> that holds *this.

template<class Y> operator auto_ptr<Y>() throw();

Effects: Calls release().

Returns: An auto_ptr<Y> that holds the pointer returned from release().

auto_ptr& operator=(auto_ptr_ref<X> r) throw()

Effects: Calls reset(p.release()) for the auto_ptr p that r holds a reference to.

Returns: *this

D.11 Violating exception-specifications [exception.unexpected]

D.11.1 Type unexpected_handler [unexpected.handler]

typedef void (*unexpected_handler)();

The type of a handler function to be called by unexpected() when a function attempts to throw an exception not listed in its dynamic-exception-specification.

Required behavior: An unexpected_handler shall not return. See also [except.unexpected].

Default behavior: The implementation's default unexpected_handler calls std::terminate().

D.11.2 set_unexpected [set.unexpected]

unexpected_handler set_unexpected(unexpected_handler f) noexcept;

Effects: Establishes the function designated by f as the current unexpected_handler.

Remark: It is unspecified whether a null pointer value designates the default unexpected_handler.

Returns: The previous unexpected_handler.

D.11.3 get_unexpected [get.unexpected]

unexpected_handler get_unexpected() noexcept;

Returns: The current unexpected_handler. [ Note: This may be a null pointer value.  — end note ]

D.11.4 unexpected [unexpected]

[[noreturn]] void unexpected();

Remarks: Called by the implementation when a function exits via an exception not allowed by its exception-specification ([except.unexpected]), in effect after evaluating the throw-expression ([unexpected.handler]). May also be called directly by the program.

Effects: Calls the current unexpected_handler function. [ Note: A default unexpected_handler is always considered a callable handler in this context.  — end note ]