%!TEX root = std.tex
\normannex{depr}{Compatibility features}

\pnum
This Clause describes features of the \Cpp Standard that are specified for compatibility with
existing implementations.

\pnum
These are deprecated features, where
\term{deprecated}
is defined as:
Normative for the current edition of the Standard,
but having been identified as a candidate for removal from future revisions.
An implementation may declare library names and entities described in this section with the
\tcode{deprecated} attribute~(\ref{dcl.attr.deprecated}).

\rSec1[depr.incr.bool]{Increment operator with \tcode{bool} operand}

\pnum
The use of an operand of type
\tcode{bool}
with the
\tcode{++}
operator is deprecated (see~\ref{expr.pre.incr} and~\ref{expr.post.incr}).

\rSec1[depr.register]{\tcode{register} keyword}

\pnum
The use of the \tcode{register} keyword as a
\grammarterm{storage-class-specifier}~(\ref{dcl.stc}) is deprecated.

\rSec1[depr.impldec]{Implicit declaration of copy functions}

\pnum
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 (\ref{class.dtor},~\ref{class.copy}).
In a future revision of this International Standard, these implicit definitions
could become deleted~(\ref{dcl.fct.def}).

\rSec1[depr.except.spec]{Dynamic exception specifications}

\pnum
The use of \grammarterm{dynamic-exception-specification}{s} is deprecated.

\rSec1[depr.c.headers]{C standard library headers}

\pnum
For compatibility with the 
\indextext{library!C standard}%
C standard library and the C Unicode TR, the \Cpp standard library provides
the 26 \textit{C headers}, as shown in Table~\ref{tab:future.c.headers}.

\begin{floattable}{C headers}{tab:future.c.headers}
{lllll}
\topline

\tcode{<assert.h>}			&
\tcode{<inttypes.h>}		&
\tcode{<signal.h>}			&
\tcode{<stdio.h>}			  &
\tcode{<wchar.h>}			  \\

\tcode{<complex.h>}			&
\tcode{<iso646.h>}			&
\tcode{<stdalign.h>}    &
\tcode{<stdlib.h>}			&
\tcode{<wctype.h>}			\\

\tcode{<ctype.h>}			  &
\tcode{<limits.h>}			&
\tcode{<stdarg.h>}			&
\tcode{<string.h>}			& \\

\tcode{<errno.h>}			  &
\tcode{<locale.h>}			&
\tcode{<stdbool.h>}			&
\tcode{<tgmath.h>}			& \\

\tcode{<fenv.h>}			  &
\tcode{<math.h>}			  &
\tcode{<stddef.h>}			&
\tcode{<time.h>}				& \\

\tcode{<float.h>}			  &
\tcode{<setjmp.h>}			&
\tcode{<stdint.h>}			&
\tcode{<uchar.h>}			  & \\

\end{floattable}

\pnum
Every C header, each of which has a name of the form
\indextext{header!C}%
\tcode{name.h},
behaves as if each name placed in the standard library namespace by
the corresponding
\tcode{c\textit{name}}
header is placed within
the global namespace scope. It is unspecified whether these names are first declared or defined within
namespace scope~(\ref{basic.scope.namespace}) of the namespace
\tcode{std} and are then injected into the global namespace scope by
explicit \grammarterm{using-declaration}{s}~(\ref{namespace.udecl}).
\indextext{namespace}%

\pnum
\enterexample
The header
\indexlibrary{\idxhdr{cstdlib}}%
\indexlibrary{\idxhdr{stdlib.h}}%
\tcode{<cstdlib>} assuredly
provides its declarations and definitions within the namespace
\tcode{std}. It may also provide these names within the
global namespace.
The header
\tcode{<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 \tcode{std}.
\exitexample

\rSec1[depr.ios.members]{Old iostreams members}

\pnum
The following member names are in addition to names specified in
Clause~\ref{input.output}:

\begin{codeblock}
namespace std {
  class ios_base {
  public:
    typedef @\textit{T1}@ io_state;
    typedef @\textit{T2}@ open_mode;
    typedef @\textit{T3}@ seek_dir;
    typedef @\impdef@ streamoff;
    typedef @\impdef@ streampos;
    // remainder unchanged
  };
}
\end{codeblock}

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

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

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

\pnum
The type
\indexlibrary{\idxcode{streamoff}}%
\tcode{streamoff}
is an
\impldef{type of \tcode{ios_base::streamoff}} type
that satisfies the requirements of
off_type in~\ref{iostreams.limits.pos}.

\pnum
The type
\tcode{streampos}
is an
\impldef{type of \tcode{ios_base::streampos}} type
that satisfies the requirements of
pos_type in~\ref{iostreams.limits.pos}.

\pnum
An implementation may provide the following additional member function, which has the
effect of calling
\tcode{sbumpc()}~(\ref{streambuf.pub.get}):

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

\pnum
An implementation may provide the following member functions that overload signatures
specified in Clause~\ref{input.output}:

\begin{codeblock}
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
  };
}
\end{codeblock}

\pnum
The effects of these functions is to call the corresponding member function specified
in Clause~\ref{input.output}.

\rSec1[depr.str.strstreams]{\tcode{char*} streams}

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

\rSec2[depr.strstreambuf]{Class \tcode{strstreambuf}}

\indexlibrary{\idxcode{strstreambuf}}%
\begin{codeblock}
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;              // \expos
    static const strstate allocated;  //  \expos
    static const strstate constant;   // \expos
    static const strstate dynamic;    // \expos
    static const strstate frozen;     // \expos
    strstate strmode;                 // \expos
    streamsize alsize;                // \expos
    void* (*palloc)(size_t);          // \expos
    void (*pfree)(void*);             // \expos
  };
}
\end{codeblock}

\pnum
The class
\tcode{strstreambuf}
associates the input sequence, and possibly the output sequence, with an object of some
\textit{character}
array type, whose elements store arbitrary values.
The array object has several attributes.

\pnum
\enternote
For the sake of exposition, these are represented as elements of a bitmask type
(indicated here as \tcode{T1}) called \tcode{strstate}.
The elements are:
\begin{itemize}
\item
\tcode{allocated}, set when a dynamic array object has been
allocated, and hence should be freed by the destructor for the
\tcode{strstreambuf} object;
\item
\tcode{constant}, set when the array object has
\tcode{const} elements, so the output sequence cannot be written;
\item
\tcode{dynamic}, set when the array object is allocated
(or reallocated)
as necessary to hold a character sequence that can change in length;
\item
\tcode{frozen}, set when the program has requested that the
array object not be altered, reallocated, or freed.
\end{itemize}
\exitnote

\pnum
\enternote
For the sake of exposition, the maintained data is presented here as:
\begin{itemize}
\item
\tcode{strstate strmode}, the attributes of the array object
associated with the \tcode{strstreambuf} object;
\item
\tcode{int alsize}, the suggested minimum size for a
dynamic array object;
\item
\tcode{void* (*palloc)(size_t)}, points to the function
to call to allocate a dynamic array object;
\item
\tcode{void (*pfree)(void*)}, points to the function to
call to free a dynamic array object.
\end{itemize}
\exitnote

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

\rSec3[depr.strstreambuf.cons]{\tcode{strstreambuf} constructors}

\indexlibrary{\idxcode{strstreambuf}!\tcode{strstreambuf}}%
\begin{itemdecl}
explicit strstreambuf(streamsize alsize_arg = 0);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Constructs an object of class
\tcode{strstreambuf},
initializing the base class with
\tcode{streambuf()}.
The postconditions of this function are indicated in Table~\ref{tab:future.strstreambuf.effects}.
\end{itemdescr}

\begin{libtab2}{\tcode{strstreambuf(streamsize)} effects}{tab:future.strstreambuf.effects}
{ll}
{Element}{Value}
\tcode{strmode}	&	\tcode{dynamic}		\\
\tcode{alsize}	&	\tcode{alsize_arg}	\\
\tcode{palloc}	&	a null pointer		\\
\tcode{pfree}	&	a null pointer		\\
\end{libtab2}

\indexlibrary{\idxcode{strstreambuf}}%
\begin{itemdecl}
strstreambuf(void* (*palloc_arg)(size_t), void (*pfree_arg)(void*));
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Constructs an object of class
\tcode{strstreambuf},
initializing the base class with
\tcode{streambuf()}.
The postconditions of this function are indicated in Table~\ref{tab:future.strstreambuf1.effects}.

\begin{libtab2}{\tcode{strstreambuf(void* (*)(size_t), void (*)(void*))} effects}
{tab:future.strstreambuf1.effects}
{ll}
{Element}{Value}
\tcode{strmode}	&	\tcode{dynamic}			\\
\tcode{alsize}	&	an unspecified value	\\
\tcode{palloc}	&	\tcode{palloc_arg}		\\
\tcode{pfree}	&	\tcode{pfree_arg}		\\
\end{libtab2}
\end{itemdescr}

\indextext{unspecified}%
\begin{itemdecl}
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);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Constructs an object of class
\tcode{strstreambuf},
initializing the base class with
\tcode{streambuf()}.
The postconditions of this function are indicated in Table~\ref{tab:future.strstreambuf2.effects}.

\begin{libtab2}{\tcode{strstreambuf(charT*, streamsize, charT*)} effects}
{tab:future.strstreambuf2.effects}
{ll}
{Element}{Value}
\tcode{strmode}	&	0						\\
\tcode{alsize}	&	an unspecified value	\\
\tcode{palloc}	&	a null pointer			\\
\tcode{pfree}	&	a null pointer			\\
\end{libtab2}

\pnum
\tcode{gnext_arg} shall point to the first element of an array
object whose number of elements \tcode{N} is determined as follows:
\begin{itemize}
\item
If
\tcode{n > 0},
\tcode{N} is \tcode{n}.
\item
If
\tcode{n == 0},
\tcode{N} is
\tcode{std::strlen(gnext_arg)}.
\indexlibrary{\idxcode{strlen}}%
\item
If
\tcode{n < 0},
\tcode{N} is
\tcode{INT_MAX}.\footnote{The function signature
\tcode{strlen(const char*)}
is declared in
\tcode{<cstring>}.
\indexlibrary{\idxcode{strlen}}%
\indexlibrary{\idxhdr{cstring}}%
(\ref{c.strings}).
The macro
\tcode{INT_MAX}
is defined in
\tcode{<climits>}~(\ref{support.limits}).
\indexlibrary{\idxhdr{climits}}}
\end{itemize}

\pnum
If \tcode{pbeg_arg} is a null pointer, the function executes:

\indexlibrary{\idxcode{strstreambuf}!\idxcode{setg}}%
\indexlibrary{\idxcode{setg}!\idxcode{strstreambuf}}%
\begin{itemdecl}
setg(gnext_arg, gnext_arg, gnext_arg + N);
\end{itemdecl}

\pnum
Otherwise, the function executes:

\begin{codeblock}
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);
\end{codeblock}

\pnum
\effects
Behaves the same as
\tcode{strstreambuf((char*)gnext_arg,n)},
except that the constructor also sets \tcode{constant} in \tcode{strmode}.
\end{itemdescr}

\indexlibrary{\idxcode{strstreambuf}!destructor}%
\begin{itemdecl}
virtual ~strstreambuf();
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Destroys an object of class
\tcode{strstreambuf}.
The function frees the dynamically allocated array object only if
\tcode{strmode \& allocated != 0}
and
\tcode{strmode \& frozen == 0}.~(\ref{depr.strstreambuf.virtuals} describes how a dynamically allocated array object is freed.)
\end{itemdescr}

\rSec3[depr.strstreambuf.members]{Member functions}

\indexlibrary{\idxcode{freeze}!\idxcode{strstreambuf}}%
\begin{itemdecl}
void freeze(bool freezefl = true);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
If \tcode{strmode} \& \tcode{dynamic} is non-zero, alters the
freeze status of the dynamic array object as follows:
\begin{itemize}
\item
If \tcode{freezefl} is
\tcode{true},
the function sets \tcode{frozen} in \tcode{strmode}.
\item
Otherwise, it clears \tcode{frozen} in \tcode{strmode}.
\end{itemize}
\end{itemdescr}

\indexlibrary{\idxcode{str}!\idxcode{strstreambuf}}%
\begin{itemdecl}
char* str();
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Calls
\tcode{freeze()},
then returns the beginning pointer for the input sequence, \tcode{gbeg}.

\pnum
\notes
The return value can be a null pointer.
\end{itemdescr}

\indexlibrary{\idxcode{pcount}!\idxcode{strstreambuf}}%
\begin{itemdecl}
int pcount() const;
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
If the next pointer for the output sequence, \tcode{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, \tcode{pnext} - \tcode{pbeg}.
\end{itemdescr}

\rSec3[depr.strstreambuf.virtuals]{\tcode{strstreambuf} overridden virtual functions}

\indexlibrary{\idxcode{overflow}!\idxcode{strstreambuf}}%
\begin{itemdecl}
int_type overflow(int_type c = EOF);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Appends the character designated by \tcode{c} to the output
sequence, if possible, in one of two ways:
\begin{itemize}
\item
If
\tcode{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 \tcode{c} to
\tcode{*pnext++}.

\pnum
Returns
\tcode{(unsigned char)c}.
\item
If
\tcode{c == EOF},
there is no character to append.

\pnum
Returns a value other than \tcode{EOF}.
\end{itemize}

\pnum
Returns
\tcode{EOF}
to indicate failure.

\pnum
\notes
The function can alter the number of write positions available as a
result of any call.

\pnum
To make a write position available, the function reallocates
(or initially allocates)
an array object with a sufficient number of elements
\tcode{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.%
\indextext{unspecified}%
\footnote{An implementation should consider \tcode{alsize} in making this
decision.}
If \tcode{palloc} is not a null pointer, the function calls
\tcode{(*palloc)(n)}
to allocate the new dynamic array object.
Otherwise, it evaluates the expression
\tcode{new charT[n]}.
In either case, if the allocation fails, the function returns
\tcode{EOF}.
Otherwise, it sets \tcode{allocated} in \tcode{strmode}.

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

\pnum
If
\tcode{strmode \& dynamic == 0},
or if
\tcode{strmode \& frozen != 0},
the function cannot extend the array (reallocate it with greater length) to make a write position available.
\end{itemdescr}

\indexlibrary{\idxcode{pbackfail}!\idxcode{strstreambuf}}%
\begin{itemdecl}
int_type pbackfail(int_type c = EOF);
\end{itemdecl}

\begin{itemdescr}
\pnum
Puts back the character designated by \tcode{c} to the input
sequence, if possible, in one of three ways:
\begin{itemize}
\item
If
\tcode{c != EOF},
if the input sequence has a putback position available, and if
\tcode{(char)c == gnext[-1]},
assigns
\tcode{gnext - 1}
to \tcode{gnext}.

\pnum
Returns \tcode{c}.
\item
If
\tcode{c != EOF},
if the input sequence has a putback position available, and if
\tcode{strmode} \& \tcode{constant} is zero,
assigns \tcode{c} to
\tcode{*\dcr{}gnext}.

\pnum
Returns
\tcode{c}.
\item
If
\tcode{c == EOF}
and if the input sequence has a putback position available,
assigns
\tcode{gnext - 1}
to \tcode{gnext}.

\pnum
Returns a value other than
\tcode{EOF}.
\end{itemize}

\pnum
Returns
\tcode{EOF}
to indicate failure.

\pnum
\notes
If the function can succeed in more than one of these ways, it is
unspecified which way is chosen.
\indextext{unspecified}%
The function can alter the number of putback
positions available as a result of any call.
\end{itemdescr}

\indexlibrary{\idxcode{underflow}!\idxcode{strstreambuf}}%
\begin{itemdecl}
int_type underflow();
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Reads a character from the
\term{input sequence},
if possible, without moving the stream position past it, as follows:
\begin{itemize}
\item
If the input sequence has a read position available, the function
signals success by returning
\tcode{(unsigned char)\brk*gnext}.
\item
Otherwise, if
the current write next pointer \tcode{pnext} is not a null pointer and
is greater than the current read end pointer \tcode{gend},
makes a
\term{read position}
available by
assigning to \tcode{gend} a value greater than \tcode{gnext} and
no greater than \tcode{pnext}.

\pnum
Returns \tcode{(unsigned char*)gnext}.
\end{itemize}

\pnum
Returns
\tcode{EOF}
to indicate failure.

\pnum
\notes
The function can alter the number of read positions available as a
result of any call.
\end{itemdescr}

\indexlibrary{\idxcode{seekoff}!\idxcode{strstreambuf}}%
\begin{itemdecl}
pos_type seekoff(off_type off, seekdir way, openmode which = in | out);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Alters the stream position within one of the
controlled sequences, if possible, as indicated in Table~\ref{tab:future.seekoff.positioning}.

\begin{libtab2}{\tcode{seekoff} positioning}{tab:future.seekoff.positioning}
{p{2.5in}l}{Conditions}{Result}
\tcode{(which \& ios::in) != 0}	&
 positions the input sequence	\\ \rowsep
\tcode{(which \& ios::out) != 0}	&
 positions the output sequence	\\ \rowsep
\tcode{(which \& (ios::in |}\br
\tcode{ios::out)) == (ios::in |}\br
\tcode{ios::out))} and\br
\tcode{way ==} either\br
\tcode{ios::beg} or\br
\tcode{ios::end}			&
 positions both the input and the output sequences	\\ \rowsep
Otherwise	&
 the positioning operation fails.	\\
\end{libtab2}

\pnum
For a sequence to be positioned, if its next pointer is a null pointer,
the positioning operation fails.
Otherwise, the function determines \tcode{newoff} as indicated in
Table~\ref{tab:future.newoff.values}.

\begin{libtab2}{\tcode{newoff} values}{tab:future.newoff.values}
{p{2.0in}p{2.0in}}{Condition}{\tcode{newoff} Value}
\tcode{way == ios::beg}	&
 0	\\ \rowsep
\tcode{way == ios::cur}	&
 the next pointer minus the beginning pointer (\tcode{xnext - xbeg}).	\\ \rowsep
\tcode{way == ios::end}	&
 \tcode{seekhigh} minus the beginning pointer (\tcode{seekhigh - xbeg}).\\ \rowsep
If \tcode{(newoff + off) <}\br
\tcode{(seeklow - xbeg)},\br
or \tcode{(seekhigh - xbeg) <}\br
\tcode{(newoff + off)}			&
 the positioning operation fails	\\
\end{libtab2}

\pnum
Otherwise, the function assigns
\tcode{xbeg} + \tcode{newoff} + \tcode{off}
to the next pointer \tcode{xnext}.

\pnum
\returns
\tcode{pos_type(newoff)},
constructed from the resultant offset
\tcode{newoff} (of type
\tcode{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
\tcode{pos_type(off_type(-1))}.
\end{itemdescr}

\indexlibrary{\idxcode{seekpos}!\idxcode{strstreambuf}}%
\begin{itemdecl}
pos_type seekpos(pos_type sp, ios_base::openmode which
                  = ios_base::in | ios_base::out);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Alters the stream position within one of the
controlled sequences, if possible, to correspond to the
stream position stored in \tcode{sp}
(as described below).
\begin{itemize}
\item
If
\tcode{(which \& ios::in) != 0},
positions the input sequence.
\item
If
\tcode{(which \& ios::out) != 0},
positions the output sequence.
\item
If the function positions neither sequence, the positioning operation fails.

\pnum
For a sequence to be positioned, if its next pointer is a null pointer,
the positioning operation fails.
Otherwise, the function determines \tcode{newoff} from
\tcode{sp.offset()}:
\item
If \tcode{newoff} is an invalid stream position,
has a negative value, or
has a value greater than (\tcode{seekhigh} - \tcode{seeklow}),
the positioning operation fails
\item
Otherwise, the function
adds \tcode{newoff} to the beginning pointer \tcode{xbeg} and
stores the result in the next pointer \tcode{xnext}.
\end{itemize}

\pnum
\returns
\tcode{pos_type(newoff)},
constructed from the resultant offset \tcode{newoff}
(of type
\tcode{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
\tcode{pos_type(off_type(-1))}.
\end{itemdescr}

\indexlibrary{\idxcode{setbuf}!\idxcode{strstreambuf}}%
\begin{itemdecl}
streambuf<char>* setbuf(char* s, streamsize n);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Implementation defined, except that
\tcode{setbuf(0, 0)}
has no effect.%
\indexlibrary{\idxcode{setbuf}!\idxcode{streambuf}}
\end{itemdescr}

\rSec2[depr.istrstream]{Class \tcode{istrstream}}

\indexlibrary{\idxcode{istrstream}}%
\begin{codeblock}
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;  // \expos
  };
}
\end{codeblock}

\pnum
The class
\tcode{istrstream}
supports the reading of objects of class
\tcode{strstreambuf}.
It supplies a
\tcode{strstreambuf}
object to control the associated array object.
For the sake of exposition, the maintained data is presented here as:
\begin{itemize}
\item
\tcode{sb}, the \tcode{strstreambuf} object.
\end{itemize}

\rSec3[depr.istrstream.cons]{\tcode{istrstream} constructors}

\indexlibrary{\idxcode{istrstream}!\idxcode{istrstream}}%
\begin{itemdecl}
explicit istrstream(const char* s);
explicit istrstream(char* s);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Constructs an object of class
\tcode{istrstream},
initializing the base class with
\tcode{istream(\&sb)}
and initializing \tcode{sb} with
\tcode{strstreambuf(s,0))}.
\tcode{s} shall designate the first element of an \ntbs.%
\indextext{NTBS}
\end{itemdescr}

\indexlibrary{\idxcode{istrstream}!constructor}%
\begin{itemdecl}
istrstream(const char* s, streamsize n);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Constructs an object of class
\tcode{istrstream},
initializing the base class with
\tcode{istream(\&sb)}
and initializing \tcode{sb} with
\tcode{strstreambuf(s,n))}.
\tcode{s} shall designate the first element of an array whose length is
\tcode{n} elements, and \tcode{n} shall be greater than zero.
\end{itemdescr}

\rSec3[depr.istrstream.members]{Member functions}

\indexlibrary{\idxcode{rdbuf}!\idxcode{istrstream}}%
\begin{itemdecl}
strstreambuf* rdbuf() const;
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns
\tcode{const_cast<strstreambuf*>(\&sb)}.
\end{itemdescr}

\indexlibrary{\idxcode{str}!\idxcode{istrstream}}%
\begin{itemdecl}
char* str();
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns
\tcode{rdbuf()->str()}.
\end{itemdescr}

\rSec2[depr.ostrstream]{Class \tcode{ostrstream}}

\indexlibrary{\idxcode{ostrstream}}%
\begin{codeblock}
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;  // \expos
  };
}
\end{codeblock}

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

\begin{itemize}
\item
\tcode{sb}, the \tcode{strstreambuf} object.
\end{itemize}

\rSec3[depr.ostrstream.cons]{\tcode{ostrstream} constructors}

\indexlibrary{\idxcode{ostrstream}!\idxcode{ostrstream}}%
\begin{itemdecl}
    ostrstream();
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Constructs an object of class
\tcode{ostrstream},
initializing the base class with
\tcode{ostream(\&sb)}
and initializing \tcode{sb} with
\tcode{strstreambuf())}.
\end{itemdescr}

\indexlibrary{\idxcode{ostrstream}!constructor}%
\begin{itemdecl}
ostrstream(char* s, int n, ios_base::openmode mode = ios_base::out);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Constructs an object of class
\tcode{ostrstream},
initializing the base class with
\tcode{ostream(\&sb)},
and initializing \tcode{sb} with one of two constructors:

\begin{itemize}
\item
If
\tcode{(mode \& app) == 0},
then \tcode{s} shall designate the first element of an array of \tcode{n} elements.

The constructor is
\tcode{strstreambuf(s, n, s)}.
\item
If
\tcode{(mode \& app) != 0},
then \tcode{s} shall designate the first element of an array of \tcode{n} elements that
contains an \ntbs whose first element is designated by \tcode{s}.
\indextext{NTBS}%
The constructor is
\tcode{strstreambuf(s, n, s + std::strlen(s))}.\footnote{The function signature
\tcode{strlen(const char*)}
is declared in
\tcode{<cstring>}
\indexlibrary{\idxcode{strlen}}%
\indexlibrary{\idxhdr{cstring}}%
(\ref{c.strings}).}
\end{itemize}
\end{itemdescr}

\rSec3[depr.ostrstream.members]{Member functions}

\indexlibrary{\idxcode{rdbuf}!\idxcode{ostrstream}}%
\begin{itemdecl}
strstreambuf* rdbuf() const;
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns
\tcode{(strstreambuf*)\&sb }.
\end{itemdescr}

\indexlibrary{\idxcode{freeze}!\idxcode{ostrstream}}%
\begin{itemdecl}
void freeze(bool freezefl = true);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Calls
\tcode{rdbuf()->freeze(freezefl)}.
\end{itemdescr}

\indexlibrary{\idxcode{str}!\idxcode{ostrstream}}%
\begin{itemdecl}
char* str();
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns
\tcode{rdbuf()->str()}.
\end{itemdescr}

\indexlibrary{\idxcode{pcount}!\idxcode{ostrstream}}%
\begin{itemdecl}
int pcount() const;
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns
\tcode{rdbuf()->pcount()}.
\end{itemdescr}

\rSec2[depr.strstream]{Class \tcode{strstream}}

\indexlibrary{\idxcode{strstream}}%
\begin{codeblock}
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;  // \expos
  };
}
\end{codeblock}

\pnum
The class
\tcode{strstream}
supports reading and writing from objects of classs
\tcode{strstreambuf.}
It supplies a
\tcode{strstreambuf}
object to control the associated array object.
For the sake of exposition, the maintained data is presented here as
\begin{itemize}
\item
\tcode{sb}, the
\tcode{strstreambuf}
object.
\end{itemize}

\rSec3[depr.strstream.cons]{\tcode{strstream} constructors}

\indexlibrary{\idxcode{strstream}!\idxcode{strstream}}%
\begin{itemdecl}
strstream();
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Constructs an object of class
\tcode{strstream},
initializing the base class with
\tcode{iostream(\&sb)}.
\end{itemdescr}

\indexlibrary{\idxcode{strstream}!\idxcode{strstream}}%
\begin{itemdecl}
strstream(char* s, int n,
          ios_base::openmode mode = ios_base::in|ios_base::out);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Constructs an object of class
\tcode{strstream},
initializing the base class with
\tcode{iostream(\&sb)}
and initializing \tcode{sb} with one of the two constructors:
\begin{itemize}
\item
If
\tcode{(mode \& app) == 0},
then \tcode{s} shall designate the first element of an array of \tcode{n} elements.
The constructor is
\tcode{strstreambuf(s,n,s)}.
\item
If
\tcode{(mode \& app) != 0},
then \tcode{s} shall
designate the first element of an array of \tcode{n} elements that contains
an \ntbs whose first element is designated by \tcode{s}.
The constructor is
\tcode{strstreambuf(s,n,s + std::strlen(s))}.
\indexlibrary{\idxcode{strstream}!destructor}%
\end{itemize}
\end{itemdescr}

\rSec3[depr.strstream.dest]{\tcode{strstream} destructor}

\indexlibrary{\idxcode{strstream}!destructor}%
\begin{itemdecl}
virtual ~strstream()
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Destroys an object of class
\tcode{strstream}.
\end{itemdescr}

\indexlibrary{\idxcode{rdbuf}!\idxcode{strstream}}%
\begin{itemdecl}
strstreambuf* rdbuf() const;
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns
\tcode{\&sb}.
\end{itemdescr}

\rSec3[depr.strstream.oper]{\tcode{strstream} operations}

\indexlibrary{\idxcode{freeze}!\idxcode{strstream}}%
\begin{itemdecl}
void freeze(bool freezefl = true);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Calls
\tcode{rdbuf()->freeze(freezefl)}.
\end{itemdescr}

\indexlibrary{\idxcode{str}!\idxcode{strstream}}%
\begin{itemdecl}
char* str();
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns
\tcode{rdbuf()->str()}.
\end{itemdescr}

\indexlibrary{\idxcode{pcount}!\idxcode{strstream}}%
\begin{itemdecl}
int pcount() const;
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns
\tcode{rdbuf()->pcount()}.
\end{itemdescr}

\rSec1[depr.function.objects]{Function objects}

\rSec2[depr.base]{Base}

\pnum
The class templates \tcode{unary_function} and \tcode{binary_function} are deprecated.
A program shall not declare specializations of these templates.

\indexlibrary{\idxcode{unary_function}}%
\begin{codeblock}
namespace std {
  template <class Arg, class Result>
  struct unary_function {
    typedef Arg    argument_type;
    typedef Result result_type;
  };
}
\end{codeblock}

\indexlibrary{\idxcode{binary_function}}%
\begin{codeblock}
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;
  };
}
\end{codeblock}

\rSec2[depr.adaptors]{Function adaptors}

\pnum
The adaptors ptr_fun, mem_fun, mem_fun_ref, and their corresponding return types
are deprecated. \enternote The function template \tcode{bind}~\ref{func.bind} provides
a better solution. \exitnote

\rSec3[depr.function.pointer.adaptors]{Adaptors for pointers to functions}

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

\indexlibrary{\idxcode{pointer_to_unary_function}}%
\begin{itemdecl}
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;
};
\end{itemdecl}

\begin{itemdescr}
\pnum
\tcode{operator()} returns \tcode{f(x)}.
\end{itemdescr}

\indexlibrary{\idxcode{ptr_fun}}%
\begin{itemdecl}
template <class Arg, class Result>
  pointer_to_unary_function<Arg, Result> ptr_fun(Result (*f)(Arg));
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns
\tcode{pointer_to_unary_function<Arg, Result>(f)}.
\end{itemdescr}

\indexlibrary{\idxcode{pointer_to_binary_function}}%
\begin{itemdecl}
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;
};
\end{itemdecl}

\begin{itemdescr}
\pnum
\tcode{operator()} returns \tcode{f(x,y)}.
\end{itemdescr}

\indexlibrary{\idxcode{ptr_fun}}%
\begin{itemdecl}
template <class Arg1, class Arg2, class Result>
  pointer_to_binary_function<Arg1,Arg2,Result>
    ptr_fun(Result (*f)(Arg1, Arg2));
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns
\tcode{pointer_to_binary_function<Arg1,Arg2,Result>(f)}.

\pnum
\enterexample
\begin{codeblock}
int compare(const char*, const char*);
replace_if(v.begin(), v.end(),
  not1(bind2nd(ptr_fun(compare), "abc")), "def");
\end{codeblock}

replaces each \tcode{abc} with \tcode{def} in sequence \tcode{v}.
\exitexample
\end{itemdescr}

\rSec3[depr.member.pointer.adaptors]{Adaptors for pointers to members}

\pnum
The purpose of the following is to provide the same facilities for pointer to
members as those provided for pointers to functions
in~\ref{depr.function.pointer.adaptors}.

\indexlibrary{\idxcode{mem_fun_t}}%
\begin{itemdecl}
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;
};
\end{itemdecl}

\begin{itemdescr}
\pnum
\tcode{mem_fun_t} calls the member function it is initialized with given a pointer
argument.
\end{itemdescr}

\indexlibrary{\idxcode{mem_fun1_t}}%
\begin{itemdecl}
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;
};
\end{itemdecl}

\begin{itemdescr}
\pnum
\tcode{mem_fun1_t} calls the member function it is initialized with given
a pointer argument and an additional argument of the appropriate type.
\end{itemdescr}

\indexlibrary{\idxcode{mem_fun}}%
\begin{itemdecl}
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));
\end{itemdecl}

\begin{itemdescr}
\pnum
\tcode{mem_fun(\&X::f)} returns an object through which \tcode{X::f} can be
called given a pointer to an \tcode{X} followed by the argument required for
\tcode{f} (if any).
\end{itemdescr}

\indexlibrary{\idxcode{mem_fun_ref_t}}%
\begin{itemdecl}
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;
};
\end{itemdecl}

\begin{itemdescr}
\pnum
\tcode{mem_fun_ref_t} calls the member function it is initialized with given
a reference argument.
\end{itemdescr}

\indexlibrary{\idxcode{mem_fun1_ref_t}}%
\begin{itemdecl}
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;
};
\end{itemdecl}

\begin{itemdescr}
\pnum
\tcode{mem_fun1_ref_t} calls the member function it is initialized with
given a reference argument and an additional argument of the appropriate type.
\end{itemdescr}

\indexlibrary{\idxcode{mem_fun_ref}}%
\begin{itemdecl}
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));
\end{itemdecl}

\begin{itemdescr}
\pnum
\tcode{mem_fun_ref(\&X::f)} returns an object through which \tcode{X::f}
can be called given a reference to an \tcode{X} followed by the argument
required for \tcode{f} (if any).
\end{itemdescr}

\indexlibrary{\idxcode{const_mem_fun_t}}%
\begin{itemdecl}
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;
};
\end{itemdecl}

\begin{itemdescr}
\pnum
\tcode{const_mem_fun_t} calls the member function it is initialized with
given a pointer argument.
\end{itemdescr}

\indexlibrary{\idxcode{const_mem_fun1_t}}%
\begin{itemdecl}
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;
};
\end{itemdecl}

\begin{itemdescr}
\pnum
\tcode{const_mem_fun1_t} calls the member function it is initialized with
given a pointer argument and an additional argument of the appropriate type.
\end{itemdescr}

\indexlibrary{\idxcode{mem_fun}}%
\begin{itemdecl}
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);
\end{itemdecl}

\begin{itemdescr}
\pnum
\tcode{mem_fun(\&X::f)} returns an object through which \tcode{X::f} can be
called given a pointer to an \tcode{X} followed by the argument required for
\tcode{f} (if any).
\end{itemdescr}

\indexlibrary{\idxcode{const_mem_fun_ref_t}}%
\begin{itemdecl}
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;
};
\end{itemdecl}

\begin{itemdescr}
\pnum
\tcode{const_mem_fun_ref_t} calls the member function it is initialized with
given a reference argument.
\end{itemdescr}

\indexlibrary{\idxcode{const_mem_fun1_ref_t}}%
\begin{itemdecl}
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;
};
\end{itemdecl}

\begin{itemdescr}
\pnum
\tcode{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.
\end{itemdescr}

\indexlibrary{\idxcode{mem_fun_ref}}%
\begin{itemdecl}
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);
\end{itemdecl}

\begin{itemdescr}
\pnum
\tcode{mem_fun_ref(\&X::f)} returns an object through which \tcode{X::f}
can be called given a reference to an \tcode{X} followed by the argument
required for \tcode{f} (if any).
\end{itemdescr}

\rSec1[depr.lib.binders]{Binders}

The binders \tcode{binder1st}, \tcode{bind1st},
\tcode{binder2nd}, and \tcode{bind2nd} are deprecated.
\enternote The function template
\tcode{bind}~(\ref{bind}) provides a better
solution.\exitnote

\rSec2[depr.lib.binder.1st]{Class template \tcode{binder1st}}

\indexlibrary{\idxcode{binder1st}}%
\begin{itemdecl}
  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;
  };
\end{itemdecl}

\begin{itemdescr}
\pnum
The constructor initializes \tcode{op} with \tcode{x} and \tcode{value}
with \tcode{y}.

\pnum
\tcode{operator()} returns \tcode{op}\tcode{(value,x)}.
\end{itemdescr}

\rSec2[depr.lib.bind.1st]{\tcode{bind1st}}

\indexlibrary{\idxcode{bind1st}}%
\begin{itemdecl}
template <class Fn, class T>
  binder1st<Fn> bind1st(const Fn& fn, const T& x);
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns
\tcode{binder1st<Fn>(fn, typename Fn::first_argument_type(x))}.
\end{itemdescr}

\rSec2[depr.lib.binder.2nd]{Class template \tcode{binder2nd}}

\indexlibrary{\idxcode{binder2nd}}%
\begin{itemdecl}
  template <class Fn>
  class binder2nd
    : public unary_function<typename Fn::first_argument_type,
                            typename Fn::result_type> {
  protected:
    Fn                       @\tcode{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;
  };
\end{itemdecl}

\begin{itemdescr}
\pnum
The constructor initializes \tcode{op} with \tcode{x} and \tcode{value}
with \tcode{y}.

\pnum
\tcode{operator()} returns \tcode{op}\tcode{(x,value)}.
\end{itemdescr}

\rSec2[depr.lib.bind.2nd]{\tcode{bind2nd}}

\indexlibrary{\idxcode{bind2nd}}%
\begin{itemdecl}
template <class Fn, class T>
  binder2nd<Fn> bind2nd(const Fn& op, const T& x);
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns
\tcode{binder2nd<Fn>(op, typename Fn::second_argument_type(x))}.

\pnum
\enterexample
\begin{codeblock}
find_if(v.begin(), v.end(), bind2nd(greater<int>(), 5));
\end{codeblock}

finds the first integer in vector \tcode{v} greater than 5;

\begin{codeblock}
find_if(v.begin(), v.end(), bind1st(greater<int>(), 5));
\end{codeblock}

finds the first integer in \tcode{v} less than 5.
\exitexample
\end{itemdescr}

\rSec1[depr.auto.ptr]{\tcode{auto_ptr}}

The class template \tcode{auto_ptr} is deprecated.
\enternote The class template
\tcode{unique_ptr}~(\ref{unique.ptr}) provides a better
solution. \exitnote

\rSec2[auto.ptr]{Class template \tcode{auto_ptr}}

\pnum
\indexlibrary{\idxcode{auto_ptr}}%
The class template \tcode{auto_ptr} stores a pointer to an object obtained via \tcode{new}
and deletes that object when it itself is destroyed (such as when leaving block
scope~\ref{stmt.dcl}).

\pnum
The class template
\tcode{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 \tcode{auto_ptr}. It
is used by the \tcode{auto_ptr} conversions to allow \tcode{auto_ptr} objects
to be passed to and returned from functions.

\begin{codeblock}
namespace std {
  template <class Y> struct auto_ptr_ref;   // \expos

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

    // \ref{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();

    // \ref{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();

    // \ref{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;
  };
}
\end{codeblock}

\pnum
The class template \tcode{auto_ptr} provides a semantics of strict ownership. An \tcode{auto_ptr}
owns the object it holds a pointer to. Copying an \tcode{auto_ptr} copies the
pointer and transfers ownership to the destination. If more than one
\tcode{auto_ptr} owns the same object at the same time the behavior of the
program is undefined.
\enternote 
The uses of \tcode{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 \tcode{auto_ptr} meet the requirements of \tcode{MoveConstructible} and \tcode{MoveAssignable}, but do not meet the requirements of \tcode{CopyConstructible} and \tcode{CopyAssignable}.
\exitnote

\rSec3[auto.ptr.cons]{\tcode{auto_ptr} constructors}

\indexlibrary{\idxcode{auto_ptr}!\idxcode{auto_ptr}}%
\begin{itemdecl}
explicit auto_ptr(X* p =0) throw();
\end{itemdecl}

\begin{itemdescr}
\pnum
\postconditions
\tcode{*this} holds the pointer \tcode{p}.
\end{itemdescr}

\indexlibrary{\idxcode{auto_ptr}!constructor}%
\begin{itemdecl}
auto_ptr(auto_ptr& a) throw();
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Calls \tcode{a.release()}.

\pnum
\postconditions
\tcode{*this} holds the pointer returned from \tcode{a.release()}.
\end{itemdescr}

\indexlibrary{\idxcode{auto_ptr}!constructor}%
\begin{itemdecl}
template<class Y> auto_ptr(auto_ptr<Y>& a) throw();
\end{itemdecl}

\begin{itemdescr}
\pnum
\requires
\tcode{Y*} can be implicitly converted to \tcode{X*}.

\pnum
\effects
Calls \tcode{a.release()}.

\pnum
\postconditions
\tcode{*this} holds the pointer returned from \tcode{a.release()}.
\end{itemdescr}

\indexlibrary{\idxcode{operator=}!\idxcode{auto_ptr}}%
\begin{itemdecl}
auto_ptr& operator=(auto_ptr& a) throw();
\end{itemdecl}

\begin{itemdescr}
\pnum
\requires
The expression \tcode{delete get()} is well formed.

\pnum
\effects
\tcode{reset(a.release())}.

\pnum
\returns
\tcode{*this}.
\end{itemdescr}

\indexlibrary{\idxcode{auto_ptr}!\idxcode{operator=}}%
\indexlibrary{\idxcode{operator=}!\idxcode{auto_ptr}}%
\begin{itemdecl}
template<class Y> auto_ptr& operator=(auto_ptr<Y>& a) throw();
\end{itemdecl}

\begin{itemdescr}
\pnum
\requires
\tcode{Y*} can be implicitly converted to \tcode{X*}. The expression
\tcode{delete get()} is well formed.

\pnum
\effects
\tcode{reset(a.release())}.

\pnum
\returns
\tcode{*this}.
\end{itemdescr}

\indexlibrary{\idxcode{auto_ptr}!destructor}%
\begin{itemdecl}
~auto_ptr() throw();
\end{itemdecl}

\begin{itemdescr}
\pnum
\requires
The expression \tcode{delete get()} is well formed.

\pnum
\effects
\tcode{delete get()}.
\end{itemdescr}

\rSec3[auto.ptr.members]{\tcode{auto_ptr} members}

\indexlibrary{\idxcode{operator*}!\idxcode{auto_ptr}}%
\begin{itemdecl}
X& operator*() const throw();
\end{itemdecl}

\begin{itemdescr}
\pnum
\requires
\tcode{get() != 0}

\pnum
\returns
\tcode{*get()}
\end{itemdescr}

\indexlibrary{\idxcode{operator->}!\idxcode{auto_ptr}}%
\begin{itemdecl}
X* operator->() const throw();
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns
\tcode{get()}
\end{itemdescr}

\indexlibrary{\idxcode{get}!\idxcode{auto_ptr}}%
\begin{itemdecl}
X* get() const throw();
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns
The pointer \tcode{*this} holds.
\end{itemdescr}

\indexlibrary{\idxcode{release}!\idxcode{auto_ptr}}%
\begin{itemdecl}
X* release() throw();
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns
\tcode{get()}

\pnum
\postcondition
\tcode{*this} holds the null pointer.
\end{itemdescr}

\indexlibrary{\idxcode{reset}!\idxcode{auto_ptr}}%
\begin{itemdecl}
void reset(X* p=0) throw();
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
If \tcode{get() != p} then \tcode{delete get()}.

\pnum
\postconditions
\tcode{*this} holds the pointer \tcode{p}.
\end{itemdescr}

\rSec3[auto.ptr.conv]{\tcode{auto_ptr} conversions}

\indexlibrary{\idxcode{auto_ptr}!constructor}%
\begin{itemdecl}
auto_ptr(auto_ptr_ref<X> r) throw();
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Calls \tcode{p.release()} for the \tcode{auto_ptr} \tcode{p} that \tcode{r} holds.

\pnum
\postconditions
\tcode{*this} holds the pointer returned from \tcode{release()}.
\end{itemdescr}

\indexlibrary{\idxcode{auto_ptr}!\idxcode{auto_ptr_ref}}%
\indexlibrary{\idxcode{auto_ptr_ref}!\idxcode{auto_ptr}}%
\begin{itemdecl}
template<class Y> operator auto_ptr_ref<Y>() throw();
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns
An \tcode{auto_ptr_ref<Y>} that holds \tcode{*this}.
\end{itemdescr}

\indexlibrary{\idxcode{auto_ptr_ref}!\idxcode{operator auto_ptr}}%
\indexlibrary{\idxcode{operator auto_ptr}!\idxcode{auto_ptr_ref}}%
\begin{itemdecl}
template<class Y> operator auto_ptr<Y>() throw();
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Calls \tcode{release()}.

\pnum
\returns
An \tcode{auto_ptr<Y>} that holds the pointer returned from \tcode{release()}.
\end{itemdescr}

\indexlibrary{\idxcode{auto_ptr_ref}!\idxcode{operator=}}%
\indexlibrary{\idxcode{operator=}!\idxcode{auto_ptr_ref}}%
\begin{itemdecl}
auto_ptr& operator=(auto_ptr_ref<X> r) throw()
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Calls \tcode{reset(p.release())} for the \tcode{auto_ptr p}
that \tcode{r} holds a reference to.

\pnum
\returns
\tcode{*this}
\end{itemdescr}

\rSec1[exception.unexpected]{Violating \grammarterm{exception-specification}{s}}

\rSec2[unexpected.handler]{Type \tcode{unexpected_handler}}

\indexlibrary{\idxcode{unexpected_handler}}%
\begin{itemdecl}
typedef void (*unexpected_handler)();
\end{itemdecl}

\begin{itemdescr}
\pnum
The type of a
\term{handler function}
to be called by
\tcode{unexpected()}
when a function attempts to throw an exception not listed in its
\grammarterm{dynamic-exception-specification}.

\pnum
\required
An
\tcode{unexpected_handler}
shall not return.
See also~\ref{except.unexpected}.

\pnum
\default
The implementation's default \tcode{unexpected_handler} calls
\tcode{std::terminate()}.
\indexlibrary{\idxcode{terminate}}
\end{itemdescr}

\rSec2[set.unexpected]{\tcode{set_unexpected}}

\indexlibrary{\idxcode{set_unexpected}}%
\begin{itemdecl}
unexpected_handler set_unexpected(unexpected_handler f) noexcept;
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Establishes the function designated by \tcode{f} as the current
\tcode{unexpected_handler}.

\pnum
\remark It is unspecified whether a null pointer value designates the default
\tcode{unexpected_handler}.

\pnum
\returns
The previous \tcode{unexpected_handler}.
\end{itemdescr}

\rSec2[get.unexpected]{\tcode{get_unexpected}}

\begin{itemdecl}
unexpected_handler get_unexpected() noexcept;
\end{itemdecl}

\begin{itemdescr}
\pnum
\returns The current \tcode{unexpected_handler}.
\enternote This may be a null pointer value. \exitnote
\end{itemdescr}

\rSec2[unexpected]{\tcode{unexpected}}

\indexlibrary{\idxcode{unexpected}}%
\begin{itemdecl}
[[noreturn]] void unexpected();
\end{itemdecl}

\begin{itemdescr}
\pnum
\remarks
Called by the implementation when a function exits via an exception not allowed by its
\grammarterm{exception-specification}~(\ref{except.unexpected}), in
effect after evaluating the throw-expression~(\ref{unexpected.handler}).
May also be called directly by the program.

\pnum
\effects
Calls the current \tcode{unexpected_handler} function.
\enternote A default \tcode{unexpected_handler} is always considered a callable handler in
this context. \exitnote
\end{itemdescr}

\rSec1[depr.alg.random.shuffle]{Random shuffle}

\indexlibrary{\idxcode{random_shuffle}}%
The function templates \tcode{random_shuffle} are deprecated.

\begin{itemdecl}
template<class RandomAccessIterator>
  void random_shuffle(RandomAccessIterator first,
                      RandomAccessIterator last);

template<class RandomAccessIterator, class RandomNumberGenerator>
  void random_shuffle(RandomAccessIterator first,
                      RandomAccessIterator last,
                      RandomNumberGenerator&& rng);
\end{itemdecl}

\begin{itemdescr}
\pnum
\effects
Permutes the elements in the range
\range{first}{last}
such that each possible permutation of those elements has equal probability of appearance.

\pnum
\requires
\tcode{RandomAccessIterator} shall satisfy the requirements of
\tcode{ValueSwappable}~(\ref{swappable.requirements}). The random number
generating function object \tcode{rng} shall have a return type that is
convertible to \tcode{iterator_traits<RandomAccessItera\-tor>::difference_type},
and the call \tcode{rng(n)} shall return a randomly chosen value in the
interval \range{0}{n}, for \tcode{n > 0} of type
\tcode{iterator_traits<Random\-Access\-Itera\-tor>::\-difference_type}.

\pnum
\complexity
Exactly
\tcode{(last - first) - 1}
swaps.

\pnum
\notes
To the extent that the implementation of these functions makes use of random numbers, the implementation shall use the following sources of randomness:

The underlying source of random numbers for the first form of the function
is \impldef{underlying source of random numbers for \tcode{random_shuffle}}. An implementation may use the
\tcode{rand}
function from the standard C library.

In the second form of the function, the
 function object
\tcode{rng} shall serve as the implementation's source of randomness.

\end{itemdescr}
