Boost logo

Boost-Commit :

From: dgregor_at_[hidden]
Date: 2008-03-03 15:03:09


Author: dgregor
Date: 2008-03-03 15:03:07 EST (Mon, 03 Mar 2008)
New Revision: 43480
URL: http://svn.boost.org/trac/boost/changeset/43480

Log:
Add LaTeX sources for the concepts library wording
Added:
   sandbox/committee/concepts/stdlib/
   sandbox/committee/concepts/stdlib/Makefile (contents, props changed)
   sandbox/committee/concepts/stdlib/clib-algorithms.tex (contents, props changed)
   sandbox/committee/concepts/stdlib/clib-concepts.tex (contents, props changed)
   sandbox/committee/concepts/stdlib/clib-containers.tex (contents, props changed)
   sandbox/committee/concepts/stdlib/clib-intro.tex (contents, props changed)
   sandbox/committee/concepts/stdlib/clib-iterators.tex (contents, props changed)
   sandbox/committee/concepts/stdlib/clib-numerics.tex (contents, props changed)
   sandbox/committee/concepts/stdlib/clib-utilities.tex (contents, props changed)
   sandbox/committee/concepts/stdlib/macros.tex (contents, props changed)
   sandbox/committee/concepts/stdlib/refbib.sty (contents, props changed)
Text files modified:
   sandbox/committee/concepts/README.txt | 1 +
   1 files changed, 1 insertions(+), 0 deletions(-)

Modified: sandbox/committee/concepts/README.txt
==============================================================================
--- sandbox/committee/concepts/README.txt (original)
+++ sandbox/committee/concepts/README.txt 2008-03-03 15:03:07 EST (Mon, 03 Mar 2008)
@@ -13,6 +13,7 @@
 
   wording/ LaTeX sources for the concepts language wording.
 
+ stdllib/ LaTeX sources for the concepts library wording.
 
 The list of all specification issues for the concepts proposals is
 available at

Added: sandbox/committee/concepts/stdlib/Makefile
==============================================================================
--- (empty file)
+++ sandbox/committee/concepts/stdlib/Makefile 2008-03-03 15:03:07 EST (Mon, 03 Mar 2008)
@@ -0,0 +1,90 @@
+# -*- makefile -*-
+
+LATEX = latex
+PDFLATEX = pdflatex
+
+
+DVIPS = dvips
+
+.SUFFIXES: .tex .dvi .ps .pdf .dot .eps
+
+
+.tex.dvi:
+ @ if test ! -f $*.ind; then echo "" > $*.ind; fi
+ @ $(LATEX) $*
+ @ if ( grep 'Writing index file' $*.log > /dev/null ); \
+ then makeindex $* ; $(LATEX) $* ; fi
+ @ if ( grep 'LaTeX Warning: Label(s) may' $*.log > /dev/null ); \
+ then $(LATEX) $* ; fi
+ @ if ( grep 'LaTeX Warning: Citation' $*.log > /dev/null ); \
+ then bibtex $* ; $(LATEX) $* ; fi
+ @ if ( grep 'LaTeX Warning: Label(s) may' $*.log > /dev/null ); \
+ then $(LATEX) $* ; fi
+ @ if ( grep 'LaTeX Warning: Label(s) may' $*.log > /dev/null ); \
+ then $(LATEX) $* ; fi
+ @ if ( grep 'LaTeX Warning: Label(s) may' $*.log > /dev/null ); \
+ then $(LATEX) $* ; fi
+
+.dot.eps:
+ dot -Tps $*.dot > $*.eps
+
+# .dot.eps:
+# dot -Tps $*.dot | sed 's/^endpage/%endpage/' > $*.tmp.ps
+# ps2epsi $*.tmp.ps $*.eps
+# /bin/rm $*.tmp.ps
+
+.dvi.ps:
+ $(DVIPS) -t letter -P cmz -o $*.ps $*
+
+.eps.pdf:
+ epstopdf $*.eps
+
+.tex.pdf:
+ @$(PDFLATEX) $*
+ @if ( grep 'LaTeX Warning: Label(s) may' $*.log > /dev/null ); \
+ then $(PDFLATEX) $* ; else :; fi
+ @ if ( grep 'Writing index file' $*.log > /dev/null ); \
+ then makeindex $* ; $(PDFLATEX) $* ; fi
+ @-if ( grep 'LaTeX Warning: Citation' $*.log > /dev/null ); then \
+ bibtex $* ; \
+ $(PDFLATEX) $* ; \
+ fi
+ @if ( grep 'LaTeX Warning: Label(s) may' $*.log > /dev/null || \
+ grep 'LaTeX Warning: Citation' $*.log > /dev/null); \
+ then $(PDFLATEX) $* ; else :; fi
+ @if ( grep 'LaTeX Warning: Label(s) may' $*.log > /dev/null || \
+ grep 'LaTeX Warning: Citation' $*.log > /dev/null); \
+ then $(PDFLATEX) $* ; else :; fi
+ @if ( grep 'LaTeX Warning: Label(s) may' $*.log > /dev/null || \
+ grep 'LaTeX Warning: Citation' $*.log > /dev/null); \
+ then $(PDFLATEX) $* ; else :; fi
+
+
+#
+# Default rule
+#
+NAMES = clib-intro clib-utilities clib-containers \
+ clib-iterators clib-algorithms clib-numerics clib-concepts
+
+OTHER_TEX = macros.tex
+
+PDF_FIGS =
+
+default: $(NAMES:%=%.pdf)
+
+
+DOT =
+
+DPS = $(DOT:.dot=.ps)
+DEPS = $(DOT:.dot=.eps)
+DPDF = $(DOT:.dot=.pdf)
+
+#
+# Standard rules
+#
+clean:
+ /bin/rm -f *.dvi *.log *.blg *.bbl *.ind *.aux *.toc *lof *.lot *-speedup.txt \
+ $(NAMES:%=%.ps) $(NAMES:%=%.pdf) *.pdfsync *.out
+
+squeaky: clean
+

Added: sandbox/committee/concepts/stdlib/clib-algorithms.tex
==============================================================================
--- (empty file)
+++ sandbox/committee/concepts/stdlib/clib-algorithms.tex 2008-03-03 15:03:07 EST (Mon, 03 Mar 2008)
@@ -0,0 +1,4033 @@
+\documentclass[american,twoside]{book}
+\usepackage{refbib}
+\usepackage{hyperref}
+\input{macros}
+
+%%--------------------------------------------------
+%% Set section numbering limit, toc limit
+\setcounter{secnumdepth}{5}
+\setcounter{tocdepth}{1}
+
+%%--------------------------------------------------
+%% Parameters that govern document appearance
+\setlength{\oddsidemargin}{0pt}
+\setlength{\evensidemargin}{0pt}
+\setlength{\textwidth}{6.6in}
+
+%%--------------------------------------------------
+%% Handle special hyphenation rules
+\hyphenation{tem-plate ex-am-ple in-put-it-er-a-tor}
+
+% Do not put blank pages after chapters that end on odd-numbered pages.
+\def\cleardoublepage{\clearpage\if_at_twoside%
+ \ifodd\c_at_page\else\hbox{}\thispagestyle{empty}\newpage%
+ \if_at_twocolumn\hbox{}\newpage\fi\fi\fi}
+
+\begin{document}
+\raggedbottom
+
+\begin{titlepage}
+\begin{center}
+\huge
+Concepts for the C++0x Standard Library: Algorithms \\
+(Revision 2)
+
+\vspace{0.5in}
+
+\normalsize
+Douglas Gregor and Andrew Lumsdaine \\
+Open Systems Laboratory, Indiana University \\
+\href{mailto:dgregor_at_[hidden]}{dgregor_at_[hidden]}, \href{mailto:lums_at_[hidden]}{lums_at_[hidden]}
+\end{center}
+
+\vspace{1in}
+\par\noindent Document number: NNNNN=07-XXXX\vspace{-6pt}
+\par\noindent Revises document number: N2084=06-0154\vspace{-6pt}
+\par\noindent Date: \today\vspace{-6pt}
+\par\noindent Project: Programming Language \Cpp{}, Library Working Group\vspace{-6pt}
+\par\noindent Reply-to: Douglas Gregor $<$\href{mailto:dgregor_at_[hidden]}{dgregor_at_[hidden]}$>$\vspace{-6pt}
+
+\section*{Introduction}
+\libintrotext{Chapter 25}
+\section*{Changes from N2084}
+\begin{itemize}
+\item Updated algorithm requirements to new concept syntax.
+\item Updated algorithm requirements to use the new iterator and
+ utility concepts, including the relaxed iterator requirements in
+ N2323 and the move concepts of N2322.
+\item Added \tcode{CopyConstructible} requirements for each of the
+ function object types. These requirements were previously implicit
+ (due to requirement propagation in earlier versions of the concepts
+ proposal).
+\item Added new algorithms \tcode{move}, \tcode{move_backward},
+ \tcode{is_sorted}, \tcode{is_sorted_until}, \tcode{is_heap},
+ \tcode{is_heap_until}, \tcode{minmax} and \tcode{minmax_element}.
+\end{itemize}
+
+\end{titlepage}
+
+%%--------------------------------------------------
+%% Headers and footers
+\pagestyle{fancy}
+\fancyhead[LE,RO]{\textbf{\rightmark}}
+\fancyhead[RE]{\textbf{\leftmark\hspace{1em}\thepage}}
+\fancyhead[LO]{\textbf{\thepage\hspace{1em}\leftmark}}
+\fancyfoot[C]{Draft}
+
+\fancypagestyle{plain}{
+\renewcommand{\headrulewidth}{0in}
+\fancyhead[LE,RO]{}
+\fancyhead[RE,LO]{}
+\fancyfoot{}
+}
+
+\renewcommand{\sectionmark}[1]{\markright{\thesection\hspace{1em}#1}}
+\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
+
+\color{black}
+
+\setcounter{chapter}{24}
+\rSec0[algorithms]{Algorithms library}
+
+\begin{paras}
+
+\pnum
+This clause describes components that \Cpp\ programs may use to perform
+algorithmic operations on containers (clause \ref{lib.containers}) and other sequences.
+
+\pnum
+The following subclauses describe components for
+non-modifying sequence operation,
+modifying sequence operations,
+sorting and related operations,
+and algorithms from the ISO C library,
+as summarized in Table~\ref{tab:algorithms.lib.summary}.
+
+\begin{libsumtab}{Algorithms library summary}{tab:algorithms.lib.summary}
+\ref{alg.nonmodifying} Non-modifying sequence operations & \\
+\ref{alg.modifying.operations} Mutating sequence operations & \tcode{<algorithm>} \\
+\ref{alg.sorting} Sorting and related operations & \\ \hline
+\ref{alg.c.library} C library algorithms & \tcode{<cstdlib>} \\ \hline
+\end{libsumtab}
+
+\synopsis{Header \tcode{<algorithm>}\ synopsis}
+\index{algorithm@\tcode{<algorithm>}}%
+
+\color{addclr}
+\begin{codeblock}
+namespace std {
+ @\textcolor{black}{// \ref{alg.nonmodifying}, non-modifying sequence operations:}@
+ template<InputIterator Iter, Callable<Iter::reference> Function>
+ requires CopyConstructible<Function>
+ Function for_each(Iter @\farg{first}@, Iter @\farg{last}@, Function @\farg{f}@);
+
+ template<InputIterator Iter, class T>
+ requires EqualityComparable<Iter::reference, T>
+ Iter find(Iter @\farg{first}@, Iter @\farg{last}@, const T& @\farg{value}@);
+
+ template<InputIterator Iter, Predicate<Iter::reference> Pred>
+ requires CopyConstructible<Pred>
+ Iter find_if(Iter @\farg{first}@, Iter @\farg{last}@, Pred @\farg{pred}@);
+
+ template<ForwardIterator Iter1, ForwardIterator Iter2>
+ requires EqualityComparable<Iter1::reference, Iter2::reference>
+ Iter1 find_end(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@);
+
+ template<ForwardIterator Iter1, ForwardIterator Iter2,
+ Predicate<Iter1::reference, Iter2::reference> Pred>
+ requires CopyConstructible<Pred>
+ Iter1 find_end(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@,
+ Pred @\farg{pred}@);
+
+ template<InputIterator Iter1, ForwardIterator Iter2>
+ requires EqualityComparable<Iter1::reference, Iter2::reference>
+ Iter1 find_first_of(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@);
+
+ template<InputIterator Iter1, ForwardIterator Iter2,
+ Predicate<Iter1::reference, Iter2::reference> Pred>
+ requires CopyConstructible<Pred>
+ Iter1 find_first_of(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@,
+ Pred @\farg{pred}@);
+
+ template<ForwardIterator Iter>
+ requires EqualityComparable<Iter::reference>
+ Iter adjacent_find(Iter @\farg{first}@, Iter @\farg{last}@);
+
+ template<ForwardIterator Iter, Predicate<Iter::reference, Iter::reference> Pred>
+ requires CopyConstructible<Pred>
+ Iter adjacent_find(Iter @\farg{first}@, Iter @\farg{last}@, Pred @\farg{pred}@);
+
+ template<InputIterator Iter, class T>
+ requires EqualityComparable<Iter::reference, T>
+ @\color{addclr}@Iter::difference_type count(Iter @\farg{first}@, Iter @\farg{last}@, const T& @\farg{value}@);
+
+ template<InputIterator Iter, Predicate<Iter::reference> Pred>
+ requires CopyConstructible<Pred>
+ Iter::difference_type count_if(Iter @\farg{first}@, Iter @\farg{last}@, Pred @\farg{pred}@);
+
+ template<InputIterator Iter1, InputIterator Iter2>
+ requires EqualityComparable<Iter1::reference, Iter2::reference>
+ pair<Iter1, Iter2> mismatch(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter @\farg{first2}@);
+
+ template<InputIterator Iter1, InputIterator Iter2,
+ Predicate<Iter1::reference, Iter2::reference> Pred>
+ requires CopyConstructible<Pred>
+ pair<Iter1, Iter2> mismatch(Iter1 @\farg{first1}@, Iter2 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Pred @\farg{pred}@);
+
+ template<InputIterator Iter1, InputIterator Iter2>
+ requires EqualityComparable<Iter1::reference, Iter2::reference>
+ bool equal(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@);
+
+ template<InputIterator Iter1, InputIterator Iter2,
+ Predicate<Iter1::reference, Iter2::reference> Pred>
+ requires CopyConstructible<Pred>
+ bool equal(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Pred @\farg{pred}@);
+
+ template<ForwardIterator Iter1, ForwardIterator Iter2>
+ requires EqualityComparable<Iter1::reference, Iter2::reference>
+ Iter1 search(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@);
+
+ template<ForwardIterator Iter1, ForwardIterator Iter2,
+ Predicate<Iter1::reference, Iter2::reference> Pred>
+ requires CopyConstructible<Pred>
+ @\textcolor{addclr}{Iter1}@ search(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@,
+ Pred @\farg{pred}@);
+
+ template<ForwardIterator Iter, class T>
+ requires EqualityComparable<Iter::reference, T>
+ Iter search_n(Iter @\farg{first}@, Iter @\farg{last}@, Iter::difference_type @\farg{count}@,
+ const T& @\farg{value}@);
+
+ template<ForwardIterator Iter, class T,
+ Predicate<Iter::reference, T> Pred>
+ requires CopyConstructible<Pred>
+ Iter search_n(Iter @\farg{first}@, Iter @\farg{last}@, Iter::difference_type @\farg{count}@,
+ const T& @\farg{value}@, Pred @\farg{pred}@);
+
+ @\textcolor{black}{// \ref{alg.modifying.operations}, modifying sequence operations:}@
+ @\textcolor{black}{// \ref{alg.copy}, copy:}@
+ template<InputIterator InIter, OutputIterator<InIter::reference> OutIter>
+ OutIter copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@);
+
+ template<BidirectionalIterator InIter, MutableBidirectionalIterator OutIter>
+ requires CopyAssignable<OutIter::reference, InIter::reference>
+ OutIter copy_backward(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@);
+
+ // \ref{alg.move}, move:
+ template<InputIterator InIter, OutputIterator<InIter::value_type&&> OutIter>
+ OutIter move(InIter first, InIter last,
+ OutIter result);
+ template<BidirectionalIterator InIter, BidirectionalIterator OutIter>
+ requires MoveAssignable<OutIter::reference, InIter::value_type>
+ OutIter move_backward(InIter first, InIter last,
+ OutIter result);
+
+ @\textcolor{black}{// \ref{alg.swap}, swap:}@
+ template<class T>
+ requires MoveAssignable<T> && MoveConstructible<T>
+ void swap(T& @\farg{a}@, T& @\farg{b}@);
+
+ template<MutableForwardIterator Iter1, MutableForwardIterator Iter2>
+ requires SameType<Iter1::value_type, Iter2::value_type> &&
+ SameType<Iter1::value_type&, Iter1::reference> &&
+ SameType<Iter2::value_type&, Iter2::reference> &&
+ Swappable<Iter1::value_type>
+ Iter2 swap_ranges(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@);
+
+ template<MutableForwardIterator Iter1, MutableForwardIterator Iter2>
+ requires SameType<Iter1::value_type, Iter2::value_type> &&
+ SameType<Iter1::value_type&, Iter1::reference> &&
+ SameType<Iter2::value_type&, Iter2::reference> &&
+ Swappable<Iter1::value_type>
+ void iter_swap(Iter1 @\farg{a}@, Iter2 @\farg{b}@);
+
+ template<InputIterator InIter, class OutIter,
+ Callable<InIter::reference> Op>
+ requires OutputIterator<OutIter, Op::result_type> && CopyConstructible<Op>
+ OutIter transform(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@, Op @\farg{op}@);
+
+ template<InputIterator InIter1, InputIterator InIter2,
+ class OutIter, Callable<InIter1::reference, InIter2::reference> BinaryOp>
+ requires OutputIterator<OutIter, BinaryOp::result_type> && CopyConstructible<BinaryOp>
+ OutIter transform(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, OutIter @\farg{result}@,
+ BinaryOp @\farg{binary_op}@);
+
+ template<MutableForwardIterator Iter, class T>
+ requires EqualityComparable<Iter::reference, T> && CopyAssignable<Iter::reference, T>
+ void replace(Iter @\farg{first}@, Iter @\farg{last}@,
+ const T& @\farg{old_value}@, const T& @\farg{new_value}@);
+
+ @\textcolor{addclr}{template}@<MutableForwardIterator Iter, Predicate<Iter::reference> Pred, class T>
+ requires CopyAssignable<Iter::reference, T> && CopyConstructible<Pred>
+ void replace_if(Iter @\farg{first}@, Iter @\farg{last}@,
+ Pred @\farg{pred}@, const T& @\farg{new_value}@);
+
+ template<InputIterator InIter, OutputIterator<InIter::value_type> OutIter, class T>
+ requires CopyAssignable<OutIter::reference, T> && EqualityComparable<InIter::reference, T>
+ OutIter replace_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@,
+ const T& @\farg{old_value}@, const T& @\farg{new_value}@);
+
+ template<InputIterator InIter, OutputIterator<InIter::value_type> OutIter,
+ Predicate<InIter::reference> Pred, class T>
+ requires CopyAssignable<OutIter::reference, T> && CopyConstructible<Pred>
+ OutIter replace_copy_if(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@,
+ Pred @\farg{pred}@, const T& @\farg{new_value}@);
+
+ template<MutableForwardIterator Iter, class T>
+ requires CopyAssignable<Iter::reference, T>
+ void fill(Iter @\farg{first}@, Iter @\farg{last}@, const T& @\farg{value}@);
+
+ template<class Iter, Integral Size, class T>
+ requires OutputIterator<Iter, T>
+ void fill_n(Iter @\farg{first}@, Size @\farg{n}@, const T& @\farg{value}@);
+
+ template<MutableForwardIterator Iter, Callable<> Generator>
+ requires CopyAssignable<Iter::reference, Generator::result_type> && CopyConstructible<Generator>
+ void generate(Iter @\farg{first}@, Iter @\farg{last}@,
+ Generator @\farg{gen}@);
+
+ template<class Iter, Integral Size, Callable<> Generator>
+ requires OutputIterator<Iter, Generator::result_type> && CopyConstructible<Generator>
+ void generate_n(Iter @\farg{first}@, Size @\farg{n}@, Generator @\farg{gen}@);
+
+ template<ForwardIterator Iter, class T>
+ requires MoveAssignable<Iter::reference> && EqualityComparable<Iter::reference, T>
+ Iter remove(Iter @\farg{first}@, Iter @\farg{last}@,
+ const T& @\farg{value}@);
+
+ template<ForwardIterator Iter, Predicate<Iter::reference> Pred>
+ requires MoveAssignable<Iter::reference> && CopyConstructible<Pred>
+ Iter remove_if(Iter @\farg{first}@, Iter @\farg{last}@,
+ Pred @\farg{pred}@);
+
+ template<InputIterator InIter, OutputIterator<InIter::value_type> OutIter, class T>
+ requires EqualityComparable<InIter::reference, T>
+ OutIter remove_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@, const T& @\farg{value}@);
+
+ template<InputIterator InIter, OutputIterator<InIter::value_type> OutIter,
+ Predicate<InIter::reference> Pred>
+ requires CopyConstructible<Pred>
+ OutIter remove_copy_if(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@, Pred @\farg{pred}@);
+
+ template<ForwardIterator Iter>
+ requires MoveAssignable<Iter::reference> && EqualityComparable<Iter::reference>
+ Iter unique(Iter @\farg{first}@, Iter @\farg{last}@);
+
+ template<ForwardIterator Iter, Predicate<Iter::reference, Iter::reference> Pred>
+ requires MoveAssignable<Iter::reference> && CopyConstructible<Pred>
+ Iter unique(Iter @\farg{first}@, Iter @\farg{last}@,
+ Pred @\farg{pred}@);
+
+ template<InputIterator InIter, OutputIterator<InIter::value_type> OutIter>
+ requires EqualityComparable<InIter::value_type> && CopyAssignable<InIter::value_type> &&
+ @\textcolor{addclr}{CopyConstructible}@<InIter::value_type> && !ForwardIterator<InIter> &&
+ !MutableForwardIterator<OutIter>
+ OutIter
+ unique_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@);
+
+ template<ForwardIterator InIter, OutputIterator<InIter::value_type> OutIter>
+ requires EqualityComparable<InIter::reference>
+ OutIter unique_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@);
+
+ template<InputIterator InIter, MutableForwardIterator OutIter>
+ requires EqualityComparable<OutIter::reference, InIter::value_type> &&
+ CopyAssignable<OutIter::reference, InIter::reference> &&
+ !ForwardIterator<InIter>
+ OutIter unique_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@);
+
+ template<InputIterator InIter, OutputIterator<InIter::value_type> OutIter,
+ Predicate<InIter::value_type, InIter::value_type> Pred>
+ requires CopyAssignable<InIter::value_type> && CopyConstructible<InIter::value_type> &&
+ !ForwardIterator<InIter> && !MutableForwardIterator<OutIter> &&
+ CopyConstructible<Pred>
+ OutIter unique_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@, Pred @\farg{pred}@);
+
+ template<ForwardIterator InIter, OutputIterator<InIter::value_type> OutIter,
+ Predicate<InIter::reference, InIter::reference> Pred>
+ requires CopyConstructible<Pred>
+ OutIter unique_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@);
+
+ template<InputIterator InIter, MutableForwardIterator OutIter,
+ Predicate<OutIter::reference, InIter::reference> Pred>
+ requires CopyAssignable<OutIter::reference, InIter::reference> &&
+ !ForwardIterator<InIter> && CopyConstructible<Pred>
+ OutIter unique_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@, Pred @\farg{pred}@);
+
+ template<MutableBidirectionalIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type>
+ void reverse(Iter @\farg{first}@, Iter @\farg{last}@);
+
+ template<BidirectionalIterator InIter, OutputIterator<InIter::value_type> OutIter>
+ OutIter reverse_copy(InIter @\farg{first}@,
+ InIter @\farg{last}@, OutIter @\farg{result}@);
+
+ template<ForwardIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type>
+ void rotate(Iter @\farg{first}@, Iter @\farg{middle}@,
+ Iter @\farg{last}@);
+
+ template<ForwardIterator InIter, OutputIterator<InIter::value_type> OutIter>
+ OutIter rotate_copy(InIter @\farg{first}@, InIter @\farg{middle}@,
+ InIter @\farg{last}@, OutIter @\farg{result}@);
+
+ template<MutableRandomAccessIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type>
+ void random_shuffle(Iter @\farg{first}@,
+ Iter @\farg{last}@);
+
+ template<MutableRandomAccessIterator Iter, Callable<Iter::difference_type> Rand>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ Convertible<Rand::result_type, Iter::difference_type> && CopyConstructible<Rand>
+ void random_shuffle(Iter @\farg{first}@,
+ Iter @\farg{last}@,
+ Rand& @\farg{rand}@);
+
+ template<class RandomAccessIterator, class UniformRandomNumberGenerator>
+ void random_shuffle(RandomAccessIterator @\farg{first}@,
+ RandomAccessIterator @\farg{last}@,
+ UniformRandomNumberGenerator& @\farg{rand}@);
+
+ @\textcolor{black}{// \ref{alg.partitions}, partitions:}@
+ template<BidirectionalIterator Iter, Predicate<Iter::reference> Pred>
+ @\color{addclr}@requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ CopyConstructible<Pred>
+ Iter partition(Iter @\farg{first}@, Iter @\farg{last}@, Pred @\farg{pred}@);
+
+ template<MutableBidirectionalIterator Iter, Predicate<Iter::reference> Pred>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ CopyConstructible<Pred>
+ Iter stable_partition(Iter @\farg{first}@, Iter @\farg{last}@, Pred @\farg{pred}@);
+
+ @\textcolor{black}{// \ref{alg.sorting}, sorting and related operations:}@
+ @\textcolor{black}{// \ref{alg.sort}, sorting:}@
+ template<MutableRandomAccessIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ LessThanComparable<Iter::value_type>
+ void sort(Iter @\farg{first}@, Iter @\farg{last}@);
+
+ template<MutableRandomAccessIterator Iter,
+ Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ CopyConstructible<Compare>
+ void sort(Iter @\farg{first}@, Iter @\farg{last}@,
+ Compare @\farg{comp}@);
+
+ template<MutableRandomAccessIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ LessThanComparable<Iter::value_type>
+ void stable_sort(Iter @\farg{first}@, Iter @\farg{last}@);
+
+ template<MutableRandomAccessIterator Iter,
+ Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ CopyConstructible<Compare>
+ void stable_sort(Iter @\farg{first}@, Iter @\farg{last}@,
+ Compare @\farg{comp}@);
+
+ template<MutableRandomAccessIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ CopyConstructible<Compare>
+ void partial_sort(Iter @\farg{first}@,
+ Iter @\farg{middle}@,
+ Iter @\farg{last}@);
+
+ template<MutableRandomAccessIterator Iter,
+ Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ CopyConstructible<Compare>
+ void partial_sort(Iter @\farg{first}@,
+ Iter @\farg{middle}@,
+ Iter @\farg{last}@,
+ Compare @\farg{comp}@);
+
+ template<InputIterator InIter, MutableRandomAccessIterator RAIter>
+ requires CopyAssignable<RAIter::reference, InIter::value_type> &&
+ SameType<RAIter::value_type&, RAIter::reference> && Swappable<RAIter::value_type> &&
+ MoveConstructible<RAIter::value_type> && MoveAssignable<RAIter::value_type> &&
+ LessThanComparable<InIter::value_type, RAIter::value_type> &&
+ LessThanComparable<RAIter::value_type, InIter::value_type> &&
+ LessThanComparable<RAIter::value_type>
+ RAIter partial_sort_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ RAIter @\farg{result_first}@, RAIter @\farg{result_last}@);
+
+ template<InputIterator InIter, MutableRandomAccessIterator RAIter, class Compare>
+ requires CopyAssignable<RAIter::reference, InIter::value_type> &&
+ SameType<RAIter::value_type&, RAIter::reference> && Swappable<RAIter::value_type> &&
+ MoveConstructible<RAIter::value_type> && MoveAssignable<RAIter::value_type> &&
+ Predicate<Compare, InIter::value_type, RAIter::value_type> &&
+ Predicate<Compare, RAIter::value_type, InIter::value_type> &&
+ Predicate<Compare, RAIter::value_type> &&
+ CopyConstructible<Compare>
+ RAIter partial_sort_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ RAIter @\farg{result_first}@, RAIter @\farg{result_last}@,
+ Compare @\farg{comp}@);
+
+ template<ForwardIterator Iter>
+ requires LessThanComparable<Iter::value_type>
+ bool is_sorted(Iter first, Iter last);
+ template<ForwardIterator Iter, Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires CopyConstructible<Compare>
+ bool is_sorted(Iter first, Iter last,
+ Compare comp);
+ template<ForwardIterator Iter>
+ requires LessThanComparable<Iter::value_type>
+ Iter is_sorted_until(Iter first, Iter last);
+ template<ForwardIterator Iter, Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires CopyConstructible<Compare>
+ Iter is_sorted_until(Iter first, Iter last,
+ Compare comp);
+
+ template<MutableRandomAccessIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ LessThanComparable<Iter::value_type>
+ void nth_element(Iter @\farg{first}@, Iter @\farg{nth}@,
+ Iter @\farg{last}@);
+
+ template<MutableRandomAccessIterator Iter,
+ Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ CopyConstructible<Compare>
+ void nth_element(Iter @\farg{first}@, Iter @\farg{nth}@,
+ Iter @\farg{last}@, Compare @\farg{comp}@);
+
+ @\textcolor{black}{// \ref{alg.binary.search}, binary search:}@
+ template<ForwardIterator Iter, class T>
+ requires LessThanComparable<Iter::reference, T>
+ Iter lower_bound(Iter @\farg{first}@, Iter @\farg{last}@,
+ const T& @\farg{value}@);
+
+ @\textcolor{addclr}{template}@<ForwardIterator Iter, class T, Predicate<Iter::reference, T> Compare>
+ requires CopyConstructible<Compare>
+ Iter lower_bound(Iter @\farg{first}@, Iter @\farg{last}@,
+ const T& @\farg{value}@, Compare @\farg{comp}@);
+
+ template<ForwardIterator Iter, class T>
+ requires LessThanComparable<T, Iter::reference>
+ Iter upper_bound(Iter @\farg{first}@, Iter @\farg{last}@,
+ const T& @\farg{value}@);
+
+ template<ForwardIterator Iter, class T, Predicate<T, Iter::reference> Compare>
+ requires CopyConstructible<Compare>
+ Iter upper_bound(Iter @\farg{first}@, Iter @\farg{last}@,
+ const T& @\farg{value}@, Compare @\farg{comp}@);
+
+ template<ForwardIterator Iter, class T>
+ requires LessThanComparable<T, Iter::reference> &&
+ LessThanComparable<Iter::reference, T>
+ pair<Iter, Iter>
+ equal_range(Iter @\farg{first}@,
+ Iter @\farg{last}@, const T& @\farg{value}@);
+
+ template<ForwardIterator Iter, class T, class Compare>
+ requires Predicate<Compare, T, Iter::reference> &&
+ Predicate<Compare, Iter::reference, T> &&
+ CopyConstructible<Compare>
+ pair<Iter, Iter>
+ equal_range(Iter @\farg{first}@,
+ Iter @\farg{last}@, const T& @\farg{value}@,
+ Compare @\farg{comp}@);
+
+ template<ForwardIterator Iter, class T>
+ requires LessThanComparable<T, Iter::reference> &&
+ LessThanComparable<Iter::reference, T>
+ bool binary_search(ForwardIterator @\farg{first}@, ForwardIterator @\farg{last}@,
+ const T& @\farg{value}@);
+
+ template<ForwardIterator Iter, class T, class Compare>
+ requires Predicate<Compare, T, Iter::reference> &&
+ Predicate<Compare, Iter::reference, T> &&
+ CopyConstructible<Compare>
+ bool binary_search(Iter @\farg{first}@, Iter @\farg{last}@,
+ const T& @\farg{value}@, Compare @\farg{comp}@);
+
+ @\textcolor{black}{// \ref{alg.merge}, merge:}@
+ template<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter>
+ requires SameType<InIter1::value_type, InIter2::value_type> &&
+ LessThanComparable<InIter1::value_type>
+ OutIter merge(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ OutIter @\farg{result}@);
+
+ @\textcolor{addclr}{template}@<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter,
+ Predicate<InIter1::value_type, InIter2::value_type> Compare>
+ requires SameType<InIter1::value_type, InIter2::value_type> &&
+ CopyConstructible<Compare>
+ OutIter merge(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ OutIter @\farg{result}@, Compare @\farg{comp}@);
+
+ template<MutableBidirectionalIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ LessThanComparable<Iter::value_type>
+ void inplace_merge(Iter @\farg{first}@,
+ Iter @\farg{middle}@,
+ Iter @\farg{last}@);
+
+ template<MutableBidirectionalIterator Iter,
+ Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ CopyConstructible<Compare>
+ void inplace_merge(Iter @\farg{first}@,
+ Iter @\farg{middle}@,
+ Iter @\farg{last}@, Compare @\farg{comp}@);
+
+ @\textcolor{black}{// \ref{alg.set.operations}, set operations:}@
+ template<InputIterator Iter1, InputIterator Iter2>
+ requires SameType<Iter1::value_type, Iter2::value_type> && LessThanComparable<Iter1::value_type>
+ bool includes(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@);
+
+ template<InputIterator Iter1, InputIterator Iter2,
+ Predicate<Iter1::value_type, Iter2::value_type> Compare>
+ requires SameType<Iter1::value_type, Iter2::value_type> && CopyConstructible<Compare>
+ bool includes(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@,
+ Compare @\farg{comp}@);
+
+ template<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter>
+ requires SameType<InIter1::value_type, InIter2::value_type> &&
+ LessThanComparable<InIter1::value_type>
+ OutIter set_union(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ OutIter @\farg{result}@);
+
+ template<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter,
+ Predicate<InIter1::value_type, InIter2::value_type> Compare>
+ requires SameType<InIter1::value_type, InIter2::value_type> && CopyConstructible<Compare>
+ OutIter set_union(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ OutIter @\farg{result}@, Compare @\farg{comp}@);
+
+ template<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter>
+ requires SameType<InIter1::value_type, InIter2::value_type> &&
+ LessThanComparable<InIter1::value_type>
+ OutIter set_intersection(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ OutIter @\farg{result}@);
+
+ template<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter,
+ Predicate<InIter1::value_type, InIter2::value_type> Compare>
+ requires SameType<InIter1::value_type, InIter2::value_type> && CopyConstructible<Compare>
+ OutIter set_intersection(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ OutIter @\farg{result}@, Compare @\farg{comp}@);
+
+ template<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter>
+ requires SameType<InIter1::value_type, InIter2::value_type> &&
+ LessThanComparable<InIter1::value_type>
+ OutIter set_difference(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ @\textcolor{addclr}{OutIter}@ @\farg{result}@);
+
+ template<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter,
+ Predicate<InIter1::value_type, InIter2::value_type> Compare>
+ requires SameType<InIter1::value_type, InIter2::value_type> && CopyConstructible<Compare>
+ OutIter set_difference(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ OutIter @\farg{result}@, Compare @\farg{comp}@);
+
+ template<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter>
+ requires SameType<InIter1::value_type, InIter2::value_type> &&
+ LessThanComparable<InIter1::value_type>
+ OutIter set_symmetric_difference(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ OutIter @\farg{result}@);
+
+ template<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter,
+ Predicate<InIter1::value_type, InIter2::value_type> Compare>
+ requires SameType<InIter1::value_type, InIter2::value_type> && CopyConstructible<Compare>
+ OutIter set_symmetric_difference(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ OutIter @\farg{result}@, Compare @\farg{comp}@);
+
+ @\textcolor{black}{// \ref{alg.heap.operations}, heap operations:}@
+ template<MutableRandomAccessIterator Iter>
+ requires MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ LessThanComparable<Iter::value_type>
+ void push_heap(Iter @\farg{first}@, Iter @\farg{last}@);
+
+ template<MutableRandomAccessIterator Iter,
+ Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ CopyConstructible<Compare>
+ void push_heap(Iter @\farg{first}@, Iter @\farg{last}@,
+ Compare @\farg{comp}@);
+
+ template<MutableRandomAccessIterator Iter>
+ requires MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ Swappable<Iter::value_type> && LessThanComparable<Iter::value_type>
+ void pop_heap(Iter @\farg{first}@, Iter @\farg{last}@);
+
+ template<MutableRandomAccessIterator Iter,
+ Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ Swappable<Iter::value_type> && CopyConstructible<Compare>
+ void pop_heap(Iter @\farg{first}@, Iter @\farg{last}@,
+ Compare @\farg{comp}@);
+
+ template<MutableRandomAccessIterator Iter>
+ requires MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ LessThanComparable<Iter::value_type>
+ void make_heap(Iter @\farg{first}@, Iter @\farg{last}@);
+
+ template<MutableRandomAccessIterator Iter,
+ Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ CopyConstructible<Compare>
+ void make_heap(Iter @\farg{first}@, Iter @\farg{last}@,
+ Compare @\farg{comp}@);
+
+ template<MutableRandomAccessIterator Iter>
+ requires MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ Swappable<Iter::value_type> && LessThanComparable<Iter::value_type>
+ void sort_heap(Iter @\farg{first}@, Iter @\farg{last}@);
+
+ template<MutableRandomAccessIterator Iter,
+ Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ Swappable<Iter::value_type> && CopyConstructible<Compare>
+ void sort_heap(Iter @\farg{first}@, Iter @\farg{last}@,
+ Compare @\farg{comp}@);
+
+ template<RandomAccessIterator Iter>
+ requires LessThanComparable<Iter::value_type>
+ bool is_heap(Iter first, Iter last);
+ template<RandomAccessIterator Iter, Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires CopyConstructible<Compare>
+ bool is_heap(Iter first, Iter last, Compare comp);
+ template<RandomAccessIterator Iter>
+ Iter is_heap_until(Iter first, Iter last);
+ template<RandomAccessIterator Iter, Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires CopyConstructible<Compare>
+ Iter is_heap_until(Iter first, Iter last,
+ Compare comp);
+
+ @\textcolor{black}{// \ref{alg.min.max}, minimum and maximum:}@
+ template<LessThanComparable T> const T& min(const T& @\farg{a}@, const T& @\farg{b}@);
+ template<class T, Predicate<T, T> Compare>
+ requires CopyConstructible<Compare>
+ const T& min(const T& @\farg{a}@, const T& @\farg{b}@, Compare @\farg{comp}@);
+
+ template<LessThanComparable T> const T& max(const T& @\farg{a}@, const T& @\farg{b}@);
+ template<class T, Predicate<T, T> Compare>
+ requires CopyConstructible<Compare>
+ const T& max(const T& @\farg{a}@, const T& @\farg{b}@, Compare @\farg{comp}@);
+
+ template<LessThanComparable T> pair<const T&, const T&> minmax(const T& @\farg{a}@, const T& @\farg{b}@);
+ template<class T, Predicate<T, T> Compare>
+ requires CopyConstructible<Compare>
+ pair<const T&, const T&> minmax(const T& @\farg{a}@, const T& @\farg{b}@, Compare @\farg{comp}@);
+
+ template<ForwardIterator Iter>
+ requires LessThanComparable<Iter::reference>
+ Iter min_element(Iter @\farg{first}@, Iter @\farg{last}@);
+
+ template<ForwardIterator Iter, Predicate<Iter::reference, Iter::reference> Compare>
+ requires CopyConstructible<Compare>
+ Iter min_element(Iter @\farg{first}@, Iter @\farg{last}@,
+ Compare @\farg{comp}@);
+
+ template<ForwardIterator Iter>
+ requires LessThanComparable<Iter::reference>
+ Iter max_element(Iter @\farg{first}@, Iter @\farg{last}@);
+
+ template<ForwardIterator Iter, Predicate<Iter::reference, Iter::reference> Compare>
+ requires CopyConstructible<Compare>
+ Iter max_element(Iter @\farg{first}@, Iter @\farg{last}@,
+ Compare @\farg{comp}@);
+
+ template<ForwardIterator Iter>
+ requires LessThanComparable<Iter::value_type>
+ pair<Iter, Iter>
+ minmax_element(Iter @\farg{first}@, Iter @\farg{last}@);
+ template<ForwardIterator Iter, Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires CopyConstructible<Compare>
+ pair<Iter, Iter>
+ minmax_element(Iter @\farg{first}@, Iter @\farg{last}@, Compare @\farg{comp}@);
+
+ @\textcolor{black}{// \ref{alg.permutation.generators}, permutations:}@
+ template<InputIterator Iter1, InputIterator Iter2>
+ @\textcolor{addclr}{requires}@ LessThanComparable<Iter1::reference, Iter2::reference> &&
+ LessThanComparable<Iter2::reference, Iter1::reference>
+ bool lexicographical_compare(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@);
+
+ @\textcolor{addclr}{template}@<InputIterator Iter1, InputIterator Iter2, class Compare>
+ requires Predicate<Compare, Iter1::reference, Iter2::reference> &&
+ Predicate<Compare, Iter2::reference, Iter1::reference> &&
+ CopyConstructible<Compare>
+ bool lexicographical_compare(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@,
+ Compare @\farg{comp}@);
+
+ template<MutableBidirectionalIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ @\textcolor{addclr}{LessThanComparable}@<Iter::reference>
+ bool next_permutation(Iter @\farg{first}@, Iter @\farg{last}@);
+
+ template<MutableBidirectionalIterator Iter,
+ Predicate<Iter::reference, Iter::reference> Compare>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ CopyConstructible<Compare>
+ bool next_permutation(Iter @\farg{first}@, Iter @\farg{last}@, Compare @\farg{comp}@);
+
+ template<MutableBidirectionalIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ LessThanComparable<Iter::reference>
+ bool prev_permutation(Iter @\farg{first}@, Iter @\farg{last}@);
+
+ template<MutableBidirectionalIterator Iter,
+ Predicate<Iter::reference, Iter::reference> Compare>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ CopyConstructible<Compare>
+ bool prev_permutation(Iter @\farg{first}@, Iter @\farg{last}@, Compare @\farg{comp}@);
+}
+\end{codeblock}
+\color{black}
+
+\pnum
+All of the algorithms are separated from the particular implementations of data structures and are
+parameterized by iterator types.
+Because of this, they can work with program-defined data structures, as long
+as these data structures have iterator types satisfying the assumptions on the algorithms.
+
+\pnum
+\removedConcepts{Throughout this clause, the names of template parameters
+are used to express type requirements.
+If an algorithm's template parameter is
+InputIterator,
+InputIterator1,
+or
+InputIterator2,
+the actual template argument shall satisfy the
+requirements of an input iterator (24.1.1).
+If an algorithm's template parameter is
+OutputIterator,
+OutputIterator1,
+or
+OutputIterator2,
+the actual template argument shall satisfy the requirements
+of an output iterator (24.1.2).
+If an algorithm's template parameter is
+ForwardIterator,
+ForwardIterator1,
+or
+ForwardIterator2,
+the actual template argument shall satisfy the requirements
+of a forward iterator (24.1.3).
+If an algorithm's template parameter is
+BidirectionalIterator,
+BidirectionalIterator1,
+or
+BidirectionalIterator2,
+the actual template argument shall satisfy the requirements
+of a bidirectional iterator (24.1.4).
+If an algorithm's template parameter is
+RandomAccessIterator,
+RandomAccessIterator1,
+or
+RandomAccessIterator2,
+the actual template argument shall satisfy the requirements
+of a random-access iterator (24.1.5).}
+
+\pnum
+\removedConcepts{If an algorithm's
+Effects
+section says that a value pointed to by any iterator passed
+as an argument is modified, then that algorithm has an additional
+type requirement:
+The type of that argument shall satisfy the requirements
+of a mutable iterator (24.1).
+[ Note:
+this requirement does not affect arguments that are declared as
+OutputIterator,
+OutputIterator1,
+or
+OutputIterator2,
+because output iterators must always be mutable.
+-- end note]}
+
+\pnum\
+\color{black}
+Both in-place and copying versions are provided for certain algorithms.%
+\footnote{
+The decision whether to include a copying version was usually based on complexity considerations.
+When the cost of doing the operation dominates the cost of copy, the copying version is not included.
+For example,
+\tcode{sort_copy}
+is not included
+because the cost of sorting is much more significant, and users might as well do
+\tcode{copy}
+followed by
+\tcode{sort}.
+}
+When such a version is provided for
+\textit{algorithm}\
+it is called
+\textit{algorithm\farg{_copy}}.
+Algorithms that take predicates end with the suffix
+\tcode{_if}
+(which follows the suffix
+\tcode{_copy}).
+
+\pnum
+\removedConcepts{The
+Predicate
+parameter is used whenever an algorithm expects a function object that when applied to the result
+of dereferencing the corresponding iterator returns a value testable as
+true.
+In other words, if an algorithm
+takes
+Predicate pred
+as its argument and first
+as its iterator argument, it should work correctly in the
+construct
+if (pred(*first))\{...\}.
+The function object
+pred
+shall not apply any non-constant
+function through the dereferenced iterator.
+This function object may be a pointer to function,
+or an object of a type with an appropriate function call operator.}
+
+\pnum
+\removedConcepts{The
+Predicate
+parameter is used whenever an algorithm expects a function object that when applied to
+the result of dereferencing two corresponding iterators or to dereferencing an
+iterator and type
+T
+when
+T
+is part of the signature returns a value testable as
+true.
+In other words, if an algorithm takes
+Predicate binary_pred
+as its argument and first1 and first2 as
+its iterator arguments, it should work correctly in
+the construct
+if (binary_pred(*first1, *first2))\{...\}.
+Predicate
+always takes the first iterator
+type as its first argument, that is, in those cases when
+T value
+is part of the signature, it should work
+correctly in the context of
+if (binary_pred(*first1, value))\{...\}.
+binary_pred shall not
+apply any non-constant function through the dereferenced iterators.}
+
+\pnum
+\enternote\
+Unless otherwise specified, algorithms that take function objects as arguments
+are permitted to copy those function objects freely. Programmers for whom object
+identity is important should consider using a wrapper class that points to a
+noncopied implementation object, or some equivalent solution.
+\exitnote\
+
+\pnum\
+\removedConcepts{
+When the description of an algorithm gives an expression such as
+*first == value
+for a condition, the expression shall evaluate to
+either true or false in boolean contexts.}
+
+\pnum
+In the description of the algorithms operators
+\tcode{+}\
+and
+\tcode{-}\
+are used for some of the iterator categories for which
+they do not have to be defined.
+In these cases the semantics of
+\tcode{a+n}\
+is the same as that of
+
+\begin{codeblock}
+ { X tmp = a;
+ advance(tmp, n);
+ return tmp;
+ }
+\end{codeblock}
+
+and that of
+\tcode{b-a}\
+is the same as of
+
+\begin{codeblock}
+ return distance(a, b);
+\end{codeblock}
+
+\rSec1[alg.nonmodifying]{Non-modifying sequence operations}
+
+\rSec2[alg.foreach]{For each}
+
+\editorial{The standard does not state whether the function object
+ takes a value of the iterator's value type or reference type. The
+ SGI STL documentation says it's the value type, but that conflicts
+ with user expectations that they are operating on references. Also,
+ ``the result of dereferencing every iterator...'' is the reference
+ type, not the value type. Therefore, we have chosen to use the
+ reference type.}
+
+\index{for_each@\tcode{for_each}}%
+
+\color{addclr}
+\begin{itemdecl}
+template<InputIterator Iter, Callable<Iter::reference> Function>
+ requires CopyConstructible<Function>
+ Function for_each(Iter @\farg{first}@, Iter @\farg{last}@, Function @\farg{f}@);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Applies
+\farg{f}\ to the result of dereferencing every iterator in the range
+\range{\farg{first}}{\farg{last}},
+starting from
+\tcode{\farg{first}}\
+and proceeding to
+\tcode{\farg{last} - 1}.
+
+\pnum
+\returns\
+\farg{f}.
+
+\pnum
+\complexity\
+Applies \farg{f}\
+exactly
+\tcode{\farg{last}\ - \farg{first}}\
+times.
+
+\pnum
+\removedConcepts{Notes: If f returns a result, the result is ignored.}
+\end{itemdescr}
+
+\rSec2[alg.find]{Find}
+
+\index{find@\tcode{find}}%
+\index{find_if@\tcode{find_if}}%
+\color{addclr}\begin{itemdecl}
+@\textcolor{addclr}{template}@<InputIterator Iter, class T>
+ requires EqualityComparable<Iter::reference, T>
+ Iter find(Iter @\farg{first}@, Iter @\farg{last}@, const T& @\farg{value}@);
+
+template<InputIterator Iter, Predicate<Iter::reference> Pred>
+ requires CopyConstructible<Pred>
+ Iter find_if(Iter @\farg{first}@, Iter @\farg{last}@, Pred @\farg{pred}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\returns\
+The first iterator
+\tcode{i}\
+in the range
+\range{\farg{first}}{\farg{last}}\
+for which the following corresponding
+conditions hold:
+\tcode{*i == \farg{value}, \farg{pred}(*i) != false}.
+Returns \farg{last}\ if no such iterator is found.
+
+\pnum
+\complexity\
+At most
+\tcode{\farg{last}\ - \farg{first}}\
+applications of the corresponding predicate.
+\end{itemdescr}
+
+\rSec2[alg.find.end]{Find End}
+
+\index{find_end@\tcode{find_end}}%
+\color{addclr}\begin{itemdecl}
+template<ForwardIterator Iter1, ForwardIterator Iter2>
+ requires EqualityComparable<Iter1::reference, Iter2::reference>
+ Iter1 find_end(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@);
+
+template<ForwardIterator Iter1, ForwardIterator Iter2,
+ Predicate<Iter1::reference, Iter2::reference> Pred>
+ requires CopyConstructible<Pred>
+ Iter1 find_end(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@,
+ Pred @\farg{pred}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Finds a subsequence of equal values in a sequence.
+
+\pnum
+\returns\
+The last iterator
+\tcode{i}\
+in the range \range{\farg{first1}}{\farg{last1} - (\farg{last2} - \farg{first2})}\
+such that for any non-negative integer
+\tcode{n < (\farg{last2} - \farg{first2})},
+the following corresponding conditions hold:
+\tcode{*(i + n) == *(\brk{}\farg{first2}\ + n), \farg{pred}(*(i + n), *(\farg{first2}\ + n)) != false}.
+Returns \farg{last1}\
+if no such iterator is found.
+
+\pnum
+\complexity\
+At most
+\tcode{(\farg{last2} - \farg{first2}) * (\farg{last1} - \farg{first1} - (\farg{last2} - \farg{first2}) + 1)}
+applications of the corresponding predicate.
+\end{itemdescr}
+
+\rSec2[alg.find.first.of]{Find First}
+
+\editorial{This text assumes that the proposed resolution to DR 576 is
+ accepted, weakening the requirements on the first type parameter
+ (\tcode{Iter1}) to \tcode{Input Iterator}.}
+
+\index{find_first_of@\tcode{find_first_of}}%
+\color{addclr}\begin{itemdecl}
+template<InputIterator Iter1, ForwardIterator Iter2>
+ requires EqualityComparable<Iter1::reference, Iter2::reference>
+ Iter1 find_first_of(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@);
+
+template<InputIterator Iter1, ForwardIterator Iter2,
+ Predicate<Iter1::reference, Iter2::reference> Pred>
+ requires CopyConstructible<Pred>
+ Iter1 find_first_of(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@,
+ Pred @\farg{pred}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Finds an element that matches one of a set of values.
+
+\pnum
+\returns\
+The first iterator
+\tcode{i}\
+in the range \range{\farg{first1}}{\farg{last1}}\
+such that for some
+iterator
+\tcode{j}\
+in the range \range{\farg{first2}}{\farg{last2}}\
+the following conditions hold:
+\tcode{*i == *j, \farg{pred}(*i,*j) != false}.
+Returns \farg{last1}\
+if no such iterator is found.
+
+\pnum
+\complexity\
+At most
+\tcode{(\farg{last1}-\farg{first1}) * (\farg{last2}-\farg{first2})}
+applications of the corresponding predicate.
+\end{itemdescr}
+
+\rSec2[alg.adjacent.find]{Adjacent find}
+
+\index{adjacent_find@\tcode{adjacent_find}}%
+\color{addclr}\begin{itemdecl}
+template<ForwardIterator Iter>
+ requires EqualityComparable<Iter::reference>
+ Iter adjacent_find(Iter @\farg{first}@, Iter @\farg{last}@);
+
+template<ForwardIterator Iter, Predicate<Iter::reference, Iter::reference> Pred>
+ requires CopyConstructible<Pred>
+ Iter adjacent_find(Iter @\farg{first}@, Iter @\farg{last}@, Pred @\farg{pred}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\returns\
+The first iterator
+\tcode{i}\
+such that both
+\tcode{i}\
+and
+\tcode{i + 1}\
+are in
+the range
+\range{\farg{first}}{\farg{last}}\
+for which
+the following corresponding conditions hold:
+\tcode{*i == *(i + 1), \farg{pred}(*i, *(i + 1)) != false}.
+Returns \farg{last}\
+if no such iterator is found.
+
+\pnum
+\complexity\
+For a nonempty range, exactly
+\tcode{min((i - \farg{first}) + 1, (\farg{last}\ - \farg{first}) - 1)}\
+applications of the corresponding predicate, where \tcode{i}\ is
+\tcode{adjacent_find}'s
+return value.
+\end{itemdescr}
+
+\rSec2[alg.count]{Count}
+
+\index{count@\tcode{count}}%
+\index{count_if@\tcode{count_if}}%
+\color{addclr}\begin{itemdecl}
+template<InputIterator Iter, class T>
+ requires EqualityComparable<Iter::reference, T>
+ @\color{addclr}@Iter::difference_type count(Iter @\farg{first}@, Iter @\farg{last}@, const T& @\farg{value}@);
+
+template<InputIterator Iter, Predicate<Iter::reference> Pred>
+ requires CopyConstructible<Pred>
+ Iter::difference_type count_if(Iter @\farg{first}@, Iter @\farg{last}@, Pred @\farg{pred}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Returns the number of iterators
+\tcode{i}\
+in the range \range{\farg{first}}{\farg{last}}\
+for which the following corresponding
+conditions hold:
+\tcode{*i == \farg{value}, \farg{pred}(*i) != false}.
+
+\pnum
+\complexity\
+Exactly
+\tcode{\farg{last} - \farg{first}}\
+applications of the corresponding predicate.
+\end{itemdescr}
+
+\rSec2[lib.mismatch]{\textcolor{black}{Mismatch}}
+
+\index{mismatch@\tcode{mismatch}}%
+\color{addclr}\begin{itemdecl}
+template<InputIterator Iter1, InputIterator Iter2>
+ requires EqualityComparable<Iter1::reference, Iter2::reference>
+ pair<Iter1, Iter2> mismatch(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter @\farg{first2}@);
+
+template<InputIterator Iter1, InputIterator Iter2,
+ Predicate<Iter1::reference, Iter2::reference> Pred>
+ requires CopyConstructible<Pred>
+ pair<Iter1, Iter2> mismatch(Iter1 @\farg{first1}@, Iter2 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Pred @\farg{pred}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\returns\
+A pair of iterators
+\tcode{i}\
+and
+\tcode{j}\
+such that
+\tcode{j == \farg{first2} + (i - \farg{first1})}\
+and
+\tcode{i}\
+is the first iterator
+in the range \range{\farg{first1}}{\farg{last1}}\
+for which the following corresponding conditions hold:
+
+\begin{codeblock}
+ !(*i == *(@\farg{first2}@ + (i - @\farg{first1}@)))
+ @\farg{pred}@(*i, *(@\farg{first2}@ + (i - @\farg{first1}@))) == false
+\end{codeblock}
+
+Returns the pair \farg{last1}\ and
+\tcode{\farg{first2}\ + (\farg{last1}\ - \farg{first1})}
+if such an iterator
+\tcode{i}\
+is not found.
+
+\pnum
+\complexity\
+At most
+\tcode{\farg{last1}\ - \farg{first1}}\
+applications of the corresponding predicate.
+\end{itemdescr}
+
+\rSec2[alg.equal]{Equal}
+
+\index{equal@\tcode{equal}}%
+\color{addclr}\begin{itemdecl}
+template<InputIterator Iter1, InputIterator Iter2>
+ requires EqualityComparable<Iter1::reference, Iter2::reference>
+ bool equal(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@);
+
+template<InputIterator Iter1, InputIterator Iter2,
+ Predicate<Iter1::reference, Iter2::reference> Pred>
+ requires CopyConstructible<Pred>
+ bool equal(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Pred @\farg{pred}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{true}\
+if for every iterator
+\tcode{i}\
+in the range \range{\farg{first1}}{\farg{last1}}\
+the following corresponding conditions hold:
+\tcode{*i == *(\farg{first2}\ + (i - \farg{first1})), \farg{pred}(*i, *(\farg{first2}\ + (i - \farg{first1}))) != false}.
+Otherwise, returns
+\tcode{false}.
+
+\pnum
+\complexity\
+At most
+\tcode{\farg{last1} - \farg{first1}}\
+applications of the corresponding predicate.
+\end{itemdescr}
+
+\rSec2[alg.search]{Search}
+
+\index{search@\tcode{search}}%
+\color{addclr}\begin{itemdecl}
+template<ForwardIterator Iter1, ForwardIterator Iter2>
+ requires EqualityComparable<Iter1::reference, Iter2::reference>
+ Iter1 search(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@);
+
+template<ForwardIterator Iter1, ForwardIterator Iter2,
+ Predicate<Iter1::reference, Iter2::reference> Pred>
+ requires CopyConstructible<Pred>
+ @\textcolor{addclr}{Iter1}@ search(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@,
+ Pred @\farg{pred}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Finds a subsequence of equal values in a sequence.
+
+\pnum
+\returns\
+The first iterator
+\tcode{i}\
+in the range \range{\farg{first1}}{\farg{last1}\ - (\farg{last2}-\farg{first2})}\
+such that for any non-negative integer
+\tcode{n}\
+less than
+\tcode{\farg{last2} - \farg{first2}}\
+the following corresponding conditions hold:
+\tcode{*(i + n) == *(\farg{first2}\ + n), \farg{pred}(*(i + n), *(\farg{first2}\ + n)) != false}.
+Returns \farg{last1}\
+if no such iterator is found.
+
+\pnum
+\complexity\
+At most
+\tcode{(\farg{last1}\ - \farg{first1}) * (\farg{last2}\ - \farg{first2})}
+applications of the corresponding predicate.
+\end{itemdescr}
+
+\color{addclr}\begin{itemdecl}
+@\textcolor{addclr}{template}@<ForwardIterator Iter, class T>
+ requires EqualityComparable<Iter::reference, T>
+ Iter search_n(Iter @\farg{first}@, Iter @\farg{last}@, Iter::difference_type @\farg{count}@,
+ const T& @\farg{value}@);
+
+template<ForwardIterator Iter, class T,
+ Predicate<Iter::reference, T> Pred>
+ requires CopyConstructible<Pred>
+ Iter search_n(Iter @\farg{first}@, Iter @\farg{last}@, Iter::difference_type @\farg{count}@,
+ const T& @\farg{value}@, Pred @\farg{pred}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{Requires:
+The type
+Size
+is convertible to integral type~(4.7, 12.3).}
+
+\editorial{We have
+removed the \tcode{Size} parameter and instead chosen to use the
+\tcode{difference_type} of the iterator. This change can break existing
+code in two ways. First, if the \tcode{Size} parameter was originally
+bound to a type larger than \tcode{difference_type} and the
+\tcode{count} parameter contains a value outside of the range of
+\tcode{difference_type} (in which case, \tcode{search_n} always
+returns \tcode{last}). Second, if the user explicitly provides an
+argument for the \tcode{Size} parameter. Note: This change has not yet
+been reflected in libstdc++.}
+
+\pnum\ \color{black}
+\effects\
+Finds a subsequence of equal values in a sequence.
+
+\pnum
+\returns\
+The first iterator
+\tcode{i}\
+in the range \range{\farg{first}}{\farg{last}-\farg{count}}\
+such that for any non-negative integer
+\tcode{n}\
+less than
+\tcode{count}\
+the following corresponding conditions hold:
+\tcode{*(i + n) == \farg{value}, \farg{pred}(*(i + n),\farg{value}) != false}.
+Returns \farg{last}\
+if no such iterator is found.
+
+\pnum
+\complexity\
+At most
+\tcode{(\farg{last}\ - \farg{first}) * \farg{count}}
+applications of the corresponding predicate if \farg{count} is positive, or
+0 otherwise.
+\end{itemdescr}
+
+\rSec1[alg.modifying.operations]{Mutating sequence operations}
+
+\rSec2[alg.copy]{Copy}
+
+\index{copy@\tcode{copy}}%
+\color{addclr}\begin{itemdecl}
+template<InputIterator InIter, OutputIterator<InIter::reference> OutIter>
+ OutIter copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Copies elements in the range \range{\farg{first}}{\farg{last}}\
+into the range \range{\farg{result}}{\farg{result}\ + (\farg{last}\ - \farg{first})}\
+starting from \farg{first} and proceeding to \farg{last}.
+For each non-negative integer
+\tcode{n < (\farg{last}-\farg{first})},
+performs
+\tcode{\textcolor{black}{*}(\farg{result}\ + n) = *(\farg{first}\ + n)}.
+
+\pnum
+\returns\
+\tcode{\farg{result}\ + (\farg{last}\ - \farg{first})}.
+
+\pnum
+\requires\
+\farg{result}
+shall not be in the range
+\range{\farg{first}}{\farg{last}}.
+
+\pnum
+\complexity\
+Exactly
+\tcode{\farg{last}\ - \farg{first}}
+assignments.
+\end{itemdescr}
+
+\index{copy_backward@\tcode{copy_backward}}%
+\color{addclr}\begin{itemdecl}
+template<BidirectionalIterator InIter, MutableBidirectionalIterator OutIter>
+ requires CopyAssignable<OutIter::reference, InIter::reference>
+ OutIter copy_backward(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Copies elements in the range \range{\farg{first}}{\farg{last}}\
+into the
+range \range{\farg{result}\ - (\farg{last}-\farg{first})}{\farg{result}}\
+\textcolor{black}{starting} from
+\tcode{\farg{last} - 1}\
+and proceeding to \farg{first}.%
+\footnote{
+\tcode{copy_backward}\
+should be used instead of copy when \farg{last}\
+is in
+the range
+\range{\farg{result}\ - (\farg{last}\ - \farg{first})}{\farg{result}}.
+}
+For each positive integer
+\tcode{n <= (\farg{last}\ - \farg{first})},
+performs
+\tcode{*(\farg{result}\ - n) = *(\farg{last}\ - n)}.
+
+\pnum
+\requires\
+\tcode{\farg{result}}
+shall not be in the range \range{\farg{first}}{\farg{last}}.
+
+\pnum
+\returns\
+\tcode{\farg{result}\ - (\farg{last}\ - \farg{first})}.
+
+\pnum
+\complexity\
+Exactly
+\tcode{\farg{last}\ - \farg{first}}
+assignments.
+\end{itemdescr}
+
+\rSec2[alg.move]{Move}
+
+\index{move\tcode{move}}%
+\color{addclr}
+\begin{itemdecl}
+template<InputIterator InIter, OutputIterator<InIter::value_type&&> OutIter>
+ OutIter move(InIter first, InIter last,
+ OutIter result);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\addedD{\mbox{\effects}
+Moves elements in the range \mbox{\range{\farg{first}}{\farg{last}}}
+into the range \mbox{\range{\farg{result}}{\farg{result}\ + (\farg{last}\ - \farg{first})}}
+starting from \mbox{\farg{first}} and proceeding to \mbox{\farg{last}}.
+For each non-negative integer
+\mbox{\tcode{n < (\farg{last}-\farg{first})}},
+performs
+\mbox{\tcode{*(\farg{result}\ + n)}} \mbox{\tcode{= std::move(*(\farg{first}\ + n))}}.}
+
+\pnum
+\addedD{\mbox{\returns}
+\mbox{\tcode{\farg{result}\ + (\farg{last}\ - \farg{first})}}.}
+
+\pnum
+\addedD{\mbox{\requires}
+\mbox{\farg{result}}
+shall not be in the range
+\mbox{\range{\farg{first}}{\farg{last}}}.}
+
+\pnum
+\addedD{\mbox{\complexity}
+Exactly
+\mbox{\tcode{\farg{last}\ - \farg{first}}}
+move assignments.}
+\end{itemdescr}
+
+\index{move_backward@\tcode{move_backward}}%
+\color{addclr}
+\begin{itemdecl}
+template<BidirectionalIterator InIter, BidirectionalIterator OutIter>
+ requires MoveAssignable<OutIter::reference, InIter::value_type>
+ OutIter move_backward(InIter first, InIter last,
+ OutIter result);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\addedD{\mbox{\effects}
+Moves elements in the range \mbox{\range{\farg{first}}{\farg{last}}}
+into the
+range \mbox{\range{\farg{result}\ - (\farg{last}-\farg{first})}{\farg{result}}}
+starting from
+\mbox{\tcode{\farg{last} - 1}}
+and proceeding to \mbox{\farg{first}}.}%
+\footnote{
+\mbox{\tcode{move_backward}}
+should be used instead of move when \mbox{\farg{last}}
+is in
+the range
+\mbox{\range{\farg{result}\ - (\farg{last}\ - \farg{first})}{\farg{result}}}.
+}
+\addedD{For each positive integer
+\mbox{\tcode{n <= (\farg{last}\ - \farg{first})}},
+performs
+\mbox{\tcode{*(\farg{result}\ - n) = std::move(*(\farg{last}\ - n))}}.}
+
+\pnum
+\addedD{\mbox{\requires}
+\mbox{\tcode{\farg{result}}}
+shall not be in the range \mbox{\range{\farg{first}}{\farg{last}}}.}
+
+\pnum
+\addedD{\mbox{\returns}
+\mbox{\tcode{\farg{result}\ - (\farg{last}\ - \farg{first})}}.}
+
+\pnum
+\addedD{\mbox{\complexity}
+Exactly
+\mbox{\tcode{\farg{last}\ - \farg{first}}}
+assignments.}
+\end{itemdescr}
+
+\rSec2[alg.swap]{Swap}
+
+\index{swap@\tcode{swap}}%
+\color{addclr}
+\begin{itemdecl}
+template<class T>
+ requires MoveAssignable<T> && MoveConstructible<T>
+ void swap(T& @\farg{a}@, T& @\farg{b}@);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{
+Requires:
+Type
+T
+is
+MoveConstructible~(33) and
+MoveAssignable~(35).}
+
+\pnum
+\effects\
+Exchanges values stored in two locations.
+\end{itemdescr}
+
+\index{swap_ranges@\tcode{swap_ranges}}%
+\color{addclr}
+\begin{itemdecl}
+template<MutableForwardIterator Iter1, MutableForwardIterator Iter2>
+ requires SameType<Iter1::value_type, Iter2::value_type> &&
+ SameType<Iter1::value_type&, Iter1::reference> &&
+ SameType<Iter2::value_type&, Iter2::reference> &&
+ Swappable<Iter1::value_type>
+ Iter2 swap_ranges(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+For each non-negative integer
+\tcode{n < (\farg{last1}\ - \farg{first1})}
+performs:
+\tcode{swap(*(\farg{first1}\ + n), *(\farg{first2}\ + n))}.
+
+\pnum
+\requires\
+The two ranges \range{\farg{first1}}{\farg{last1}}\
+and
+\range{\farg{first2}}{\farg{first2}\ + (\farg{last1}\ - \farg{first1})}\
+shall not overlap.
+\removedConcepts{The type of *first1 shall be the same
+as the type of *first2 and that type shall satisfy the
+Swappable requirements (20.1.4).}
+
+\pnum
+\returns\
+\tcode{\farg{first2}\ + (\farg{last1}\ - \farg{first1})}.
+
+\pnum
+\complexity\
+Exactly
+\tcode{\farg{last1}\ - \farg{first1}}\
+swaps.
+\end{itemdescr}
+
+\index{iter_swap@\tcode{iter_swap}}%
+\color{addclr}
+\begin{itemdecl}
+template<MutableForwardIterator Iter1, MutableForwardIterator Iter2>
+ requires SameType<Iter1::reference, Iter2::reference> &&
+ SameType<Iter1::value_type&, Iter1::reference> &&
+ SameType<Iter2::value_type&, Iter2::reference> &&
+ Swappable<Iter1::value_type>
+ @\addedConcepts{void}@ iter_swap(Iter1 @\farg{a}@, Iter2 @\farg{b}@);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+\tcode{swap(*\farg{a}, *\farg{b})}.
+
+\pnum
+\removedConcepts{
+Requires:
+The type of *a shall be the same
+as the type of *b and that type shall satisfy the
+Swappable requirements (20.1.4).}
+\end{itemdescr}
+
+\rSec2[alg.transform]{Transform}
+
+\index{transform@\tcode{transform}}%
+\color{addclr}\begin{itemdecl}
+template<InputIterator InIter, class OutIter,
+ Callable<InIter::reference> Op>
+ requires OutputIterator<OutIter, Op::result_type> && CopyConstructible<Op>
+ OutIter transform(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@, Op @\farg{op}@);
+
+template<InputIterator InIter1, InputIterator InIter2,
+ class OutIter, Callable<InIter1::reference, InIter2::reference> BinaryOp>
+ requires OutputIterator<OutIter, BinaryOp::result_type> && CopyConstructible<BinaryOp>
+ OutIter transform(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, OutIter @\farg{result}@,
+ BinaryOp @\farg{binary_op}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Assigns through every iterator
+\tcode{i}\
+in the range
+\range{\farg{result}}{\farg{result}\ + (\farg{last1}\ - \farg{first1})}
+a new
+corresponding value equal to
+\tcode{\farg{op}(*(\farg{first1}\ + (i - \farg{result}))}
+or
+\tcode{\farg{binary_op}(*(\farg{first1}\ + (i - \farg{result}), *(\farg{first2}\ + (i - \farg{result})))}.
+
+\pnum
+\requires\
+\farg{op}\ and \farg{binary_op}\
+shall not invalidate iterators or subranges, or modify elements in the ranges
+\crange{\farg{first1}}{\farg{last1}},
+\crange{\farg{first2}}{\farg{first2}\ + (\farg{last1}\ - \farg{first1})},
+and
+\crange{\farg{result}}{\farg{result}\ + (\farg{last1}\ - \farg{first1})}.%
+\footnote{The use of fully closed ranges is intentional.
+}
+
+\pnum
+\returns\
+\tcode{\farg{result}\ + (\farg{last1}\ - \farg{first1})}.
+
+\pnum
+\complexity\
+Exactly
+\tcode{\farg{last1}\ - \farg{first1}}\
+applications of
+\farg{op}\ or \farg{binary_op}.
+
+\pnum
+\notes\
+\farg{result}\ may be equal to \farg{first}\
+in case of unary transform,
+or to \farg{first1}\ or \farg{first2}\
+in case of binary transform.
+\end{itemdescr}
+
+\rSec2[alg.replace]{Replace}
+
+\index{replace@\tcode{replace}}%
+\index{replace_if@\tcode{replace_if}}%
+\color{addclr}\begin{itemdecl}
+template<MutableForwardIterator Iter, class T>
+ requires EqualityComparable<Iter::reference, T> && CopyAssignable<Iter::reference, T>
+ void replace(Iter @\farg{first}@, Iter @\farg{last}@,
+ const T& @\farg{old_value}@, const T& @\farg{new_value}@);
+
+@\textcolor{addclr}{template}@<MutableForwardIterator Iter, Predicate<Iter::reference> Pred, class T>
+ requires CopyAssignable<Iter::reference, T> && CopyConstructible<Pred>
+ void replace_if(Iter @\farg{first}@, Iter @\farg{last}@,
+ Pred @\farg{pred}@, const T& @\farg{new_value}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\requires\
+The expression
+\tcode{*\farg{first}\ = \farg{new_value}}\
+must be valid.
+
+\pnum
+\effects\
+Substitutes elements referred by the iterator
+\tcode{i}\
+in the range \range{\farg{first}}{\farg{last}}\
+with \farg{new_value},
+when the following corresponding conditions hold:
+\tcode{*i == \farg{old_value}}, \tcode{\farg{pred}(*i) != false}.
+
+\pnum
+\complexity\
+Exactly
+\tcode{\farg{last}\ - \farg{first}}\
+applications of the corresponding predicate.
+\end{itemdescr}
+
+\index{replace_copy@\tcode{replace_copy}}%
+\index{replace_copy_if@\tcode{replace_copy_if}}%
+\color{addclr}\begin{itemdecl}
+template<InputIterator InIter, OutputIterator<InIter::value_type> OutIter, class T>
+ requires CopyAssignable<OutIter::reference, T> && EqualityComparable<InIter::reference, T>
+ OutIter replace_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@,
+ const T& @\farg{old_value}@, const T& @\farg{new_value}@);
+
+template<InputIterator InIter, OutputIterator<InIter::value_type> OutIter,
+ Predicate<InIter::reference> Pred, class T>
+ requires CopyAssignable<OutIter::reference, T> && CopyConstructible<Pred>
+ OutIter replace_copy_if(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@,
+ Pred @\farg{pred}@, const T& @\farg{new_value}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\requires\
+The results of the expressions
+\tcode{*\farg{first}}\
+and
+\farg{new_value}\
+shall be writable to the
+\farg{result}\
+output iterator.
+The ranges
+\range{\farg{first}}{\farg{last}}\
+and
+\range{\farg{result}}{\farg{result}\ + (\farg{last}\ - \farg{first})}\
+shall not overlap.
+
+\pnum
+\effects\
+Assigns to every iterator
+\tcode{i}\
+in the
+range
+\range{\farg{result}}{\farg{result} + (\farg{last} - \farg{first})}\
+either
+\tcode{\farg{new_value}}\
+or
+\tcode{*\brk(\farg{first} + (i - \farg{result}))}\
+depending on whether the following corresponding conditions hold:
+
+\begin{codeblock}
+*(@\farg{first}@ + (i - @\farg{result}@)) == @\farg{old_value}@
+@\farg{pred}@(*(@\farg{first}@ + (i - @\farg{result}@))) != false
+\end{codeblock}
+
+\pnum
+\returns\
+\tcode{\farg{result}\ + (\farg{last}\ - \farg{first})}.
+
+\pnum
+\complexity\
+Exactly
+\tcode{\farg{last}\ - \farg{first}}\
+applications of the corresponding predicate.
+\end{itemdescr}
+
+\rSec2[alg.fill]{Fill}
+
+\index{fill@\tcode{fill}}%
+\index{fill_n@\tcode{fill_n}}%
+\color{addclr}\begin{itemdecl}
+template<MutableForwardIterator Iter, class T>
+ requires CopyAssignable<Iter::reference, T>
+ void fill(Iter @\farg{first}@, Iter @\farg{last}@, const T& @\farg{value}@);
+
+template<class Iter, Integral Size, class T>
+ requires OutputIterator<Iter, T>
+ void fill_n(Iter @\farg{first}@, Size @\farg{n}@, const T& @\farg{value}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{Requires: The expression value shall be writable to
+ the output iterator. The type Size is convertible to integral type~(4.7,
+ 12.3).}\efootnote{The ``Convertible to integral type'' requirements
+ are very odd. We can model them with concepts if we need, but I've
+ chosen the simpler route of requiring the \tcode{Size} parameter to model
+ \tcode{Integral}. This could break existing code, although it
+ appears that such existing code would fail to compile with at least
+ libstdc++.}
+
+\pnum
+\effects\
+The first algorithm assigns \farg{value}\ through all the iterators in the range
+\range{\farg{first}}{\farg{last}}. The second algorithm assigns \farg{value}\
+through all the iterators in the range \range{\farg{first}}{\farg{first}\ + \farg{n}}
+if \farg{n}\ is positive, otherwise it does nothing.
+
+\textcolor{black}{\pnum}
+\complexity\
+Exactly
+\tcode{\farg{last}\ - \farg{first}},
+\farg{n}, or 0 assignments, respectively.
+\end{itemdescr}
+
+\rSec2[alg.generate]{Generate}
+
+\index{generate@\tcode{generate}}%
+\index{generate_n@\tcode{generate_n}}%
+\color{addclr}\begin{itemdecl}
+template<MutableForwardIterator Iter, Callable<> Generator>
+ requires CopyAssignable<Iter::reference, Generator::result_type> &&
+ CopyConstructible<Generator>
+ void generate(Iter @\farg{first}@, Iter @\farg{last}@,
+ Generator @\farg{gen}@);
+
+template<class Iter, Integral Size, Callable<> Generator>
+ requires OutputIterator<Iter, Generator::result_type> &&
+ CopyConstructible<Generator>
+ void generate_n(Iter @\farg{first}@, Size @\farg{n}@, Generator @\farg{gen}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+The first algorithm invokes the function object \farg{gen}\ and assigns the return
+value of \farg{gen}\ through all the iterators in the range
+\range{\farg{first}}{\farg{last}}. The second algorithm invokes the function object
+\farg{gen}\ and assigns the return value of \farg{gen}\ through all the iterators in
+the range \range{\farg{first}}{\farg{first} + \farg{n}} if \farg{n}\ is positive,
+otherwise it does nothing.
+
+\pnum
+\removedConcepts{Requires: gen takes no arguments, Size is convertible
+ to integral type~(4.7,
+ 12.3).}\efootnote{The ``Convertible to integral type'' requirements
+ are very odd. We can model them with concepts if we need, but I've
+ chosen the simpler route of requiring the \tcode{Size} parameter to model
+ \tcode{Integral}. This could break existing code, although it
+ appears that such existing code would fail to compile with at least
+ libstdc++.}
+
+\pnum
+\complexity\
+Exactly
+\tcode{\farg{last}\ - \farg{first}},
+\farg{n}, or 0
+invocations of \farg{gen}\ and assignments, respectively.
+\end{itemdescr}
+
+\rSec2[alg.remove]{Remove}
+
+\index{remove@\tcode{remove}}%
+\index{remove_if@\tcode{remove_if}}%
+\color{addclr}\begin{itemdecl}
+template<ForwardIterator Iter, class T>
+ requires MoveAssignable<Iter::reference> && EqualityComparable<Iter::reference, T>
+ Iter remove(Iter @\farg{first}@, Iter @\farg{last}@,
+ const T& @\farg{value}@);
+
+template<ForwardIterator Iter, Predicate<Iter::reference> Pred>
+ requires MoveAssignable<Iter::reference> && CopyConstructible<Pred>
+ Iter remove_if(Iter @\farg{first}@, Iter @\farg{last}@,
+ Pred @\farg{pred}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{Requires: The type of *first shall satisfy the
+ MoveAssignable requirements (Table 35).}
+
+\textcolor{black}{\pnum}
+\effects\
+Eliminates all the elements referred to by iterator
+\tcode{i}\
+in the range \range{\farg{first}}{\farg{last}}\
+for which the following corresponding conditions hold:
+\tcode{*i == \farg{value}, \farg{pred}(*i) != false}.
+
+\pnum
+\returns\
+The end of the resulting range.
+
+\textcolor{black}{\pnum}
+\notes\
+Stable.
+
+\pnum
+\complexity\
+Exactly
+\tcode{\farg{last} - \farg{first}}\
+applications of the corresponding predicate.
+\end{itemdescr}
+
+\index{remove_copy@\tcode{remove_copy}}%
+\index{remove_copy_if@\tcode{remove_copy_if}}%
+\color{addclr}\begin{itemdecl}
+template<InputIterator InIter, OutputIterator<InIter::value_type> OutIter, class T>
+ requires EqualityComparable<InIter::reference, T>
+ OutIter remove_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@, const T& @\farg{value}@);
+
+template<InputIterator InIter, OutputIterator<InIter::value_type> OutIter,
+ Predicate<InIter::reference> Pred>
+ requires CopyConstructible<Pred>
+ OutIter remove_copy_if(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@, Pred @\farg{pred}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\requires\
+\removedConcepts{Type T is EqualityComparable~(20.1.1).}
+The ranges
+\range{\farg{first}}{\farg{last}}
+and
+\range{\farg{result}}{\farg{result} + (\farg{last} - \farg{first})}\
+shall not overlap.
+
+\pnum
+\effects\
+Copies all the elements referred to by the iterator
+\tcode{i}\
+in the range
+\range{\farg{first}}{\farg{last}}\
+for which the following corresponding conditions do not hold:
+\tcode{*i == \farg{value}, \farg{pred}(*i) != false}.
+
+\textcolor{black}{\pnum}
+\returns\
+The end of the resulting range.
+
+\pnum
+\complexity\
+Exactly
+\tcode{\farg{last}\ - \farg{first}}\
+applications of the corresponding predicate.
+
+\pnum
+\notes\
+Stable.
+\end{itemdescr}
+
+\rSec2[alg.unique]{Unique}
+
+\index{unique@\tcode{unique}}%
+\color{addclr}\begin{itemdecl}
+template<ForwardIterator Iter>
+ requires MoveAssignable<Iter::reference> && EqualityComparable<Iter::reference>
+ Iter unique(Iter @\farg{first}@, Iter @\farg{last}@);
+
+template<ForwardIterator Iter, Predicate<Iter::reference, Iter::reference> Pred>
+ requires MoveAssignable<Iter::reference> && CopyConstructible<Pred>
+ Iter unique(Iter @\farg{first}@, Iter @\farg{last}@,
+ Pred @\farg{pred}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+For a nonempty range, eliminates all but the first element from every
+consecutive group of equivalent elements referred to by the iterator
+\tcode{i}\
+in the range
+\range{\farg{first} + 1}{\farg{last}}\
+for which the following conditions hold:
+\tcode{*(i - 1) == *i}\
+or
+\tcode{\farg{pred}(*(i - 1), *i) != false}.
+
+\pnum
+\requires\
+The comparison function shall be an equivalence relation.
+
+\pnum
+\returns\
+The end of the resulting range.
+
+\pnum
+\complexity\
+For nonempty ranges, exactly
+\tcode{(\farg{last} - \farg{first}) - 1}\
+applications of the corresponding predicate.
+\end{itemdescr}
+
+\index{unique_copy@\tcode{unique_copy}}%
+\color{addclr}
+\begin{itemdecl}
+template<InputIterator InIter, OutputIterator<InIter::value_type> OutIter>
+ requires EqualityComparable<InIter::value_type> && CopyAssignable<InIter::value_type> &&
+ CopyConstructible<InIter::value_type> && !ForwardIterator<InIter> &&
+ !MutableForwardIterator<OutIter>
+ @\textcolor{addclr}{OutIter}@
+ unique_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@);
+
+template<ForwardIterator InIter, OutputIterator<InIter::value_type> OutIter>
+ requires EqualityComparable<InIter::reference>
+ OutIter unique_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@);
+
+@\textcolor{addclr}{template}@<InputIterator InIter, MutableForwardIterator OutIter>
+ requires EqualityComparable<OutIter::reference, InIter::value_type> &&
+ CopyAssignable<OutIter::reference, InIter::reference> &&
+ !ForwardIterator<InIter>
+ OutIter unique_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@);
+
+template<InputIterator InIter, OutputIterator<InIter::value_type> OutIter,
+ Predicate<InIter::value_type, InIter::value_type> Pred>
+ requires CopyAssignable<InIter::value_type> && CopyConstructible<InIter::value_type> &&
+ !ForwardIterator<InIter> && !MutableForwardIterator<OutIter> &&
+ CopyConstructible<Pred>
+ OutIter unique_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ @\textcolor{addclr}{OutIter}@ @\farg{result}@, Pred @\farg{pred}@);
+
+template<ForwardIterator InIter, OutputIterator<InIter::value_type> OutIter,
+ Predicate<InIter::reference, InIter::reference> Pred>
+ requires CopyConstructible<Pred>
+ OutIter unique_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@);
+
+template<InputIterator InIter, MutableForwardIterator OutIter,
+ Predicate<OutIter::reference, InIter::reference> Pred>
+ requires CopyAssignable<OutIter::reference, InIter::reference> &&
+ !ForwardIterator<InIter> && CopyConstructible<Pred>
+ OutIter unique_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@, Pred @\farg{pred}@);
+\end{itemdecl}
+\color{black}
+
+\editorial{We assume (and require!) the proposed resolution to DR 538,
+ which adds the \tcode{CopyAssignable} requirement.}
+
+\editorial{Note that we have split the two signatures of
+ \tcode{unique_copy} into six signatures, to cover the actual
+ variants required in the implementation.}
+
+\begin{itemdescr}
+\pnum
+\requires\
+The ranges
+\range{\farg{first}}{\farg{last}}\
+and
+\range{\farg{result}}{\farg{result}+(\farg{last}-\farg{first})}\
+shall not overlap. \removedConcepts{The expression
+*result = *first
+shall be valid. If neither
+InputIterator
+nor
+OutputIterator
+meets the requirements of forward iterator then the value type of
+InputIterator
+shall be CopyConstructible (20.1.3).
+Otherwise CopyConstructible is not required.}
+
+\pnum
+\effects\
+Copies only the first element from every consecutive group of equal elements referred to by
+the iterator \color{black}
+\tcode{i}\
+in the range
+\range{\farg{first}}{\farg{last}}\
+for which the following corresponding conditions hold:
+\tcode{*i == *(i - 1)}\
+or
+\tcode{\farg{pred}(*i, *(i - 1)) != false}.
+
+\pnum
+\returns\
+The end of the resulting range.
+
+\pnum
+\complexity\
+For nonempty ranges, exactly
+\tcode{\farg{last}\ - \farg{first} - 1}\
+applications of the corresponding predicate.
+\end{itemdescr}
+
+\rSec2[alg.reverse]{Reverse}
+
+\index{reverse@\tcode{reverse}}%
+\color{addclr}\begin{itemdecl}
+template<MutableBidirectionalIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type>
+ void reverse(Iter @\farg{first}@, Iter @\farg{last}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+For each non-negative integer
+\tcode{i <= (\farg{last}\ - \farg{first})/2},
+applies
+\tcode{iter_swap}\
+to all pairs of iterators
+\tcode{\farg{first}\ + i, (\farg{last}\ - i) - 1}.
+
+\pnum
+\removedConcepts{Requires:
+The type of *first shall satisfy the
+Swappable requirements (20.1.4).}
+
+\pnum
+\complexity\
+Exactly
+\tcode{(\farg{last}\ - \farg{first})/2}\
+swaps.
+\end{itemdescr}
+
+\index{reverse_copy@\tcode{reverse_copy}}%
+\color{addclr}\begin{itemdecl}
+template<BidirectionalIterator InIter, OutputIterator<InIter::value_type> OutIter>
+ OutIter reverse_copy(InIter @\farg{first}@,
+ InIter @\farg{last}@, OutIter @\farg{result}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Copies the range
+\range{\farg{first}}{\farg{last}}\
+to the range
+\range{\farg{result}}{\farg{result}+(\farg{last}-\farg{first})}\
+such that
+for any non-negative integer
+\tcode{i < (\farg{last}\ - \farg{first})}\
+the following assignment takes place:
+\tcode{*(\farg{result}\ + (\farg{last}\ - \farg{first}) - i) = *(\farg{first}\ + i)}.
+
+\pnum
+\requires\
+The ranges
+\range{\farg{first}}{\farg{last}}\
+and
+\range{\farg{result}}{\farg{result}+(\farg{last}-\farg{first})}\
+shall not overlap.
+
+\pnum
+\returns\
+\tcode{\farg{result}\ + (\farg{last}\ - \farg{first})}.
+
+\pnum
+\complexity\
+Exactly
+\tcode{\farg{last}\ - \farg{first}}\
+assignments.
+\end{itemdescr}
+
+\rSec2[alg.rotate]{Rotate}
+
+\index{rotate@\tcode{rotate}}%
+\color{addclr}\begin{itemdecl}
+template<ForwardIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type>
+ void rotate(Iter @\farg{first}@, Iter @\farg{middle}@,
+ Iter @\farg{last}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+For each non-negative integer
+\tcode{i < (\farg{last}\ - \farg{first})},
+places the element from the position
+\tcode{\farg{first}\ + i}\
+into position
+\tcode{\farg{first}\ + (i + (\farg{last}\ - \farg{middle})) \% (\farg{last}\ - \farg{first})}.
+
+\pnum
+\notes\
+This is a left rotate.
+
+\pnum
+\requires\
+\range{\farg{first}}{\farg{middle}}\
+and
+\range{\farg{middle}}{\farg{last}}\
+are valid ranges.
+\removedConcepts{The type of *first shall satisfy the
+Swappable requirements (20.1.4), the \mbox{\tcode{MoveConstructible}} requirements (Table~33), and the \mbox{\tcode{MoveAssignable}} requirements (Table~35).}
+
+\pnum
+\complexity\
+At most
+\tcode{\farg{last}\ - \farg{first}}\
+swaps.
+\end{itemdescr}
+
+\index{rotate_copy@\tcode{rotate_copy}}%
+\color{addclr}\begin{itemdecl}
+template<ForwardIterator InIter, OutputIterator<InIter::value_type> OutIter>
+ OutIter rotate_copy(InIter @\farg{first}@, InIter @\farg{middle}@,
+ InIter @\farg{last}@, OutIter @\farg{result}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Copies the range
+\range{\farg{first}}{\farg{last}}\
+to the range
+\range{\farg{result}}{\farg{result}\ + (\farg{last}\ - \farg{first})}\
+such that for each non-negative integer
+\tcode{i < (\farg{last}\ - \farg{first})}\
+the following assignment takes place:
+\tcode{*(\farg{result}\ + i) = *(\farg{first} +
+(i + (\farg{middle}\ - \farg{first})) \% (\farg{last}\ - \farg{first}))}.
+
+\pnum
+\returns\
+\tcode{\farg{result}\ + (\farg{last}\ - \farg{first})}.
+
+\pnum
+\requires\
+The ranges
+\range{\farg{first}}{\farg{last}}\
+and
+\range{\farg{result}}{\farg{result}\ + (\farg{last}\ - \farg{first})}\
+shall not overlap.
+
+\pnum
+\complexity\
+Exactly
+\tcode{\farg{last}\ - \farg{first}}\
+assignments.
+\end{itemdescr}
+
+\rSec2[alg.random.shuffle]{Random shuffle}
+
+\index{random_shuffle@\tcode{random_shuffle}}%
+\color{addclr}\begin{itemdecl}
+template<MutableRandomAccessIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type>
+ void random_shuffle(Iter @\farg{first}@,
+ Iter @\farg{last}@);
+
+template<MutableRandomAccessIterator Iter, Callable<Iter::difference_type> Rand>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ Convertible<Rand::result_type, Iter::difference_type> && CopyConstructible<Rand>
+ void random_shuffle(Iter @\farg{first}@,
+ Iter @\farg{last}@,
+ Rand&& @\farg{rand}@);
+
+template<class RandomAccessIterator, class UniformRandomNumberGenerator>
+ void random_shuffle(RandomAccessIterator @\farg{first}@,
+ RandomAccessIterator @\farg{last}@,
+ UniformRandomNumberGenerator& @\farg{rand}@);
+\end{itemdecl}\color{black}
+
+\editorial{TODO: We do not yet have the
+\tcode{UniformRandomNumberGenerator} concept, so we leave the third
+\tcode{random_shuffle} without concept constraints for now.}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Shuffles the elements in the range
+\range{\farg{first}}{\farg{last}}\
+with uniform distribution.
+
+\pnum
+\removedConcepts{Requires:
+The type of *first shall satisfy the
+Swappable requirements (20.1.4).}
+
+\pnum
+\complexity\
+Exactly
+\tcode{(\farg{last}\ - \farg{first}) - 1}\
+swaps.
+
+\pnum
+\notes\
+The underlying source of random numbers for the first form of the function
+is implementation-defined. An implementation may use the
+\tcode{rand}\
+function from the standard C library.
+The second form of the function
+takes a random number generating function object
+\farg{rand}
+\removedConcepts{such that
+if
+n
+is an argument for rand, with a positive value, that has
+type
+iterator_traits<RandomAccessIterator>::difference_type,
+then
+rand(n)
+returns a randomly chosen value,
+which lies in the interval (0,n],
+and which has a type that is convertible to
+iterator_traits<RandomAccessIterator>:: difference_type}.
+\end{itemdescr}
+
+\rSec2[alg.partitions]{Partitions}
+
+\index{partition@\tcode{partition}}%
+\color{addclr}\begin{itemdecl}
+template<BidirectionalIterator Iter, Predicate<Iter::reference> Pred>
+ @\color{addclr}@requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ CopyConstructible<Pred>
+ Iter partition(Iter @\farg{first}@, Iter @\farg{last}@, Pred @\farg{pred}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Places all the elements in the range
+\range{\farg{first}}{\farg{last}}\
+that satisfy \farg{pred}\
+before all the elements that do not satisfy it.
+
+\pnum
+\returns\
+An iterator
+\tcode{i}\
+such that for any iterator
+\tcode{j}\
+in the range
+\range{\farg{first}}{i}\
+\tcode{\farg{pred}(*j) != false},
+and for any iterator
+\tcode{k}\
+in the range
+\range{i}{\farg{last}},
+\tcode{\farg{pred}(*k) == false}.
+
+\pnum
+\removedConcepts{Requires:
+The type of *first shall satisfy the
+Swappable requirements (20.1.4),
+the \mbox{\tcode{MoveConstructible}} requirements
+(Table~\mbox{\ref{moveconstructible}}), and the
+the \mbox{\tcode{MoveAssignable}} requirements
+(Table~\mbox{\ref{moveassignable}}).}
+
+\pnum
+\complexity\
+At most
+\tcode{(\farg{last}\ - \farg{first})/2}\
+swaps.
+Exactly
+\tcode{\farg{last}\ - \farg{first}}\
+applications of the predicate are done.
+\end{itemdescr}
+
+\index{stable_partition@\tcode{stable_partition}}%
+\color{addclr}\begin{itemdecl}
+template<MutableBidirectionalIterator Iter, Predicate<Iter::reference> Pred>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ CopyConstructible<Pred>
+ Iter stable_partition(Iter @\farg{first}@, Iter @\farg{last}@, Pred @\farg{pred}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Places all the elements in the range
+\range{\farg{first}}{\farg{last}}\
+that satisfy \farg{pred}\ before all the
+elements that do not satisfy it.
+
+\pnum
+\returns\
+An iterator
+\tcode{i}\
+such that for any iterator
+\tcode{j}\
+in the range
+\range{\farg{first}}{i},
+\tcode{\farg{pred}(*j) != false},
+and for any iterator
+\tcode{k}\
+in the range
+\range{i}{\farg{last}},
+\tcode{\farg{pred}(*k) == false}.
+The relative order of the elements in both groups is \textcolor{black}{preserved}.
+
+\pnum
+\removedConcepts{Requires:
+The type of *first shall satisfy the
+Swappable requirements (20.1.4),
+the \mbox{\tcode{MoveConstructible}} requirements
+(Table~\mbox{\ref{moveconstructible}}), and the
+the \mbox{\tcode{MoveAssignable}} requirements
+(Table~\mbox{\ref{moveassignable}}).}
+
+\pnum
+\complexity\
+At most
+\tcode{(\farg{last}\ - \farg{first}) * log(\farg{last}\ - \farg{first})}\
+swaps, but only linear number of swaps if there is enough extra memory.
+Exactly
+\tcode{\farg{last}\ - \farg{first}}\
+applications of the predicate.
+\end{itemdescr}
+
+\rSec1[alg.sorting]{Sorting and related operations}
+
+\rSec2[alg.sort]{Sorting}
+
+\rSec3[lib.sort]{\tcode{sort}}
+
+\index{sort@\tcode{sort}}%
+\color{addclr}\begin{itemdecl}
+template<MutableRandomAccessIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ LessThanComparable<Iter::value_type>
+ void sort(Iter @\farg{first}@, Iter @\farg{last}@);
+
+template<MutableRandomAccessIterator Iter, Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ CopyConstructible<Compare>
+ void sort(Iter @\farg{first}@, Iter @\farg{last}@,
+ Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Sorts the elements in the range
+\range{\farg{first}}{\farg{last}}.
+
+\pnum
+\removedConcepts{Requires:
+The type of *first shall satisfy the
+Swappable requirements (37),
+the \mbox{\tcode{MoveConstructible}} requirements
+(Table~33), and the
+the \mbox{\tcode{MoveAssignable}} requirements
+(Table~35).}
+
+\pnum
+\complexity\
+Approximately $N \log(N)$
+(where
+\tcode{$N$ == \farg{last} - \farg{first}})
+comparisons on the average.%
+\footnote{
+If the worst case behavior is important
+\tcode{stable_sort()}~(\ref{lib.stable.sort}) or
+\tcode{partial_sort()}~(\ref{lib.partial.sort}) should be used.
+}
+\end{itemdescr}
+
+\rSec3[lib.stable.sort]{\tcode{stable_sort}}
+
+\index{stable_sort@\tcode{stable_sort}}%
+\color{addclr}\begin{itemdecl}
+template<MutableRandomAccessIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ LessThanComparable<Iter::value_type>
+ void stable_sort(Iter @\farg{first}@, Iter @\farg{last}@);
+
+template<MutableRandomAccessIterator Iter, Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ CopyConstructible<Compare>
+ void stable_sort(Iter @\farg{first}@, Iter @\farg{last}@,
+ Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Sorts the elements in the range \range{\farg{first}}{\farg{last}}.
+
+\pnum
+\removedConcepts{Requires:
+The type of *first shall satisfy the
+Swappable requirements (20.1.4),
+the \mbox{\tcode{MoveConstructible}} requirements
+(Table~33), and the
+the \mbox{\tcode{MoveAssignable}} requirements
+(Table~35).}
+
+\pnum
+\complexity\
+It does at most $N \log^2(N)$
+(where
+\tcode{$N$ == \farg{last} - \farg{first}})
+comparisons; if enough extra memory is available, it is
+$N \log(N)$.
+
+\pnum
+\notes\
+Stable.
+\end{itemdescr}
+
+\rSec3[lib.partial.sort]{\tcode{partial_sort}}
+
+\index{partial_sort@\tcode{partial_sort}}%
+\color{addclr}\begin{itemdecl}
+template<MutableRandomAccessIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ LessThanComparable<Iter::value_type>
+ void partial_sort(Iter @\farg{first}@,
+ Iter @\farg{middle}@,
+ Iter @\farg{last}@);
+
+template<MutableRandomAccessIterator Iter, Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ CopyConstructible<Compare>
+ void partial_sort(Iter @\farg{first}@,
+ Iter @\farg{middle}@,
+ Iter @\farg{last}@,
+ Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Places the first
+\tcode{\farg{middle}\ - \farg{first}}\
+sorted elements from the range
+\range{\farg{first}}{\farg{last}}
+into the range
+\range{\farg{first}}{\farg{middle}}.
+The rest of the elements in the range
+\range{\farg{middle}}{\farg{last}}\
+are placed in an unspecified order.
+\index{unspecified}%
+
+\pnum
+\removedConcepts{Requires:
+The type of *first shall satisfy the
+Swappable requirements (20.1.4),
+the \mbox{\tcode{MoveConstructible}} requirements
+(Table~33), and the
+the \mbox{\tcode{MoveAssignable}} requirements
+(Table~35).}
+
+\pnum
+\complexity\
+It takes approximately
+\tcode{(\farg{last}\ - \farg{first}) * log(\farg{middle}\ - \farg{first})}\
+comparisons.
+\end{itemdescr}
+
+\rSec3[lib.partial.sort.copy]{\tcode{partial_sort_copy}}
+
+\index{partial_sort_copy@\tcode{partial_sort_copy}}%
+\color{addclr}\begin{itemdecl}
+template<InputIterator InIter, MutableRandomAccessIterator RAIter>
+ requires CopyAssignable<RAIter::reference, InIter::value_type> &&
+ SameType<RAIter::value_type&, RAIter::reference> && Swappable<RAIter::value_type> &&
+ MoveConstructible<RAIter::value_type> && MoveAssignable<RAIter::value_type> &&
+ LessThanComparable<InIter::value_type, RAIter::value_type> &&
+ LessThanComparable<RAIter::value_type, InIter::value_type> &&
+ LessThanComparable<RAIter::value_type>
+ RAIter partial_sort_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ RAIter @\farg{result_first}@, RAIter @\farg{result_last}@);
+
+template<InputIterator InIter, MutableRandomAccessIterator RAIter, class Compare>
+ requires CopyAssignable<RAIter::reference, InIter::value_type> &&
+ SameType<RAIter::value_type&, RAIter::reference> && Swappable<RAIter::value_type> &&
+ MoveConstructible<RAIter::value_type> && MoveAssignable<RAIter::value_type> &&
+ Predicate<Compare, InIter::value_type, RAIter::value_type> &&
+ Predicate<Compare, RAIter::value_type, InIter::value_type> &&
+ Predicate<Compare, RAIter::value_type> &&
+ CopyConstructible<Compare>
+ RAIter partial_sort_copy(InIter @\farg{first}@, InIter @\farg{last}@,
+ RAIter @\farg{result_first}@, RAIter @\farg{result_last}@,
+ Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Places the first
+\tcode{min(\farg{last}\ - \farg{first}, \farg{result_last}\ - \farg{result_first})}\
+sorted elements into the range
+\range{\farg{result_first}}{\farg{result_first}\ + min(\farg{last}\ - \farg{first}, \farg{result_last}\ - \farg{result_first})}.
+
+\pnum
+\returns\
+The smaller of:
+\farg{result_last}\ or
+\tcode{\farg{result_first}\ + (\farg{last}\ - \farg{first})}.
+
+\pnum
+\removedConcepts{\mbox{\requires}
+The type of \mbox{\tcode{*result_first}} shall satisfy the
+Swappable requirements (37),
+the \mbox{\tcode{MoveConstructible}} requirements
+(Table~33), and the
+the \mbox{\tcode{MoveAssignable}} requirements
+(Table~35).}
+
+\pnum
+\complexity\
+Approximately
+\tcode{(\farg{last}\ - \farg{first}) * log(min(\farg{last}\ - \farg{first}, \farg{result_last}\ - \farg{result_first}))}\
+comparisons.
+\end{itemdescr}
+
+\rSec3[is.sorted]{\tcode{is_sorted}}
+
+\index{is_sorted@\tcode{is_sorted}}%
+\color{addclr}
+\begin{itemdecl}
+template<ForwardIterator Iter>
+ requires LessThanComparable<Iter::value_type>
+ bool is_sorted(Iter first, Iter last);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\addedD{\mbox{\returns} \mbox{\tcode{is_sorted_until(first, last) == last}}}
+\end{itemdescr}
+
+\index{is_sorted@\tcode{is_sorted}}%
+\color{addclr}
+\begin{itemdecl}
+template<ForwardIterator Iter, Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires CopyConstructible<Compare>
+ bool is_sorted(Iter first, Iter last,
+ Compare comp);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\addedD{\mbox{\returns} \mbox{\tcode{is_sorted_until(first, last, comp) == last}}}
+\end{itemdescr}
+
+\index{is_sorted_until@\tcode{is_sorted_until}}%
+\color{addclr}
+\begin{itemdecl}
+template<ForwardIterator Iter>
+ requires LessThanComparable<Iter::value_type>
+ Iter is_sorted_until(Iter first, Iter last);
+template<ForwardIterator Iter, Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires CopyConstructible<Compare>
+ Iter is_sorted_until(Iter first, Iter last,
+ Compare comp);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\addedD{\mbox{\returns} If \mbox{\tcode{distance(first, last) < 2}}, returns
+\mbox{\tcode{last}}. Otherwise, returns
+the last iterator \mbox{\tcode{i}} in \mbox{\crange{first}{last}} for which the
+range \mbox{\range{first}{i}} is sorted.}
+
+\pnum
+\addedD{\mbox{\complexity} Linear.}
+\end{itemdescr}
+
+\rSec2[alg.nth.element]{Nth element}
+
+\index{nth_element@\tcode{nth_element}}%
+\color{addclr}\begin{itemdecl}
+template<MutableRandomAccessIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ LessThanComparable<Iter::value_type>
+ void nth_element(Iter @\farg{first}@, Iter @\farg{nth}@,
+ Iter @\farg{last}@);
+
+template<MutableRandomAccessIterator Iter, Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ CopyConstructible<Compare>
+ void nth_element(Iter @\farg{first}@, Iter @\farg{nth}@,
+ Iter @\farg{last}@, Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+After
+\tcode{nth_element}\
+the element in the position pointed to by \farg{nth}\
+is the element that would be
+in that position if the whole range were sorted.
+Also for any iterator
+\tcode{i}\
+in the range
+\range{\farg{first}}{\farg{nth}}
+and any iterator
+\tcode{j}\
+in the range
+\range{\farg{nth}}{\farg{last}}\
+it holds that:
+\tcode{!(*i > *j)}\
+or
+\tcode{\farg{comp}(*j, *i) == false}.
+
+\pnum
+\removedConcepts{Requires:
+The type of *first shall satisfy the
+Swappable requirements (20.1.4),
+the \mbox{\tcode{MoveConstructible}} requirements
+(Table~33), and the
+the \mbox{\tcode{MoveAssignable}} requirements
+(Table~35).}
+
+\pnum
+\complexity\
+Linear on average.
+\end{itemdescr}
+
+\rSec2[alg.binary.search]{Binary search}
+
+\pnum
+All of the algorithms in this section are versions of binary search
+and assume that the sequence being searched is partitioned with respect to
+an expression formed by binding the search key to an argument of the
+implied or explicit comparison function.
+They work on non-random access iterators minimizing the number of comparisons,
+which will be logarithmic for all types of iterators.
+They are especially appropriate for random access iterators,
+because these algorithms do a logarithmic number of steps
+through the data structure.
+For non-random access iterators they execute a linear number of steps.
+
+\rSec3[lib.lower.bound]{\tcode{lower_bound}}
+
+\index{lower_bound@\tcode{lower_bound}}%
+\color{addclr}\begin{itemdecl}
+template<ForwardIterator Iter, class T>
+ requires LessThanComparable<Iter::reference, T>
+ Iter lower_bound(Iter @\farg{first}@, Iter @\farg{last}@,
+ const T& @\farg{value}@);
+
+@\textcolor{addclr}{template}@<ForwardIterator Iter, class T, Predicate<Iter::reference, T> Compare>
+ requires CopyConstructible<Compare>
+ Iter lower_bound(Iter @\farg{first}@, Iter @\farg{last}@,
+ const T& @\farg{value}@, Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\requires\
+The elements
+\tcode{e}\
+of
+\range{\farg{first}}{\farg{last}}\
+are partitioned with respect to the expression
+\tcode{e < value}\
+or
+\tcode{\farg{comp}(e, value)}.
+
+\pnum
+\returns\
+The furthermost iterator
+\tcode{i}\
+in the range
+\crange{\farg{first}}{\farg{last}}
+such that for any iterator
+\tcode{j}\
+in the range
+\range{\farg{first}}{i}\
+the following corresponding conditions hold:
+\tcode{*j < \farg{value}}\
+or
+\tcode{\farg{comp}(*j, \farg{value}) != false}.
+
+\pnum
+\complexity\
+At most
+\tcode{log(\farg{last}\ - \farg{first}) + 1}\
+comparisons.
+\end{itemdescr}
+
+\rSec3[lib.upper.bound]{\tcode{upper_bound}}
+
+\index{upper_bound@\tcode{upper_bound}}%
+\color{addclr}\begin{itemdecl}
+template<ForwardIterator Iter, class T>
+ requires LessThanComparable<T, Iter::reference>
+ Iter upper_bound(Iter @\farg{first}@, Iter @\farg{last}@,
+ const T& @\farg{value}@);
+
+template<ForwardIterator Iter, class T, Predicate<T, Iter::reference> Compare>
+ requires CopyConstructible<Compare>
+ Iter upper_bound(Iter @\farg{first}@, Iter @\farg{last}@,
+ const T& @\farg{value}@, Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\requires\
+The elements
+\tcode{e}\
+of
+\range{\farg{first}}{\farg{last}}\
+are partitioned with respect to the expression
+\tcode{!(value < e)}\
+or
+\tcode{!\farg{comp}(\brk{}value, e)}.
+
+\pnum
+\returns\
+The furthermost iterator
+\tcode{i}\
+in the range
+\range{\farg{first}}{\farg{last}}\
+such that for any iterator
+\tcode{j}\
+in the range
+\range{\farg{first}}{i}\
+the following corresponding conditions hold:
+\tcode{!(value < *j)}\
+or
+\tcode{\farg{comp}(\farg{value}, *j) == false}.
+
+\pnum
+\complexity\
+At most
+\tcode{log(\farg{last}\ - \farg{first}) + 1}\
+comparisons.
+\end{itemdescr}
+
+\rSec3[lib.equal.range]{\tcode{equal_range}}
+
+\index{equal_range@\tcode{equal_range}}%
+\color{addclr}\begin{itemdecl}
+template<ForwardIterator Iter, class T>
+ requires LessThanComparable<T, Iter::reference> &&
+ LessThanComparable<Iter::reference, T>
+ pair<Iter, Iter>
+ equal_range(Iter @\farg{first}@,
+ Iter @\farg{last}@, const T& @\farg{value}@);
+
+template<ForwardIterator Iter, class T, class Compare>
+ requires Predicate<Compare, T, Iter::reference> &&
+ Predicate<Compare, Iter::reference, T> &&
+ CopyConstructible<Compare>
+ pair<Iter, Iter>
+ equal_range(Iter @\farg{first}@,
+ Iter @\farg{last}@, const T& @\farg{value}@,
+ Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\requires\
+The elements
+\tcode{e}\
+of
+\range{\farg{first}}{\farg{last}}\
+are partitioned with respect to the expressions
+\tcode{e < value}\
+and
+\tcode{!(value < e)}\
+or
+\tcode{\farg{comp}(e, value)}\
+and
+\tcode{!\farg{comp}(value, e)}.
+Also, for all elements
+\tcode{e}\
+of
+\tcode{[\farg{first}, \farg{last})},
+\tcode{e < value}\
+implies
+\tcode{!(value < e)}\
+or
+\tcode{\farg{comp}(e, value)}\
+implies
+\tcode{!\farg{comp}(value, e)}.
+
+\pnum
+\returns\
+\begin{codeblock}
+ make_pair(lower_bound(@\farg{first}@, @\farg{last}@, @\farg{value}@),
+ upper_bound(@\farg{first}@, @\farg{last}@, @\farg{value}@))
+\end{codeblock}
+or
+\begin{codeblock}
+ make_pair(lower_bound(@\farg{first}@, @\farg{last}@, @\farg{value}@, @\farg{comp}@),
+ upper_bound(@\farg{first}@, @\farg{last}@, @\farg{value}@, @\farg{comp}@))
+\end{codeblock}
+
+\pnum
+\complexity\
+At most
+\tcode{2 * log(\farg{last}\ - \farg{first}) + 1}\
+comparisons.
+\end{itemdescr}
+
+\rSec3[lib.binary.search]{\tcode{binary_search}}
+
+\index{binary_search@\tcode{binary_search}}%
+\color{addclr}\begin{itemdecl}
+template<ForwardIterator Iter, class T>
+ requires LessThanComparable<T, Iter::reference> &&
+ LessThanComparable<Iter::reference, T>
+ bool binary_search(ForwardIterator @\farg{first}@, ForwardIterator @\farg{last}@,
+ const T& @\farg{value}@);
+
+template<ForwardIterator Iter, class T, class Compare>
+ requires Predicate<Compare, T, Iter::reference> &&
+ Predicate<Compare, Iter::reference, T> &&
+ CopyConstructible<Compare>
+ bool binary_search(Iter @\farg{first}@, Iter @\farg{last}@,
+ const T& @\farg{value}@, Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\requires\
+The elements
+\tcode{e}\
+of
+\range{\farg{first}}{\farg{last}}\
+are partitioned with respect to the expressions
+\tcode{e < value}\
+and
+\tcode{!(value < e)}\
+or
+\tcode{\farg{comp}(e, value)}\
+and
+\tcode{!\farg{comp}(value, e)}.
+Also, for all elements
+\tcode{e}\
+of
+\tcode{[\farg{first}, \farg{last})},
+\tcode{e < value}\
+implies
+\tcode{!(value < e)}\
+or
+\tcode{\farg{comp}(e, value)}\
+implies
+\tcode{!\farg{comp}(value, e)}.
+
+\pnum
+\returns\
+\tcode{true}\
+if there is an iterator
+\tcode{i}\
+in the range
+\range{\farg{first}}{\farg{last}}\
+that satisfies the corresponding conditions:
+\tcode{!(*i < \farg{value}) \&\& !(\farg{value} < *i)}
+or
+\tcode{\farg{comp}(*i, \farg{value}) == false \&\& \farg{comp}(\farg{value}, *i) == false}.
+
+\pnum
+\complexity\
+At most
+\tcode{log(\farg{last}\ - \farg{first}) + 2}\
+comparisons.
+\end{itemdescr}
+
+\rSec2[alg.merge]{Merge}
+
+\index{merge@\tcode{merge}}%
+\color{addclr}\begin{itemdecl}
+template<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter>
+ @\textcolor{addclr}{requires}@ SameType<InIter1::value_type, InIter2::value_type> &&
+ LessThanComparable<InIter1::value_type>
+ OutIter merge(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ OutIter @\farg{result}@);
+
+@\textcolor{addclr}{template}@<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter,
+ Predicate<InIter1::value_type, InIter2::value_type> Compare>
+ requires SameType<InIter1::value_type, InIter2::value_type> &&
+ CopyConstructible<Compare>
+ OutIter merge(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ OutIter @\farg{result}@, Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Merges two sorted ranges
+\range{\farg{first1}}{\farg{last1}}\
+and
+\range{\farg{first2}}{\farg{last2}}\
+into the range
+\range{\farg{result}}{\farg{result}\ + (\farg{last1}\ - \farg{first1}) + (\farg{last2}\ - \farg{first2})}.
+
+\pnum
+The resulting range shall not overlap with either of the original ranges.
+The list will be sorted in non-decreasing order according to the
+ordering defined by
+\tcode{\farg{comp}};
+that is, for every iterator
+\tcode{i}\
+in
+\range{\farg{first}}{\farg{last}}\
+other than
+\tcode{\farg{first}},
+the condition
+\tcode{*i < *(i - 1)}\
+or
+\tcode{\farg{comp}(*i, *(i - 1))}\
+will be false.
+
+\pnum
+\returns\
+\tcode{\farg{result}\ + (\farg{last1}\ - \farg{first1}) + (\farg{last2}\ - \farg{first2})}.
+
+\pnum
+\complexity\
+At most
+\tcode{(\farg{last1}\ - \farg{first1}) + (\farg{last2}\ - \farg{first2}) - 1}\
+comparisons.
+
+\pnum
+\notes\
+Stable.
+\end{itemdescr}
+
+\index{inplace_merge@\tcode{inplace_merge}}%
+\color{addclr}\begin{itemdecl}
+@\textcolor{addclr}{template}@<MutableBidirectionalIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ LessThanComparable<Iter::value_type>
+ void inplace_merge(Iter @\farg{first}@,
+ Iter @\farg{middle}@,
+ Iter @\farg{last}@);
+
+template<MutableBidirectionalIterator Iter,
+ Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ CopyConstructible<Compare>
+ void inplace_merge(Iter @\farg{first}@,
+ Iter @\farg{middle}@,
+ Iter @\farg{last}@, Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Merges two sorted consecutive ranges
+\range{\farg{first}}{\farg{middle}}\
+and
+\range{\farg{middle}}{\farg{last}},
+putting the result of the merge into the range
+\range{\farg{first}}{\farg{last}}.
+The resulting range will be in non-decreasing order;
+that is, for every iterator
+\tcode{i}\
+in
+\range{\farg{first}}{\farg{last}}\
+other than
+\tcode{\farg{first}},
+the condition
+\tcode{*i < *(i - 1)}
+or, respectively,
+\tcode{\farg{comp}(*i, *(i - 1))}\
+will be false.
+
+\pnum
+\removedConcepts{Requires:
+The type of *first shall satisfy the
+Swappable requirements (20.1.4),
+the \mbox{\tcode{MoveConstructible}} requirements
+(Table~33), and the
+the \mbox{\tcode{MoveAssignable}} requirements
+(Table~35).}
+
+\pnum
+\complexity\
+When enough additional memory is available,
+\tcode{(\farg{last}\ - \farg{first}) - 1}\
+comparisons.
+If no additional memory is available, an algorithm with complexity
+$N \log(N)$
+(where
+\tcode{N}
+is equal to
+\tcode{\farg{last}\ - \farg{first}})\
+may be used.
+
+\pnum
+\notes\
+Stable.
+\end{itemdescr}
+
+\rSec2[alg.set.operations]{Set operations on sorted structures}
+
+\pnum
+This section defines all the basic set operations on sorted structures.
+They also work with
+\tcode{multiset}s~(\ref{lib.multiset})
+containing multiple copies of equivalent elements.
+The semantics of the set operations are generalized to
+\tcode{multiset}s
+in a standard way by defining
+\tcode{set_union()}\
+to contain the maximum number of occurrences of every element,
+\tcode{set_intersection()}\
+to contain the minimum, and so on.
+
+\rSec3[lib.includes]{\tcode{includes}}
+
+\index{includes@\tcode{includes}}%
+\color{addclr}\begin{itemdecl}
+template<InputIterator Iter1, InputIterator Iter2>
+ requires SameType<Iter1::value_type, Iter2::value_type> && LessThanComparable<Iter1::value_type>
+ bool includes(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@);
+
+template<InputIterator Iter1, InputIterator Iter2,
+ Predicate<Iter1::value_type, Iter2::value_type> Compare>
+ requires SameType<Iter1::value_type, Iter2::value_type> && CopyConstructible<Compare>
+ bool includes(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@,
+ Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{true}\
+if every element in the range
+\range{\farg{first2}}{\farg{last2}}\
+is contained in the range
+\range{\farg{first1}}{\farg{last1}}.
+Returns
+\tcode{false}\
+otherwise.
+
+\textcolor{black}{\pnum}
+\complexity\
+At most
+\tcode{2 * ((\farg{last1}\ - \farg{first1}) + (\farg{last2}\ - \farg{first2})) - 1}\
+comparisons.
+\end{itemdescr}
+
+\rSec3[lib.set.union]{\tcode{set_union}}
+
+\index{set_union@\tcode{set_union}}%
+\color{addclr}\begin{itemdecl}
+template<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter>
+ requires SameType<InIter1::value_type, InIter2::value_type> &&
+ LessThanComparable<InIter1::value_type>
+ OutIter set_union(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ OutIter @\farg{result}@);
+
+template<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter,
+ Predicate<InIter1::value_type, InIter2::value_type> Compare>
+ requires SameType<InIter1::value_type, InIter2::value_type> && CopyConstructible<Compare>
+ OutIter set_union(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ OutIter @\farg{result}@, Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Constructs a sorted union of the elements from the two ranges;
+that is, the set of elements that are present in one or both of the ranges.
+
+\pnum
+\requires\
+The resulting range shall not overlap with either of the original ranges.
+
+\pnum
+\returns\
+The end of the constructed range.
+
+\textcolor{black}{\pnum}
+\complexity\
+At most
+\tcode{2 * ((\farg{last1}\ - \farg{first1}) + (\farg{last2}\ - \farg{first2})) - 1}\
+comparisons.
+
+\pnum
+\notes\ If \range{first1}{last1}\ contains $m$ elements that are equivalent to
+each other and \range{first2}{last2}\ contains $n$ elements that are equivalent
+to them, then all $m$ elements from the first range shall be copied to the output
+range, in order, and then $\max(n - m, 0)$ elements from the second range shall
+be copied to the output range, in order.
+\end{itemdescr}
+
+\rSec3[lib.set.intersection]{\tcode{set_intersection}}
+
+\index{set_intersection@\tcode{set_intersection}}%
+\color{addclr}\begin{itemdecl}
+template<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter>
+ requires SameType<InIter1::value_type, InIter2::value_type> &&
+ LessThanComparable<InIter1::value_type>
+ OutIter set_intersection(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ OutIter @\farg{result}@);
+
+template<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter,
+ Predicate<InIter1::value_type, InIter2::value_type> Compare>
+ requires SameType<InIter1::value_type, InIter2::value_type> && CopyConstructible<Compare>
+ OutIter set_intersection(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ OutIter @\farg{result}@, Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Constructs a sorted intersection of the elements from the two ranges;
+that is, the set of elements that are present in both of the ranges.
+
+\pnum
+\requires\
+The resulting range shall not overlap with either of the original ranges.
+
+\pnum
+\returns\
+The end of the constructed range.
+
+\pnum
+\complexity\
+At most
+\tcode{2 * ((\farg{last1}\ - \farg{first1}) + (\farg{last2}\ - \farg{first2})) - 1}\
+comparisons.
+
+\pnum
+\notes\ If \range{first1}{last1}\ contains $m$ elements that are equivalent to
+each other and \range{first2}{last2}\ contains $n$ elements that are equivalent
+to them, the first $\min(m, n)$ elements shall be copied from the first range
+to the output range, in order.
+\end{itemdescr}
+
+\rSec3[lib.set.difference]{\tcode{set_difference}}
+
+\index{set_difference@\tcode{set_difference}}%
+\color{addclr}\begin{itemdecl}
+template<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter>
+ requires SameType<InIter1::value_type, InIter2::value_type> &&
+ @\textcolor{addclr}{LessThanComparable}@<InIter1::value_type>
+ OutIter set_difference(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ @\textcolor{addclr}{OutIter}@ @\farg{result}@);
+
+template<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter,
+ Predicate<InIter1::value_type, InIter2::value_type> Compare>
+ requires SameType<InIter1::value_type, InIter2::value_type> && CopyConstructible<Compare>
+ OutIter set_difference(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ OutIter @\farg{result}@, Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Copies the elements of the range
+\range{\farg{first1}}{\farg{last1}}\
+which are not present in the range
+\range{\farg{first2}}{\farg{last2}}\
+to the range beginning at
+\tcode{result}.
+The elements in the constructed range are sorted.
+
+\pnum
+\requires\
+The resulting range shall not overlap with either of the original ranges.
+
+\pnum
+\returns\
+The end of the constructed range.
+
+\pnum
+\complexity\
+At most
+\tcode{2 * ((\farg{last1}\ - \farg{first1}) + (\farg{last2}\ - \farg{first2})) - 1}\
+comparisons.
+
+\pnum
+\notes\
+If
+\range{first1}{last1}\
+contains $m$
+elements that are equivalent to each other and
+\range{first2}{last2}\
+contains $n$
+elements that are equivalent to them, the last
+$\max(m - n, 0)$
+elements from
+\range{first1}{last1}\
+shall be \color{black}copied to the output range.
+\end{itemdescr}
+
+\rSec3[lib.set.symmetric.difference]{\tcode{set_symmetric_difference}}
+
+\index{set_symmetric_difference@\tcode{set_symmetric_difference}}%
+\color{addclr}\begin{itemdecl}
+template<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter>
+ requires SameType<InIter1::value_type, InIter2::value_type> &&
+ LessThanComparable<InIter1::value_type>
+ OutIter set_symmetric_difference(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ OutIter @\farg{result}@);
+
+template<InputIterator InIter1, InputIterator InIter2,
+ OutputIterator<InIter1::value_type> OutIter,
+ Predicate<InIter1::value_type, InIter2::value_type> Compare>
+ requires SameType<InIter1::value_type, InIter2::value_type> && CopyConstructible<Compare>
+ OutIter set_symmetric_difference(InIter1 @\farg{first1}@, InIter1 @\farg{last1}@,
+ InIter2 @\farg{first2}@, InIter2 @\farg{last2}@,
+ OutIter @\farg{result}@, Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Copies the elements of the range
+\range{\farg{first1}}{\farg{last1}}\
+which are not present in the range
+\range{\farg{first2}}{\farg{last2}},
+and the elements of the range
+\range{\farg{first2}}{\farg{last2}}\
+which are not present in the range
+\range{\farg{first1}}{\farg{last1}}\
+to the range beginning at
+\tcode{result}.
+The elements in the constructed range are sorted.
+
+\pnum
+\requires\
+The resulting range shall not overlap with either of the original ranges.
+
+\pnum
+\returns\
+The end of the constructed range.
+
+\textcolor{black}{\pnum}
+\complexity\
+At most
+\tcode{2 * ((\farg{last1}\ - \farg{first1}) + (\farg{last2}\ - \farg{first2})) - 1}\
+comparisons.
+
+\pnum
+\notes\
+If \range{first1}{last1}\ contains $m$ elements that are equivalent to each other and
+\range{first2}{last2}\ contains $n$ elements that are equivalent to them, then
+$|m - n|$ of those elements shall be copied to the output range: the last
+$m - n$ of these elements from \range{first1}{last1}\ if $m > n$, and the last
+$n - m$ of these elements from \range{first2}{last2}\ if $m < n$.
+\end{itemdescr}
+
+\rSec2[alg.heap.operations]{Heap operations}
+
+\pnum
+A
+\techterm{heap}\
+is a particular organization of elements in a range between two random access iterators
+\range{a}{b}.
+Its two key properties are:
+
+\begin{description}
+\item{(1)} There is no element greater than
+\tcode{*a}\
+in the range and
+\item{(2)} \tcode{*a}\
+may be removed by
+\tcode{pop_heap()},
+or a new element added by
+\tcode{push_heap()},
+in
+$\mathcal{O}(\log(N))$
+time.
+\end{description}
+
+\pnum
+These properties make heaps useful as priority queues.
+
+\pnum
+\tcode{make_heap()}\
+converts a range into a heap and
+\tcode{sort_heap()}\
+turns a heap into a sorted sequence.
+
+\rSec3[lib.push.heap]{\tcode{push_heap}}
+
+\index{push_heap@\tcode{push_heap}}%
+\color{addclr}\begin{itemdecl}
+template<MutableRandomAccessIterator Iter>
+ requires MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ LessThanComparable<Iter::value_type>
+ void push_heap(Iter @\farg{first}@, Iter @\farg{last}@);
+
+template<MutableRandomAccessIterator Iter, Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ CopyConstructible<Compare>
+ void push_heap(Iter @\farg{first}@, Iter @\farg{last}@,
+ Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Places the value in the location
+\tcode{\farg{last} - 1}\
+into the resulting heap
+\range{\farg{first}}{\farg{last}}.
+
+\pnum
+\requires\
+The range
+\range{\farg{first}}{\farg{last} - 1}\
+shall be a valid heap.
+\removedConcepts{The type of \mbox{\tcode{*first}} shall satisfy
+the \mbox{\tcode{MoveConstructible}} requirements
+(Table~\mbox{\ref{moveconstructible}}) and the
+the \mbox{\tcode{MoveAssignable}} requirements
+(Table~\mbox{\ref{moveassignable}}).}
+
+\pnum
+\complexity\
+At most
+\tcode{log(\farg{last}\ - \farg{first})}\
+comparisons.
+\end{itemdescr}
+
+\rSec3[lib.pop.heap]{\tcode{pop_heap}}
+
+\index{pop_heap@\tcode{pop_heap}}%
+\color{addclr}\begin{itemdecl}
+template<MutableRandomAccessIterator Iter>
+ requires MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ Swappable<Iter::value_type> && LessThanComparable<Iter::value_type>
+ void pop_heap(Iter @\farg{first}@, Iter @\farg{last}@);
+
+template<MutableRandomAccessIterator Iter, Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ Swappable<Iter::value_type> && CopyConstructible<Compare>
+ void pop_heap(Iter @\farg{first}@, Iter @\farg{last}@,
+ Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Swaps the value in the location \farg{first}\
+with the value in the location
+\tcode{\farg{last} - 1}\
+and makes
+\range{\farg{first}}{\farg{last} - 1}\
+into a heap.
+
+\pnum
+\requires\
+The range
+\range{\farg{first}}{\farg{last}}\
+shall be a valid heap.
+\removedConcepts{
+The type of *first shall satisfy the
+Swappable requirements (20.1.4),
+the \mbox{\tcode{MoveConstructible}} requirements
+(Table~\mbox{\ref{moveconstructible}}), and the
+the \mbox{\tcode{MoveAssignable}} requirements
+(Table~\mbox{\ref{moveassignable}}).}
+
+\pnum
+\complexity\
+At most
+\tcode{2 * log(\farg{last}\ - \farg{first})}\
+comparisons.
+\end{itemdescr}
+
+\rSec3[lib.make.heap]{\tcode{make_heap}}
+
+\index{make_heap@\tcode{make_heap}}%
+\color{addclr}\begin{itemdecl}
+template<MutableRandomAccessIterator Iter>
+ requires MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ LessThanComparable<Iter::value_type>
+ void make_heap(Iter @\farg{first}@, Iter @\farg{last}@);
+
+@\color{addclr}@template<MutableRandomAccessIterator Iter, Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ CopyConstructible<Compare>
+ void make_heap(Iter @\farg{first}@, Iter @\farg{last}@,
+ Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Constructs a heap out of the range
+\range{\farg{first}}{\farg{last}}.
+
+\pnum
+\removedConcepts{\mbox{\requires} The type of \mbox{\tcode{*first}} shall satisfy
+the \mbox{\tcode{MoveConstructible}} requirements
+(Table~\mbox{\ref{moveconstructible}}) and the
+the \mbox{\tcode{MoveAssignable}} requirements
+(Table~\mbox{\ref{moveassignable}}).}
+
+\pnum
+\complexity\
+At most
+\tcode{3 * (\farg{last}\ - \farg{first})}\
+comparisons.
+\end{itemdescr}
+
+\rSec3[lib.sort.heap]{\tcode{sort_heap}}
+
+\index{sort_heap@\tcode{sort_heap}}%
+\color{addclr}\begin{itemdecl}
+template<MutableRandomAccessIterator Iter>
+ requires MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ Swappable<Iter::value_type> && LessThanComparable<Iter::value_type>
+ void sort_heap(Iter @\farg{first}@, Iter @\farg{last}@);
+
+template<MutableRandomAccessIterator Iter, Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires MoveConstructible<Iter::value_type> && MoveAssignable<Iter::value_type> &&
+ Swappable<Iter::value_type> && CopyConstructible<Compare>
+ void sort_heap(Iter @\farg{first}@, Iter @\farg{last}@,
+ Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Sorts elements in the heap
+\range{\farg{first}}{\farg{last}}.
+
+\pnum
+\removedConcepts{Requires:
+The type of *first shall satisfy the
+Swappable requirements (20.1.4),
+the \mbox{\tcode{MoveConstructible}} requirements
+(Table~\mbox{\ref{moveconstructible}}), and the
+the \mbox{\tcode{MoveAssignable}} requirements
+(Table~\mbox{\ref{moveassignable}}).}
+
+\pnum
+\complexity\
+At most $N \log(N)$
+comparisons (where
+\tcode{N == \farg{last}\ - \farg{first}}).
+\end{itemdescr}
+
+\rSec3[is.heap]{\tcode{is_heap}}
+
+\index{is_heap@\tcode{is_heap}}%
+\color{addclr}
+\begin{itemdecl}
+template<RandomAccessIterator Iter>
+ requires LessThanComparable<Iter::value_type>
+ bool is_heap(Iter first, Iter last);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\addedD{\mbox{\returns} \mbox{\tcode{is_heap_until(first, last) == last}}}
+\end{itemdescr}
+
+\color{addclr}
+\begin{itemdecl}
+template<RandomAccessIterator Iter, Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires CopyConstructible<Compare>
+ bool is_heap(Iter first, Iter last, Compare comp);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\addedD{\mbox{\returns} \mbox{\tcode{is_heap_until(first, last, comp) == last}}}
+\end{itemdescr}
+
+\color{addclr}
+\begin{itemdecl}
+template<RandomAccessIterator Iter>
+ Iter is_heap_until(Iter first, Iter last);
+template<RandomAccessIterator Iter, Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires CopyConstructible<Compare>
+ Iter is_heap_until(Iter first, Iter last,
+ Compare comp);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\addedD{\mbox{\returns} If \mbox{\tcode{distance(first, last) < 2}}, returns
+\mbox{\tcode{last}}. Otherwise, returns
+the last iterator \mbox{\tcode{i}} in \mbox{\crange{first}{last}} for which the
+range \mbox{\range{first}{i}} is a heap.}
+
+\pnum
+\addedD{\mbox{\complexity} Linear.}
+\end{itemdescr}
+
+\rSec2[alg.min.max]{Minimum and maximum}
+
+\index{min@\tcode{min}}%
+\color{addclr}\begin{itemdecl}
+template<LessThanComparable T> const T& min(const T& @\farg{a}@, const T& @\farg{b}@);
+template<class T, Predicate<T, T> Compare>
+ requires CopyConstructible<Compare>
+ const T& min(const T& @\farg{a}@, const T& @\farg{b}@, Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{Requires:
+Type
+T
+is
+LessThanComparable~(20.1.2).}
+
+\pnum
+\returns\
+The smaller value.
+
+\pnum
+\notes\
+Returns the first argument when the arguments are equivalent.
+\end{itemdescr}
+
+\index{max@\tcode{max}}%
+\color{addclr}\begin{itemdecl}
+template<LessThanComparable T> const T& max(const T& @\farg{a}@, const T& @\farg{b}@);
+template<class T, Predicate<T, T> Compare>
+ requires CopyConstructible<Compare>
+ const T& max(const T& @\farg{a}@, const T& @\farg{b}@, Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{Requires:
+Type
+T
+is
+LessThanComparable~(20.1.2).}
+
+\pnum
+\returns\
+The larger value.
+
+\pnum
+\notes\
+Returns the first argument when the arguments are equivalent.
+\end{itemdescr}
+
+\index{minmax@\tcode{minmax}}%
+\color{addclr}
+\begin{itemdecl}
+template<LessThanComparable T> pair<const T&, const T&> minmax(const T& @\farg{a}@, const T& @\farg{b}@);
+template<class T, Predicate<T, T> Compare>
+ requires CopyConstructible<Compare>
+ @\textcolor{addclr}{pair}@<const T&, const T&> minmax(const T& @\farg{a}@, const T& @\farg{b}@, Compare @\farg{comp}@);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{\mbox{\requires}
+Type
+\mbox{\tcode{T}}
+shall be
+\mbox{\tcode{LessThanComparable}}~(\mbox{\ref{lessthancomparable}}).}
+
+\pnum
+\addedB{\mbox{\returns}
+\mbox{\tcode{pair<const T\&, const T\&>(b, a)}} if \mbox{\tcode{b}} is smaller
+than \mbox{\tcode{a}}, and
+\mbox{\tcode{pair<const T\&, const T\&>(a, b)}} otherwise.}
+
+\pnum
+\addedB{\mbox{\notes}
+Returns \mbox{\tcode{<pair<const T\&, const T\&>(a, b)}} when the arguments are equivalent.}
+
+\pnum
+\addedB{\mbox{\complexity}
+Exactly one comparison.}
+\end{itemdescr}
+
+\index{min_element@\tcode{min_element}}%
+\color{addclr}\begin{itemdecl}
+template<ForwardIterator Iter>
+ requires LessThanComparable<Iter::reference>
+ Iter min_element(Iter @\farg{first}@, Iter @\farg{last}@);
+
+template<ForwardIterator Iter, Predicate<Iter::reference, Iter::reference> Compare>
+ requires CopyConstructible<Compare>
+ Iter min_element(Iter @\farg{first}@, Iter @\farg{last}@,
+ Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\returns\
+The first iterator
+\tcode{i}\
+in the range
+\range{\farg{first}}{\farg{last}}\
+such that for any iterator
+\tcode{j}\
+in the range
+\range{\farg{first}}{\farg{last}}\
+the following corresponding conditions hold:
+\tcode{!(*j < *i)}\
+or
+\tcode{\farg{comp}(*j, *i) == false}.
+Returns
+\tcode{\farg{last}}\
+if
+\tcode{\farg{first} == \farg{last}}.
+
+\pnum
+\complexity\
+Exactly
+\tcode{max((\farg{last} - \farg{first}) - 1, 0)}\
+applications of the corresponding comparisons.
+\end{itemdescr}
+
+\index{max_element@\tcode{max_element}}%
+\color{addclr}\begin{itemdecl}
+template<ForwardIterator Iter>
+ requires LessThanComparable<Iter::reference>
+ Iter max_element(Iter @\farg{first}@, Iter @\farg{last}@);
+
+template<ForwardIterator Iter, Predicate<Iter::reference, Iter::reference> Compare>
+ requires CopyConstructible<Compare>
+ Iter max_element(Iter @\farg{first}@, Iter @\farg{last}@,
+ Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\returns\
+The first iterator
+\tcode{i}\
+in the range
+\range{\farg{first}}{\farg{last}}\
+such that for any iterator
+\tcode{j}\
+in the range
+\range{\farg{first}}{\farg{last}}\
+the following corresponding conditions hold:
+\tcode{!(*i < *j)}
+or
+\tcode{\farg{comp}(*i, *j) == false}.
+Returns
+\tcode{\farg{last}}\
+if
+\tcode{\farg{first} == \farg{last}}.
+
+\pnum
+\complexity\
+Exactly
+\tcode{max((\farg{last}\ - \farg{first}) - 1, 0)}\
+applications of the corresponding comparisons.
+\end{itemdescr}
+
+\index{minmax_element@\tcode{minmax_element}}%
+\color{addclr}
+\begin{itemdecl}
+template<ForwardIterator Iter>
+ requires LessThanComparable<Iter::value_type>
+ pair<Iter, Iter>
+ minmax_element(Iter @\farg{first}@, Iter @\farg{last}@);
+template<ForwardIterator Iter, Predicate<Iter::value_type, Iter::value_type> Compare>
+ requires CopyConstructible<Compare>
+ pair<Iter, Iter>
+ minmax_element(Iter @\farg{first}@, Iter @\farg{last}@, Compare @\farg{comp}@);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\addedB{\mbox{\returns}
+\mbox{\tcode{make_pair(m, M)}}, where \mbox{\tcode{m}} is
+\mbox{\tcode{min_element(first, last)}}
+or \mbox{\tcode{min_element(first, last, comp)}}
+and \mbox{\tcode{M}} is \mbox{\tcode{max_element(first, last)}}
+or \mbox{\tcode{max_element(first, last, comp)}}.}
+
+\pnum
+\addedB{\mbox{\complexity}
+At most
+\mbox{\tcode{max(2 * (\farg{last} - \farg{first}) - 2, 0)}}
+applications of the corresponding comparisons.}
+\end{itemdescr}
+
+\rSec2[alg.lex.comparison]{Lexicographical comparison}
+
+\index{lexicographical_compare@\tcode{lexicographical_compare}}%
+\color{addclr}\begin{itemdecl}
+template<InputIterator Iter1, InputIterator Iter2>
+ requires LessThanComparable<Iter1::reference, Iter2::reference> &&
+ LessThanComparable<Iter2::reference, Iter1::reference>
+ bool lexicographical_compare(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@);
+
+template<InputIterator Iter1, InputIterator Iter2, class Compare>
+ requires Predicate<Compare, Iter1::reference, Iter2::reference> &&
+ Predicate<Compare, Iter2::reference, Iter1::reference>
+ CopyConstructible<Compare>
+ bool lexicographical_compare(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, Iter2 @\farg{last2}@,
+ Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{true}\
+if the sequence of elements defined by the range
+\range{\farg{first1}}{\farg{last1}}\
+is lexicographically less than the sequence of elements defined by the range
+\range{\farg{first2}}{\farg{last2}}.
+
+Returns
+\tcode{false}\
+otherwise.
+
+\pnum
+\complexity\
+At most
+\tcode{2*min((\farg{last1}\ - \farg{first1}), (\farg{last2}\ - \farg{first2}))}\
+applications of the corresponding comparison.
+
+\pnum
+\notes\
+If two sequences have the same number of elements and their corresponding
+elements are equivalent, then neither sequence is lexicographically
+less than the other.
+If one sequence is a prefix of the other, then the shorter sequence is
+lexicographically less than the longer sequence.
+Otherwise, the lexicographical comparison of the sequences yields the same
+result as the comparison of the first corresponding pair of
+elements that are not equivalent.
+
+\begin{codeblock}
+for ( ; @\farg{first1}@ != @\farg{last1}@ && @\farg{first2}@ != @\farg{last2}@ ; @\farg{++first1}@, @\farg{++first2}@) {
+ if (*@\farg{first1}@ < *@\farg{first2}@) return true;
+ if (*@\farg{first2}@ < *@\farg{first1}@) return false;
+}
+return @\farg{first1}@ == @\farg{last1}@ && @\farg{first2}@ != @\farg{last2}@;
+\end{codeblock}
+\end{itemdescr}
+
+\rSec2[alg.permutation.generators]{Permutation generators}
+
+\index{next_permutation@\tcode{next_permutation}}%
+\color{addclr}\begin{itemdecl}
+template<MutableBidirectionalIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ LessThanComparable<Iter::reference>
+ bool next_permutation(Iter @\farg{first}@, Iter @\farg{last}@);
+
+template<MutableBidirectionalIterator Iter, Predicate<Iter::reference, Iter::reference> Compare>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ CopyConstructible<Compare>
+ @\textcolor{addclr}{bool}@ next_permutation(Iter @\farg{first}@, Iter @\farg{last}@, Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Takes a sequence defined by the range
+\range{\farg{first}}{\farg{last}}\
+and transforms it into the next permutation.
+The next permutation is found by assuming that the set of all permutations is
+lexicographically sorted with respect to
+\tcode{operator<}\
+or \farg{comp}.
+If such a permutation exists, it returns
+\tcode{true}.
+Otherwise, it transforms the sequence into the smallest permutation,
+that is, the ascendingly sorted one, and returns
+\tcode{false}.
+
+\pnum
+\removedConcepts{Requires:
+The type of first shall satisfy the
+Swappable requirements (20.1.4).}
+
+\pnum
+\complexity\
+At most
+\tcode{(\farg{last}\ - \farg{first})/2}\
+swaps.
+\end{itemdescr}
+
+\index{prev_permutation@\tcode{prev_permutation}}%
+\color{addclr}\begin{itemdecl}
+template<MutableBidirectionalIterator Iter>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ LessThanComparable<Iter::reference>
+ bool prev_permutation(Iter @\farg{first}@, Iter @\farg{last}@);
+
+template<MutableBidirectionalIterator Iter, Predicate<Iter::reference, Iter::reference> Compare>
+ requires SameType<Iter::value_type&, Iter::reference> && Swappable<Iter::value_type> &&
+ CopyConstructible<Compare>
+ bool prev_permutation(Iter @\farg{first}@, Iter @\farg{last}@, Compare @\farg{comp}@);
+\end{itemdecl}\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Takes a sequence defined by the range
+\range{\farg{first}}{\farg{last}}\
+and transforms it into the previous permutation.
+The previous permutation is found by assuming that the set of all permutations is
+lexicographically sorted with respect to
+\tcode{operator<}\
+or \farg{comp}.
+
+\pnum
+\returns\
+\tcode{true}\
+if such a permutation exists.
+Otherwise, it transforms the sequence into the largest permutation,
+that is, the descendingly sorted one, and returns
+\tcode{false}.
+
+\pnum
+\removedConcepts{Requires:
+The type of *first shall satisfy the
+Swappable requirements (20.1.4).}
+
+\pnum
+\complexity\
+At most
+\tcode{(\farg{last}\ - \farg{first})/2}\
+swaps.
+\end{itemdescr}
+
+\end{paras}
+
+\bibliographystyle{plain}
+\bibliography{../local}
+
+\end{document}
\ No newline at end of file

Added: sandbox/committee/concepts/stdlib/clib-concepts.tex
==============================================================================
--- (empty file)
+++ sandbox/committee/concepts/stdlib/clib-concepts.tex 2008-03-03 15:03:07 EST (Mon, 03 Mar 2008)
@@ -0,0 +1,1673 @@
+\documentclass[american,twoside]{book}
+\usepackage{hyperref}
+\usepackage{refbib}
+\usepackage{pdfsync}
+\input{macros}
+
+%%--------------------------------------------------
+%% Set section numbering limit, toc limit
+\setcounter{secnumdepth}{5}
+\setcounter{tocdepth}{1}
+
+%%--------------------------------------------------
+%% Parameters that govern document appearance
+\setlength{\oddsidemargin}{0pt}
+\setlength{\evensidemargin}{0pt}
+\setlength{\textwidth}{6.6in}
+
+%%--------------------------------------------------
+%% Handle special hyphenation rules
+\hyphenation{tem-plate ex-am-ple in-put-it-er-a-tor}
+
+% Do not put blank pages after chapters that end on odd-numbered pages.
+\def\cleardoublepage{\clearpage\if_at_twoside%
+ \ifodd\c_at_page\else\hbox{}\thispagestyle{empty}\newpage%
+ \if_at_twocolumn\hbox{}\newpage\fi\fi\fi}
+
+\newsavebox\rebindbox
+
+\begin{document}
+\raggedbottom
+
+\begin{titlepage}
+\begin{center}
+\huge
+Core Concepts for the C++0x Standard Library
+\vspace{0.5in}
+
+\normalsize
+Douglas Gregor and Andrew Lumsdaine \\
+Open Systems Laboratory \\
+Indiana University \\
+Bloomington, IN\ \ 47405 \\
+\{\href{mailto:dgregor_at_[hidden]}{dgregor}, \href{mailto:lums_at_[hidden]}{lums}\}@osl.iu.edu
+\end{center}
+
+\vspace{1in}
+\par\noindent Document number: \vspace{-6pt}
+\par\noindent Revises document number: N2502=08-0012\vspace{-6pt}
+\par\noindent Date: \today\vspace{-6pt}
+\par\noindent Project: Programming Language \Cpp{}, Library Working Group\vspace{-6pt}
+\par\noindent Reply-to: Douglas Gregor $<$\href{mailto:dgregor_at_[hidden]}{dgregor_at_[hidden]}$>$\vspace{-6pt}
+
+\section*{Introduction}
+This document proposes basic support for concepts in the \Cpp0x
+Standard Library. It describes a new header \tcode{<concepts>} that
+contains concepts that require compiler support (such as
+\tcode{SameType} and \tcode{ObjectType}) and concepts that describe
+common type behaviors likely to be used in many templates, including
+those in the Standard Library (such as \tcode{CopyConstructible} and
+\tcode{EqualityComparable}).
+
+This proposal adds new functionality into the Standard Library for
+concepts, and is meant as a companion to the language wording for
+concepts, since some of the language wording depends on this library
+wording. More thorough changes to the Standard Library will follow in
+future revisions of the ``Concepts for the \Cpp0x Standard Library''
+proposals.
+
+The concepts in this proposal replace the requirements tables
+currently in [utility.requirements]. This leaves the Standard Library
+in an interesting (but consistent!) state, where the template
+requirements of the Standard Library are described in terms of actual
+concepts, but the templates themselves are not constrained
+templates. For example, a type \tcode{T} in a Standard Library
+algorithm might be stated to be \tcode{CopyConstructible} in the
+current text: previously, that text referred to a requirements table
+for \tcode{CopyConstructible}, whereas now it refers to the
+\tcode{CopyConstructible} concept itself. When the Standard Library is
+fully evolved to use concepts, this informally-stated requirement that
+\tcode{T} is \tcode{CopyConstructible} will be made formal by a
+\tcode{requires} clause stating \tcode{CopyConstructible<T>}. Thus,
+the approach of this proposal is designed to provide an evolutionary
+step toward complete concepts support in the library, while
+improving the description of the library and support for concepts with
+each step.
+
+Within the proposed wording, text that has been added
+\textcolor{addclr}{will be presented in blue} \addedConcepts{and
+underlined when possible}. Text that has been removed will be
+presented \textcolor{remclr}{in red},\removedConcepts{with
+strike-through when possible}. Non-editorial
+changes from the previous wording are \addedCC{highlighted in green}.
+
+\editorial{Purely editorial comments will be written in a separate,
+ shaded box.}
+
+
+\end{titlepage}
+
+%%--------------------------------------------------
+%% Headers and footers
+\pagestyle{fancy}
+\fancyhead[LE,RO]{\textbf{\rightmark}}
+\fancyhead[RE]{\textbf{\leftmark\hspace{1em}\thepage}}
+\fancyhead[LO]{\textbf{\thepage\hspace{1em}\leftmark}}
+\fancyfoot[C]{Draft}
+
+\fancypagestyle{plain}{
+\renewcommand{\headrulewidth}{0in}
+\fancyhead[LE,RO]{}
+\fancyhead[RE,LO]{}
+\fancyfoot{}
+}
+
+\renewcommand{\sectionmark}[1]{\markright{\thesection\hspace{1em}#1}}
+\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
+
+\setcounter{chapter}{19}
+\rSec0[utilities]{General utilities library}
+\setcounter{Paras}{1}
+\textcolor{black}{\pnum}
+The following clauses describe utility and allocator \changedConcepts{requirements}{concepts}, utility
+components, \addedB{tuples, type traits templates,} function objects, dynamic
+memory management utilities, and date/time utilities, as summarized in
+Table~\ref{tab:util.lib.summary}.
+
+\setcounter{table}{29}
+\begin{libsumtab}{General utilities library summary}{tab:util.lib.summary}
+\ref{utility.concepts}
+\changedConcepts{Requirements}{Concepts} & \addedConcepts{\ttfamily <concepts>} \\ \rowsep
+\ref{utility} Utility components & \tcode{<utility>} \\ \rowsep
+\ref{tuple} \addedB{Tuples} & \tcode{\addedB{<tuple>}} \\ \rowsep
+\ref{meta} \addedB{Type traits} & \tcode{\addedB{<type_traits>}} \\ \rowsep
+\ref{function.objects} Function objects & \tcode{<functional>}\\ \rowsep
+ & \tcode{<memory>} \\
+\ref{memory} Memory & \tcode{<cstdlib>} \\
+ & \tcode{<cstring>} \\ \rowsep
+\ref{date.time} Date and time & \tcode{<ctime>} \\
+\end{libsumtab}
+
+\noindent\editorial{Replace the section [utility.requirements] with
+ the following section [utility.concepts]}
+
+\color{addclr}
+\rSec1[utility.concepts]{Concepts}
+
+\pnum The \tcode{<concepts>} header describes requirements on template
+arguments used throughout the \Cpp\ Standard Library.
+
+\synopsis{Header \tcode{<concepts>}\ synopsis}
+\begin{codeblock}
+namespace std {
+ // \ref{concept.support}, support concepts:
+ concept Returnable<typename T> { }
+ concept PointeeType<typename T> { }
+ concept ReferentType<typename T> @\textit{see below}@;
+ concept VariableType<typename T> { }
+ concept ObjectType<typename T> @\textit{see below}@;
+ concept ClassType<typename T> @\textit{see below}@;
+ concept Class<typename T> @\textit{see below}@;
+ concept Union<typename T> @\textit{see below}@;
+ concept TrivialType<typename T> @\textit{see below}@;
+ concept StandardLayoutType<typename T> @\textit{see below}@;
+ concept LiteralType<typename T> @\textit{see below}@;
+ concept ScalarType<typename T> @\textit{see below}@;
+ concept NonTypeTemplateParameterType<typename T> @\textit{see below}@;
+ concept IntegralConstantExpressionType<typename T> @\textit{see below}@;
+ concept IntegralType<typename T> @\textit{see below}@;
+ concept EnumerationType<typename T> @\textit{see below}@;
+ concept SameType<typename T, typename U> { }
+ concept DerivedFrom<typename Derived, typename Base> { }
+
+ // \ref{concept.comparison}, comparisons:
+ auto concept LessThanComparable<typename T, typename U = T> @\textit{see below}@;
+ auto concept EqualityComparable<typename T, typename U = T> @\textit{see below}@;
+ auto concept TriviallyEqualityComparable<typename T> @\textit{see below}@;
+
+ // \ref{concept.destruct}, destruction:
+ auto concept Destructible<typename T> @\textit{see below}@;
+ concept TriviallyDestructible<typename T> @\textit{see below}@;
+
+ // \ref{concept.construct}, construction:
+ auto concept Constructible<typename T, typename... Args> @\textit{see below}@;
+ auto concept DefaultConstructible<typename T> @\textit{see below}@;
+ concept TriviallyDefaultConstructible<typename T> @\textit{see below}@;
+
+ // \ref{concept.copymove}, copy and move:
+ auto concept MoveConstructible<typename T> @\textit{see below}@;
+ auto concept CopyConstructible<typename T> @\textit{see below}@;
+ concept TriviallyCopyConstructible<typename T> @\textit{see below}@;
+ auto concept MoveAssignable<typename T, typename U = T> @\textit{see below}@;
+ auto concept CopyAssignable<typename T, typename U = T> @\textit{see below}@;
+ concept TriviallyCopyAssignable<typename T> @\textit{see below}@;
+ auto concept Swappable<typename T> @\textit{see below}@;
+
+ // \ref{concept.memory}, memory allocation:
+ auto concept Newable<typename T, typename... Args> @\textit{see below}@;
+ auto concept Deletable<typename T> @\textit{see below}@;
+ auto concept ArrayNewable<typename T, typename... Args> @\textit{see below}@;
+ auto concept ArrayDeletable<typename T> @\textit{see below}@;
+ auto concept HeapAllocatable<typename T> @\textit{see below}@;
+
+ // \ref{concept.regular}, regular types:
+ auto concept Semiregular<typename T> @\textit{see below}@;
+ auto concept Regular<typename T> @\textit{see below}@;
+
+ // \ref{concept.convertible}, convertibility:
+ auto concept ExplicitlyConvertible<typename T, typename U> @\textit{see below}@;
+ auto concept Convertible<typename T, typename U> @\textit{see below}@;
+
+ // \ref{concept.true}, true:
+ concept True<bool> { }
+ concept_map True<true> { }
+
+ // \ref{concept.operator}, operator concepts:
+ auto concept HasPlus<typename T, typename U = T> @\textit{see below}@;
+ auto concept HasMinus<typename T, typename U = T> @\textit{see below}@;
+ auto concept HasMultiply<typename T, typename U = T> @\textit{see below}@;
+ auto concept HasDivide<typename T, typename U = T> @\textit{see below}@;
+ auto concept HasModulus<typename T, typename U = T> @\textit{see below}@;
+ auto concept HasUnaryPlus<typename T> @\textit{see below}@;
+ auto concept HasNegate<typename T> @\textit{see below}@;
+ auto concept HasLogicalAnd<typename T, typename U = T> @\textit{see below}@;
+ auto concept HasLogicalOr<typename T, typename U = T> @\textit{see below}@;
+ auto concept HasLogicalNot<typename T> @\textit{see below}@;
+ auto concept HasBitAnd<typename T, typename U = T> @\textit{see below}@;
+ auto concept HasBitOr<typename T, typename U = T> @\textit{see below}@;
+ auto concept HasBitXor<typename T, typename U = T> @\textit{see below}@;
+ auto concept HasComplement<typename T> @\textit{see below}@;
+ auto concept HasLeftShift<typename T, typename U = T> @\textit{see below}@;
+ auto concept HasRightShift<typename T, typename U = T> @\textit{see below}@;
+ auto concept Dereferenceable<typename T> @\textit{see below}@;
+ auto concept Addressable<typename T> @\textit{see below}@;
+ auto concept Callable<typename F, typename... Args> @\textit{see below}@;
+
+ // \ref{concept.arithmetic}, arithmetic concepts:
+ concept ArithmeticLike<typename T> @\textit{see below}@;
+ concept IntegralLike<typename T> @\textit{see below}@;
+ concept SignedIntegralLike<typename T> @\textit{see below}@;
+ concept UnsignedIntegralLike<typename T> @\textit{see below}@;
+ concept FloatingPointLike<typename T> @\textit{see below}@;
+
+ // \ref{concept.predicate}, predicates:
+ auto concept Predicate<typename F, typename... Args> @\textit{see below}@;
+
+ // \ref{concept.allocator}, allocators:
+ concept Allocator<typename X> @\textit{see below}@;
+ concept AllocatorGenerator<typename X> @\textit{see below}@;
+ template<Allocator X> concept_map AllocatorGenerator<X> @\textit{see below}@;
+}
+\end{codeblock}
+
+\rSec2[concept.support]{Support concepts}
+\pnum
+The concepts in [concept.support] provide the ability to state
+template requirements for C++ type classifications ([basic.types]) and
+type relationships that cannot be expressed directly with concepts
+([concept]). Concept maps for these concepts are implicitly defined.
+A program shall not provide concept maps for any concept in
+[concept.support].
+
+\begin{itemdecl}
+concept Returnable<typename T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} Describes types that can be used as the
+ return type of a function.}
+
+\pnum
+\addedConcepts{\mbox{\requires} for every type \mbox{\tcode{T}} that is
+ \mbox{\techterm{cv}} \mbox{\tcode{void}} or that meets the
+ requirement \mbox{\tcode{MoveConstructible<T>}}
+ (\mbox{\ref{concept.copymove}}), the concept map
+ \mbox{\tcode{Returnable<T>}} shall be implicitly defined in
+ namespace \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept PointeeType<typename T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note}
+describes types to which a pointer can be
+created.}
+
+\pnum
+\addedConcepts{\mbox{\requires}
+for every type \mbox{\tcode{T}} that is an object type,
+ function type, or \mbox{\techterm{cv}} \mbox{\tcode{void}}, a
+ concept map \mbox{\tcode{PointeeType}} shall be implicitly defined
+ in namespace \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept ReferentType<typename T> : PointeeType<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\mbox{\note}
+describes types to which a reference or pointer-to-member can be
+created.
+
+\pnum
+\mbox{\requires}
+for every type \mbox{\tcode{T}} that is an object type or
+ function type, a
+ concept map \mbox{\tcode{ReferentType}} shall be implicitly defined
+ in namespace \mbox{\tcode{std}}.
+\end{itemdescr}
+
+\begin{itemdecl}
+concept VariableType<typename T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types that can be used to
+ declare a variable.}
+
+\pnum
+\addedConcepts{\mbox{\requires} for every type \mbox{\tcode{T}} that
+ is an object type or reference type, a concept map
+ \mbox{\tcode{VariableType<T>}} shall be implicitly defined in
+namespace \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept ObjectType<typename T> : VariableType<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes object types ([basic.types]),
+ for which storage can be allocated.}
+
+\pnum
+\addedConcepts{\mbox{\requires} for every type \mbox{\tcode{T}} that
+ is an object type, a concept map
+ \mbox{\tcode{ObjectType<T>}} shall be implicitly defined in
+ namespace \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+
+\begin{itemdecl}
+concept ClassType<typename T> : ObjectType<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes class types (i.e., unions,
+ classes, and structs).}
+
+\pnum
+\addedConcepts{\mbox{\requires} for every type \mbox{\tcode{T}} that
+ is a class type ([class]), a concept map \mbox{\tcode{ClassType<T>}}
+ shall be implicitly defined in namespace \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept Class<typename T> : ClassType<Class> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes classes and structs ([class]).}
+
+\pnum
+\addedConcepts{\mbox{\requires} for every type \mbox{\tcode{T}} that
+ is a class or struct, a concept map
+ \mbox{\tcode{Class<T>}} shall be implicitly defined in namespace
+ \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept Union<typename T> : ClassType<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes union types ([class.union]).}
+
+\pnum
+\addedConcepts{\mbox{\requires} for every type \mbox{\tcode{T}} that
+ is a union, a concept map \mbox{\tcode{Union<T>}}
+ shall be implicitly defined in namespace \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept TrivialType<typename T> : ObjectType<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes trivial types ([basic.types]).}
+
+\pnum
+\addedConcepts{\mbox{\requires} for every type \mbox{\tcode{T}} that
+ is a trivial type, a concept map \mbox{\tcode{TrivialType<T>}} shall
+ be implicitly defined in namespace \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept StandardLayoutType<typename T> : ObjectType<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes standard-layout types ([basic.types]).}
+
+\pnum
+\addedConcepts{\mbox{\requires} for every type \mbox{\tcode{T}} that
+ is a standard-layout type, a concept map
+ \mbox{\tcode{StandardLayoutType<T>}} shall be implicitly defined in
+namespace \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept LiteralType<typename T> : ObjectType<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes literal types ([basic.types]).}
+
+\pnum
+\addedConcepts{\mbox{\requires} for every type \mbox{\tcode{T}} that
+ is a literal type, a concept map \mbox{\tcode{LiteralType<T>}} shall
+ be implicitly defined in namespace \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept ScalarType<typename T>
+ : TrivialType<T>, LiteralType<T>, StandardLayoutType<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes scalar types ([basic.types]).}
+
+\pnum
+\addedConcepts{\mbox{\requires} for every type \mbox{\tcode{T}} that
+ is a scalar type, a concept map \mbox{\tcode{ScalarType<T>}} shall
+ be implicitly defined in namespace \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept NonTypeTemplateParameterType<typename T> : VariableType<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describess type that can
+be used as the type of a non-type template parameter ([temp.param]).}
+
+\pnum
+\addedConcepts{\mbox{\requires}
+for every type \mbox{\tcode{T}} that can be the type of a non-type
+\mbox{\techterm{template-parameter}} ([temp.param]), a concept map
+\mbox{\tcode{NonTypeTemplateParameterType<T>}} shall be implicitly defined in
+namespace \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept IntegralConstantExpressionType<typename T>
+ : ScalarType<T>, NonTypeTemplateParameterType<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types that
+can be the type of an integral constant expression ([expr.const]).}
+
+\pnum
+\addedConcepts{\mbox{\requires} for every type \mbox{\tcode{T}} that
+ is an integral type or enumeration type, a concept map
+ \mbox{\tcode{IntegralConstantExpressionType<T>}} shall be implicitly
+ defined in namespace \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept IntegralType<typename T> : IntegralConstantExpressionType<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes integral types
+([basic.fundamental]).}
+
+\pnum
+\addedConcepts{\mbox{\requires}
+for every type \mbox{\tcode{T}} that is an integral type, a concept map
+\mbox{\tcode{IntegralType<T>}} shall be implicitly defined in
+namespace \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept EnumerationType<typename T> : IntegralConstantExpressionType<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes enumeration types
+([dcl.enum]).}
+
+\pnum
+\addedConcepts{\mbox{\requires}
+for every type \mbox{\tcode{T}} that is an enumeration type, a concept map
+\mbox{\tcode{EnumerationType<T>}} shall be implicitly defined in namespace
+\mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept SameType<typename T, typename U> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes a same-type requirement
+ ([temp.req]).}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept DerivedFrom<typename Derived, typename Base> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\mbox{\requires}
+for every pair of class types (\mbox{\tcode{T}}, \mbox{\tcode{U}}),
+such that \mbox{\tcode{T}} is either the same as or publicly and
+unambiguously derived from \mbox{\tcode{U}}, a concept map
+\mbox{\tcode{DerivedFrom<T, U>}} shall be implicitly defined in namespace
+\mbox{\tcode{std}}.
+\end{itemdescr}
+
+\rSec2[concept.comparison]{Comparisons}
+
+\begin{itemdecl}
+auto concept LessThanComparable<typename T, typename U = T> {
+ bool operator<(T const& a, U const& b);
+ bool operator>(U const& a, T const& b) { return b < a; }
+ bool operator<=(U const& a, T const& b) { return !(b < a); }
+ bool operator>=(T const& a, U const& b) { return !(a < b); }
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types whose values can be
+ ordered via an inequality operator.}
+
+\pnum
+\addedConcepts{\mbox{\requires}} \tcode{operator<} is a strict
+ weak ordering relation (\ref{alg.sorting}).
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept EqualityComparable<typename T, typename U = T> {
+ bool operator==(T const& a, U const& b);
+ bool operator!=(T const& a, U const& b) { return !(a == b); }
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types whose values can be
+compared for equality with \mbox{\tcode{operator==}}.}
+
+\pnum
+\addedConcepts{\mbox{\requires}}
+\changedConcepts{W}{w}hen \tcode{T} and \tcode{U} are identical, \tcode{operator==} is an
+equivalence relation, that is, it has the following properties:
+\begin{itemize}
+\item
+For all \tcode{a}, \tcode{a == a}.
+\item
+If \tcode{a == b}, then \tcode{b == a}.
+\item
+If \tcode{a == b} and \tcode{b == c}, then \tcode{a == c}.
+\end{itemize}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept TriviallyEqualityComparable<typename T> : EqualityComparable<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types whose equality comparison
+ operators (\mbox{\tcode{==}}, \mbox{\tcode{!=}}) can be implemented
+ via a bitwise equality comparison, as with \mbox{\tcode{memcmp}}.
+\mbox{\enternote} such types should not have
+padding, i.e. the size of the type is the sum of the sizes of its
+elements. If padding exists, the comparison may provide false
+negatives, but never false positives. \mbox{\exitnote}}
+
+\pnum
+\addedConcepts{\mbox{\requires} for every integral type
+ \mbox{\tcode{T}} and pointer type, a concept map
+ \mbox{\tcode{TriviallyEqualityComparable<T>}} shall be
+ defined in namespace \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\rSec2[concept.destruct]{Destruction}
+\begin{itemdecl}
+auto concept Destructible<typename T> : VariableType<T> {
+ T::~T();
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types that can be destroyed,
+ including scalar types, references, and class types with a public
+ destructor.}
+
+\pnum
+\addedConcepts{\mbox{\requires} following destruction of an object,}
+\changedConcepts{All}{all} resources owned by the object are reclaimed.
+\end{itemdescr}
+
+\begin{itemdecl}
+concept TriviallyDestructible<typename T> : Destructible<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types whose
+destructors do not need to be executed when the object is destroyed.}
+
+\pnum
+\addedConcepts{\mbox{\requires} for every type \mbox{\tcode{T}} that
+ is a trivial type ([basic.types]), reference, or class type with a
+ trivial destructor ([class.dtor]), a concept map
+ \mbox{\tcode{TriviallyDestructible<T>}} shall be implicitly
+ defined in namespace \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\rSec2[concept.construct]{Construction}
+\begin{itemdecl}
+auto concept Constructible<typename T, typename... Args> : Destructible<T> {
+ T::T(Args...);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types that can be constructed
+ from a given set of arguments.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept DefaultConstructible<typename T> : Constructible<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types that can be default-constructed.}
+\end{itemdescr}
+
+\rSec2[concept.copymove]{Copy and move}
+\begin{itemdecl}
+auto concept MoveConstructible<typename T> : Destructible<T> {
+ T::T(T&&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note}
+describes types that can move-construct an
+object from a value of the same type, possibly altering that
+value.}
+\end{itemdescr}
+
+\begin{itemdecl}
+T::T(T&& rv);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\postcondition}
+the constructed \mbox{\tcode{T}} object is equivalent to the value of
+\mbox{\tcode{rv}} before the construction.
+\mbox{\enternote} there is no requirement on the value of
+\mbox{\tcode{rv}} after the construction. \mbox{\exitnote}}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept CopyConstructible<typename T> : MoveConstructible<T> {
+ T::T(const T&);
+
+ axiom CopyPreservation(T x) {
+ T(x) == x;
+ }
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with a public copy constructor.}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept TriviallyCopyConstructible<typename T> : CopyConstructible<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types whose copy
+constructor is equivalent to \mbox{\tcode{memcpy}}.}
+
+\pnum
+\addedConcepts{\mbox{\requires} for every type \mbox{\tcode{T}} that
+ is a trivial type ([basic.types]), a reference, or a class type with
+ a trivial copy constructor ([class.copy]), a concept map
+ \mbox{\tcode{TriviallyCopyConstructible<T>}}
+shall be implicitly defined in namespace \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept MoveAssignable<typename T, typename U = T> {
+ typename result_type;
+ result_type @\addedCC{T::}@operator=(@\removedCC{T\&, }@U&&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with the ability
+ to assign to an object from an rvalue, potentially altering the rvalue.}
+\end{itemdescr}
+
+\begin{itemdecl}
+result_type T::operator=(U&& rv);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\postconditions}
+the constructed \mbox{\tcode{T}} object is equivalent to the value of
+\mbox{\tcode{rv}} before the assignment.
+\mbox{\enternote} there is no requirement on the value of
+\mbox{\tcode{rv}} after
+the assignment. \mbox{\exitnote}}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept CopyAssignable<typename T, typename U = T> : MoveAssignable<T, U> {
+ typename result_type;
+ result_type T::operator=(const U&);
+
+ axiom CopyPreservation(T& x, U y) {
+ (x = y, x) == y;
+ }
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with the ability to assign to an
+object.}
+\end{itemdescr}
+
+\editorial{\textcolor{black}{The CopyAssignable requirements in N2461 specify that
+ \tcode{operator=} must return a \tcode{T\&}. This is too strong a
+ requirement for most of the uses of \tcode{CopyAssignable}, so we have
+ weakened \tcode{CopyAssignable} to not require anything of its return
+ type. When we need a \tcode{T\&}, we'll add that as an explicit
+ requirement. See, e.g., the \tcode{Integral} concept.}}
+
+\begin{itemdecl}
+concept TriviallyCopyAssignable<typename T> : CopyAssignable<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types whose copy-assignment
+ operator is equivalent to \mbox{\tcode{memcpy}}.}
+
+\pnum
+\addedConcepts{\mbox{\requires} for every type \mbox{\tcode{T}} that
+ is a trivial type ([basic.types]) or a
+class type with a trivial copy assignment operator ([class.copy]), a
+concept map \mbox{\tcode{TriviallyCopyAssignable<T>}} shall be implicitly
+defined in namespace \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept Swappable<typename T> {
+ void swap(T&, T&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types for which two values of
+ that type can be swapped.}
+\end{itemdescr}
+
+\begin{itemdecl}
+void swap(T& t, T& u);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\postconditions}
+\mbox{\tcode{t}} has the value originally held by \mbox{\tcode{u}},
+and \mbox{\tcode{u}} has the value originally held by \mbox{\tcode{t}}.}
+\end{itemdescr}
+
+\rSec2[concept.memory]{Memory allocation}
+\begin{itemdecl}
+auto concept Newable<typename T, typename... Args> : ObjectType<T> {
+ void* T::operator new(size_t size, Args...);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types for which objects can be
+allocated on the heap via \mbox{\tcode{new}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept Deletable<typename T> : ObjectType<T> {
+ void T::operator delete(void*);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types for which objects on the
+heap can be freed with \mbox{\tcode{delete}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept ArrayNewable<typename T, typename... Args> : ObjectType<T> {
+ void* T::operator new[](size_t size, Args...);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types for which arrays of
+objects can be allocated on the heap via array \mbox{\tcode{new}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept ArrayDeletable<typename T> : ObjectType<T> {
+ void T::operator delete[](void*);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types for which an array
+objects on the heap can be freed with \mbox{\tcode{delete[]}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept HeapAllocatable<typename T>
+ : Newable<T>, Deletable<T>, ArrayNewable<T>, ArrayDeletable<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types for which objects and
+arrays of objects can be allocated on or freed from the heap with
+\mbox{\tcode{new}} and \mbox{\tcode{delete}}.}
+\end{itemdescr}
+
+\rSec2[concept.regular]{Regular types}
+
+\begin{itemdecl}
+auto concept Semiregular<typename T> : CopyConstructible<T>, CopyAssignable<T> {
+ requires SameType<CopyAssignable<T>::result_type, T&>;
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} collects several common
+requirements supported by most types.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept Regular<typename T>
+ : Semiregular<T>, DefaultConstructible<T>, EqualityComparable<T>, HeapAllocatable<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes semi-regular types that are default
+constructible, have equality comparison operators, and can be
+allocated on the heap.}
+\end{itemdescr}
+
+\rSec2[concept.convertible]{Convertibility}
+
+\begin{itemdecl}
+auto concept ExplicitlyConvertible<typename T, typename U> : VariableType<T> {
+ explicit operator U(T const&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with a conversion (explicit
+or implicit) from one type to another.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept Convertible<typename T, typename U> : ExplicitlyConvertible<T, U> {
+ operator U(T const&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with an implicit conversion from one
+type to another.}
+\end{itemdescr}
+
+\rSec2[concept.true]{True}
+
+\begin{itemdecl}
+concept True<bool> { }
+concept_map True<true> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} used to express the requirement that a
+ particular integral constant expression evaluate true.}
+
+\pnum
+\addedConcepts{\mbox{\requires} a program shall not provide a concept map for the
+\mbox{\tcode{True}} concept.}
+\end{itemdescr}
+
+\rSec2[concept.operator]{Operator concepts}
+\begin{itemdecl}
+auto concept HasPlus<typename T, typename U = T> {
+ typename result_type;
+ result_type operator+(T const&, U const&);
+ result_type operator+(T const&, U &&);
+ result_type operator+(T &&, U const&);
+ result_type operator+(T &&, U &&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with a binary \mbox{\tcode{operator+}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept HasMinus<typename T, typename U = T> {
+ typename result_type;
+ result_type operator-(T const&, U const&);
+ result_type operator-(T const&, U &&);
+ result_type operator-(T &&, U const&);
+ result_type operator-(T &&, U &&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with a binary \mbox{\tcode{operator-}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept HasMultiply<typename T, typename U = T> {
+ typename result_type;
+ result_type operator*(T const&, U const&);
+ result_type operator*(T const&, U &&);
+ result_type operator*(T &&, U const&);
+ result_type operator*(T &&, U &&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with} \changedCC{an}{a binary} \addedConcepts{\mbox{\tcode{operator*}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept HasDivide<typename T, typename U = T> {
+ typename result_type;
+ result_type operator/(T const&, U const&);
+ result_type operator/(T const&, U &&);
+ result_type operator/(T &&, U const&);
+ result_type operator/(T &&, U &&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with an \mbox{\tcode{operator/}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept HasModulus<typename T, typename U = T> {
+ typename result_type;
+ result_type operator%(T const&, U const&);
+ result_type operator%(T const&, U &&);
+ result_type operator%(T &&, U const&);
+ result_type operator%(T &&, U &&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with an \mbox{\tcode{operator\%}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept HasUnaryPlus<typename T> {
+ typename result_type;
+ result_type operator+(T const&);
+ result_type operator+(T &&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\mbox{\note} describes types with a unary \mbox{\tcode{operator+}}.
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept HasNegate<typename T> {
+ typename result_type;
+ result_type operator-(T const&);
+ result_type operator-(T &&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with a unary \mbox{\tcode{operator-}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept HasLogicalAnd<typename T, typename U = T> {
+ bool operator&&(T const&, U const&);
+ bool operator&&(T const&, U &&);
+ bool operator&&(T &&, U const&);
+ bool operator&&(T &&, U &&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with a logical conjunction operator.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept HasLogicalOr<typename T, typename U = T> {
+ bool operator||(T const&, U const&);
+ bool operator||(T const&, U &&);
+ bool operator||(T &&, U const&);
+ bool operator||(T &&, U &&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with a logical disjunction operator.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept HasLogicalNot<typename T> {
+ bool operator!(T const&);
+ bool operator!(T &&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with a logical negation operator.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept HasBitAnd<typename T, typename U = T> {
+ typename result_type;
+ result_type operator&(T const&, U const&);
+ result_type operator&(T const&, U &&);
+ result_type operator&(T &&, U const&);
+ result_type operator&(T &&, U &&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with a binary \mbox{\tcode{operator\&}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept HasBitOr<typename T, typename U = T> {
+ typename result_type;
+ result_type operator|(T const&, U const&);
+ result_type operator|(T const&, U &&);
+ result_type operator|(T &&, U const&);
+ result_type operator|(T &&, U &&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with an \mbox{\tcode{operator|}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept HasBitXor<typename T, typename U = T> {
+ typename result_type;
+ result_type operator^(T const&, U const&);
+ result_type operator^(T const&, U &&);
+ result_type operator^(T &&, U const&);
+ result_type operator^(T &&, U &&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with an \mbox{\tcode{operator\^}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept HasComplement<typename T> {
+ typename result_type;
+ result_type operator~(T const&);
+ result_type operator~(T &&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with an
+ \mbox{\tcode{operator\~}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept HasLeftShift<typename T, typename U = T> {
+ typename result_type;
+ result_type operator<<(T const&, U const&);
+ result_type operator<<(T const&, U &&);
+ result_type operator<<(T &&, U const&);
+ result_type operator<<(T &&, U &&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\mbox{\note} describes types with an \mbox{\tcode{operator$<<$}}.
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept HasRightShift<typename T, typename U = T> {
+ typename result_type;
+ result_type operator>>(T const&, U const&);
+ result_type operator>>(T const&, U &&);
+ result_type operator>>(T &&, U const&);
+ result_type operator>>(T &&, U &&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\mbox{\note} describes types with an \mbox{\tcode{operator$>>$}}.
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept Dereferenceable<typename T> {
+ typename reference;
+ reference operator*(T);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with a dereferencing \mbox{\tcode{operator*}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept Addressable<typename T> {
+ typename pointer;
+ typename const_pointer;
+
+ pointer operator&(T&);
+ const_pointer operator&(const T&);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types with an address-of \mbox{\tcode{operator\&}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+auto concept Callable<typename F, typename... Args> {
+ typename result_type;
+ result_type operator()(F&, Args...);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes function object types
+callable given arguments of types \mbox{\tcode{Args...}}.}
+\end{itemdescr}
+
+\rSec2[concept.arithmetic]{Arithmetic concepts}
+
+\begin{itemdecl}
+concept ArithmeticLike<typename T>
+ : Regular<T>, LessThanComparable<T>, HasPlus<T>, HasMinus<T>, HasMultiply<T>, HasDivide<T>,
+ HasUnaryPlus<T>, HasNegate<T> {
+ T::T(long long);
+
+ T& operator++(T&);
+ T operator++(T& t, int) { T tmp(t); ++t; return tmp; }
+ T& operator--(T&);
+ T operator--(T& t, int) { T tmp(t); --t; return tmp; }
+
+ requires Convertible<HasUnaryPlus<T>::result_type, T>
+ && Convertible<HasNegate<T>::result_type, T>
+ && Convertible<HasPlus<T>::result_type, T>
+ && Convertible<HasMinus<T>::result_type, T>
+ && Convertible<HasMultiply<T>::result_type, T>
+ && Convertible<HasDivide<T>::result_type, T>;
+
+ T& operator*=(T&, T);
+ T& operator/=(T&, T);
+ T& operator+=(T&, T);
+ T& operator-=(T&, T);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types that provide all of the
+ operations available on arithmetic types ([basic.fundamental]).}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept IntegralLike<typename T>
+ : ArithmeticLike<T>, HasComplement<T>, HasModulus<T>, HasBitAnd<T>, HasBitXor<T>, HasBitOr<T>,
+ HasLeftShift<T>, HasRightShift<T> {
+ requires Convertible<HasComplement<T>::result_type, T>
+ && Convertible<HasModulus<T>::result_type, T>
+ && Convertible<HasBitAnd<T>::result_type, T>
+ && Convertible<HasBitXor<T>::result_type, T>
+ && Convertible<HasBitOr<T>::result_type, T>
+ && Convertible<HasLeftShift<T>::result_type, T>
+ && Convertible<HasRightShift<T>::result_type, T>;
+
+ T& operator%=(T&, T);
+ T& operator&=(T&, T);
+ T& operator^=(T&, T);
+ T& operator|=(T&, T);
+ T& operator<<=(T&, T);
+ T& operator>>=(T&, T);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types that provide all of the operations
+ available on integral types.}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept SignedIntegralLike<typename T> : IntegralLike<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types that provide all of the
+ operations available on signed integral types.}
+
+\pnum
+\addedConcepts{\mbox{\requires} for every signed integral type
+ \mbox{\tcode{T}} ([basic.fundamental]), including signed extended
+ integral types, an empty concept map
+ \mbox{\tcode{SignedIntegral<T>}} shall be defined in namespace
+ \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept UnsignedIntegralLike<typename T> : IntegralLike<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes types that provide all of the
+ operations available on unsigned integral types.}
+
+\pnum
+\addedConcepts{\mbox{\requires} for every unsigned integral type
+ \mbox{\tcode{T}} ([basic.fundamental]), including unsigned extended
+ integral types, an empty concept map
+ \mbox{\tcode{UnsignedIntegral<T>}} shall be defined in namespace
+ \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\begin{itemdecl}
+concept FloatingPointLike<typename T> : ArithmeticLike<T> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes floating-point types.}
+
+\pnum
+\addedConcepts{\mbox{\requires}
+for every floating point type \mbox{\tcode{T}} ([basic.fundamental]),
+an empty concept map \mbox{\tcode{FloatingPoint<T>}} shall be defined
+in namespace \mbox{\tcode{std}}.}
+\end{itemdescr}
+
+\rSec2[concept.predicate]{Predicates}
+
+\begin{itemdecl}
+auto concept Predicate<typename F, typename... Args> : Callable<F, Args...> {
+ requires Convertible<result_type, bool>;
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\note} describes function objects
+callable with some set of arguments, the result of which can be used in a
+context that requires a \mbox{\tcode{bool}}.}
+
+\pnum
+\addedConcepts{\mbox{\requires}
+predicate function objects shall not apply any non-constant function
+through the predicate arguments.}
+\end{itemdescr}
+
+\color{black}
+\rSec2[concept.allocator]{Allocators}
+\index{requirements!Allocator@\tcode{Allocator}}%
+\editorial{We have kept most of the text of [allocator.requirements]
+ here, although much of it has been moved from tables into numbered
+ paragraphs when translating the allocator requirements into concepts.}
+
+\pnum
+The library describes a standard set of requirements for \techterm{allocators},
+which are objects that encapsulate the information about an allocation model.
+This information includes the knowledge of pointer types, the type of their
+difference, the type of the size of objects in this allocation model, as well
+as the memory allocation and deallocation primitives for it. All of the
+containers (clause~\ref{containers}) are parameterized in terms of allocators.
+
+\eremove{Remove Table 39: Descriptive variable definitions}
+
+\eremove{Remove Table 40: Allocator requirements}
+
+\pnum
+\changedConcepts{Table~40 describes the requirements on types manipulated
+through allocators.}
+{The \mbox{\tcode{Allocator}} concept describes the requirements on
+ allocators.}
+\changedConcepts{All the operations on the allocators are expected to be
+amortized constant time.}{Each allocator operation shall have
+amortized constant time complexity.}
+\removedConcepts{Table~33
+describes the requirements on allocator types.}
+
+\color{addclr}
+\begin{itemdecl}
+concept Allocator<typename X> : DefaultConstructible<X>, CopyConstructible<X> {
+ ObjectType value_type = typename X::value_type;
+ MutableRandomAccessIterator pointer = typename X::pointer;
+ RandomAccessIterator const_pointer = typename X::const_pointer;
+ typename reference = typename X::reference;
+ typename const_reference = typename X::const_reference;
+ SignedIntegral difference_type = typename X::difference_type;
+ UnsignedIntegral size_type = typename X::size_type;
+ template<ObjectType T> class rebind = @\textit{see below}@;
+
+ requires Convertible<pointer, const_pointer> &&
+ Convertible<pointer, void*> &&
+ Convertible<pointer, value_type*> &&
+ SameType<pointer::value_type, value_type> &&
+ SameType<pointer::reference, value_type&> &&
+ SameType<pointer::reference, reference>;
+
+ requires Convertible<const_pointer, const void*> &&
+ @\textcolor{addclr}{Convertible}@<const_pointer, const value_type&> &&
+ SameType<const_pointer::value_type, value_type> &&
+ SameType<const_pointer::reference, const value_type&> &&
+ SameType<const_pointer::reference, const_reference>;
+
+ requires SameType<rebind<value_type>, X>;
+
+ pointer X::allocate(size_type n);
+ pointer X::allocate(size_type n, const_pointer p);
+ @\textcolor{addclr}{void}@ X::deallocate(pointer p, size_type n);
+
+ size_type X::max_size() const;
+
+ template<ObjectType T>
+ X::X(const rebind<T>& y);
+
+ @\removedConcepts{void X::construct(pointer p, const value_type\&);}@
+ template<typename V>
+ requires Convertible<V, value_type>
+ @\textcolor{addclr}{void}@ X::construct(pointer p, V&&);
+
+ void X::destroy(pointer p);
+
+ pointer X::address(reference) const;
+ const_pointer X::address(const_reference) const;
+}
+\end{itemdecl}
+\color{black}
+
+\color{addclr}
+\begin{itemdecl}
+UnsignedIntegral size_type;
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\ctype\
+a type that can represent the size of the largest object in the allocation model
+\end{itemdescr}
+
+\color{addclr}
+\begin{itemdecl}
+SignedIntegral difference_type;
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\ctype\
+a type that can represent the difference between any two pointers
+in the allocation model
+\end{itemdescr}
+
+\color{addclr}
+\begin{itemdecl}
+template<ObjectType T> class rebind;
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\ctype}}
+The \changedConcepts{member class}{associated} template \tcode{rebind} \removedConcepts{in the table above is effectively a
+typedef template}{is a template that produces allocators in the same
+ family as \mbox{\tcode{X}}}: if the name
+\changedConcepts{\mbox{\tcode{Allocator}}}{\mbox{\tcode{X}}} is bound
+to \changedConcepts{\mbox{\tcode{SomeAllocator<T>}}}{
+\mbox{\tcode{SomeAllocator<value_type>}}},
+then \changedConcepts{\mbox{\tcode{Allocator::rebind<U>::other}}}{\mbox{\tcode{rebind<U>}}} is the same type as
+\mbox{\tcode{Some}}\-\mbox{\tcode{Allocator<U>}}.
+\addedConcepts{The resulting type
+\mbox{\tcode{SameAllocator<U>}} shall meet the requirements of the
+\mbox{\tcode{Allocator}} concept.}
+
+\addedConcepts{The
+ default value for \mbox{\tcode{rebind}} is a template
+ \mbox{\tcode{R}} for which \mbox{\tcode{R<U>}} is
+ \mbox{\tcode{X::template rebind<U>::other}}.}
+
+\begin{lrbox}\rebindbox
+\begin{minipage}{\linewidth}
+\begin{lstlisting}
+template<typename Alloc>
+struct rebind_allocator {
+ template<typename U>
+ using rebind = typename Alloc::template rebind<U>::other;
+};
+\end{lstlisting}
+\end{minipage}
+\end{lrbox}
+
+\editorial{The aforementioned default value for \tcode{rebind} can be
+ implemented as follows:
+
+\usebox \rebindbox
+
+The default value for \tcode{rebind} in the \tcode{Allocator} concept
+is, therefore, \tcode{rebind_allocator<X>::template rebind}.}
+
+\end{itemdescr}
+
+\color{addclr}
+\begin{itemdecl}
+pointer X::allocate(size_type n);
+pointer X::allocate(size_type n, const_pointer p);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Memory is allocated for \tcode{n}\ objects of type \changedConcepts{\mbox{\tcode{T}}}{\mbox{\tcode{value_type}}}\ but objects
+are not constructed. \footnote{It is intended that \tcode{a.allocate}\ be an efficient means
+of allocating a single object of type \tcode{T}, even when \tcode{sizeof(T)}\
+is small. That is, there is no need for a container to maintain its own
+``free list''.}
+
+\pnum
+\returns\
+\removedConcepts{The result is a random access iterator.}
+\addedConcepts{A pointer to the allocated memory.}
+\enternote\
+If \tcode{n == 0}, the return value is unspecified.
+\exitnote\
+
+\pnum
+\throws\
+\tcode{allocate}\ may raise an appropriate exception.
+\end{itemdescr}
+
+\color{addclr}
+\begin{itemdecl}
+void X::deallocate(pointer p, size_type n);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\preconditions\
+All \tcode{n }\ \changedConcepts{T}{value\_type} objects in the area pointed to by \tcode{p}\ shall be
+destroyed prior to this call. \tcode{n} shall match the value passed to
+\tcode{allocate}\ to obtain this memory.
+\enternote\ \tcode{p} shall not be \changedConcepts{null}{singular}.\exitnote
+
+\throws\ Does not throw exceptions.
+\end{itemdescr}
+
+\begin{itemdecl}
+@\addedConcepts{size_type X::max_size() const;}@
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+the largest value that can meaningfully be passed to \tcode{X::allocate()}
+\end{itemdescr}
+
+\color{addclr}
+\begin{itemdecl}
+template<typename V>
+ requires Constructible<value_type, V&&>
+ void X::construct(pointer p, V&&);
+\end{itemdecl}
+\color{black}
+
+\editorial{The non-templated \tcode{X::construct} has been removed
+from the \tcode{Allocator} requirements because it implies that the
+\tcode{value_type} is \tcode{CopyConstructible} (which we do not want
+as a requirement in the \tcode{Allocator} concept). The templated
+version is more general, allowing in-place and move construction.}
+
+\begin{itemdescr}
+\pnum
+\effects\
+\tcode{::new((void*)p) T(forward<V>(v))}
+\end{itemdescr}
+
+\color{addclr}
+\begin{itemdecl}
+void X::destroy(pointer p);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+\tcode{((T*)p)->$\sim$T()}
+\end{itemdescr}
+
+\pnum
+\addedConcepts{The \mbox{\tcode{AllocatorGenerator}} concept describes
+ the requirements on types that can be used to generate
+ \mbox{\tcode{Allocator}}s.}
+
+\color{addclr}
+\begin{itemdecl}
+concept AllocatorGenerator<typename X> : Regular<X> {
+ typename value_type = typename X::value_type;
+ template<typename T> class rebind = @\textit{see below}@;
+
+ @\textcolor{addclr}{requires}@ SameType<rebind<value_type>, X>;
+}
+\end{itemdecl}
+\color{black}
+
+\begin{itemdecl}
+@\addedConcepts{template<typename T> class rebind;}@
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\ctype}}
+The \changedConcepts{member class}{associated} template \tcode{rebind} \removedConcepts{in the table above is effectively a
+typedef template}{is a template that produces allocator generators in the same
+ family as \mbox{\tcode{X}}}: if the name
+\changedConcepts{\mbox{\tcode{Allocator}}}{\mbox{\tcode{X}}} is bound
+to \changedConcepts{\mbox{\tcode{SomeAllocator<T>}}}{
+\mbox{\tcode{SomeAllocator<value_type>}}},
+then \changedConcepts{\mbox{\tcode{Allocator::rebind<U>::other}}}{\mbox{\tcode{rebind<U>}}} is the same type as
+\mbox{\tcode{Some}}\-\mbox{\tcode{Allocator<U>}}. \addedConcepts{The
+ default value for \mbox{\tcode{rebind}} is a template
+ \mbox{\tcode{R}} for which \mbox{\tcode{R<U>}} is
+ \mbox{\tcode{X::template}} \mbox{\tcode{rebind<U>::other}}.}
+\end{itemdescr}
+
+\pnum
+Two allocators \addedConcepts{or allocator generators} compare equal with \tcode{==}
+iff storage allocated from each can be deallocated via the other.
+
+\pnum \addedConcepts{Every \mbox{\tcode{Allocator}} also meets the
+ requirements of the \mbox{\tcode{AllocatorGenerator}} concept:}
+\color{addclr}
+\begin{itemdecl}
+template<Allocator X>
+concept_map AllocatorGenerator<X> {
+ typedef Allocator<X>::value_type value_type;
+ template<typename U> using rebind = Allocator<X>::rebind<U>;
+}
+\end{itemdecl}
+\color{black}
+
+\pnum
+Implementations of containers described in this International Standard
+are permitted to assume that their \tcode{Alloc}\removedConcepts{\mbox{\tcode{ator}}} template parameter meets
+the following two additional requirements beyond those in
+\changedConcepts{Table~40}{the Allocator concept}.
+
+\begin{itemize}
+\item
+All instances of a given allocator type are required to be interchangeable
+and always compare equal to each other.
+\item
+\removedConcepts{The typedef members pointer, const\_pointer, size\_type,
+and difference\_type are required to be T*, T const*,
+std::size\_t, and std::ptrdiff\_t, respectively.} \color{addclr}The
+requirements clause may contain the following additional requirements:
+\tcode{SameType<Alloc::pointer, Alloc::value_type*>}, \tcode{SameType<Alloc::const_pointer,
+ const Alloc::value_type*>}, \tcode{SameType<Alloc::size_type, std::size_t>}, and
+\tcode{SameType<Alloc::difference_type, std::ptrdiff_t>}.
+\end{itemize}
+
+\pnum
+Implementors are encouraged to supply libraries that can accept allocators
+that encapsulate more general memory models and that support non-equal
+instances.
+In such implementations, any requirements imposed on allocators
+by containers beyond those requirements that appear in
+\changedConcepts{Table~40}{concept Allocator}, and the
+semantics of containers and algorithms when allocator instances compare
+non-equal, are implementation-defined.
+
+\section*{Acknowledgments}
+Thanks to Walter Brown and Daniel Kr\"ugler for providing corrections
+to and noting omissions from this document.
+
+\end{document}

Added: sandbox/committee/concepts/stdlib/clib-containers.tex
==============================================================================
--- (empty file)
+++ sandbox/committee/concepts/stdlib/clib-containers.tex 2008-03-03 15:03:07 EST (Mon, 03 Mar 2008)
@@ -0,0 +1,2212 @@
+\documentclass[american,twoside]{book}
+\usepackage{refbib}
+\usepackage{hyperref}
+\input{macros}
+
+%%--------------------------------------------------
+%% Set section numbering limit, toc limit
+\setcounter{secnumdepth}{5}
+\setcounter{tocdepth}{1}
+
+%%--------------------------------------------------
+%% Parameters that govern document appearance
+\setlength{\oddsidemargin}{0pt}
+\setlength{\evensidemargin}{0pt}
+\setlength{\textwidth}{6.6in}
+
+%%--------------------------------------------------
+%% Handle special hyphenation rules
+\hyphenation{tem-plate ex-am-ple in-put-it-er-a-tor}
+
+% Do not put blank pages after chapters that end on odd-numbered pages.
+\def\cleardoublepage{\clearpage\if_at_twoside%
+ \ifodd\c_at_page\else\hbox{}\thispagestyle{empty}\newpage%
+ \if_at_twocolumn\hbox{}\newpage\fi\fi\fi}
+
+\begin{document}
+\raggedbottom
+
+\begin{titlepage}
+\begin{center}
+\huge
+Concepts for the C++0x Standard Library: Containers
+
+\vspace{0.5in}
+
+\normalsize
+Douglas Gregor \\
+Open Systems Laboratory \\
+Indiana University \\
+Bloomington, IN\ \ 47405 \\
+\href{mailto:dgregor_at_[hidden]}{dgregor_at_[hidden]}
+\end{center}
+
+\vspace{1in}
+\par\noindent Document number: N2085=06-0155\vspace{-6pt}
+\par\noindent Date: \today\vspace{-6pt}
+\par\noindent Project: Programming Language \Cpp{}, Library Working Group\vspace{-6pt}
+\par\noindent Reply-to: Douglas Gregor $<$\href{mailto:dgregor_at_[hidden]}{dgregor_at_[hidden]}$>$\vspace{-6pt}
+
+\section*{Introduction}
+\libintrotext{Chapter 23}
+\end{titlepage}
+
+%%--------------------------------------------------
+%% Headers and footers
+\pagestyle{fancy}
+\fancyhead[LE,RO]{\textbf{\rightmark}}
+\fancyhead[RE]{\textbf{\leftmark\hspace{1em}\thepage}}
+\fancyhead[LO]{\textbf{\thepage\hspace{1em}\leftmark}}
+\fancyfoot[C]{Draft}
+
+\fancypagestyle{plain}{
+\renewcommand{\headrulewidth}{0in}
+\fancyhead[LE,RO]{}
+\fancyhead[RE,LO]{}
+\fancyfoot{}
+}
+
+\renewcommand{\sectionmark}[1]{\markright{\thesection\hspace{1em}#1}}
+\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
+
+\color{black}
+
+\setcounter{chapter}{23}
+\rSec0[lib.containers]{Containers library}
+
+\pnum
+This clause describes components that \Cpp\ programs may use to
+organize collections of information.
+
+\pnum
+The following subclauses describe
+container \changedConcepts{requirements}{concepts},
+and components for
+sequences and
+associative containers,
+as summarized in
+Table~\ref{tab:containers.lib.summary}:
+
+\begin{libsumtab}{Containers library summary}{tab:containers.lib.summary}
+\ref{lib.container.requirements} Requirements & \addedConcepts{\ttfamily <container>} \\ \rowsep
+\ref{lib.sequences} Sequences & \tcode{<array>} \\
+ & \tcode{<deque>} \\
+ & \tcode{<list>} \\
+ & \tcode{<queue>} \\
+ & \tcode{<stack>} \\
+ & \tcode{<vector>} \\ \rowsep
+\ref{lib.associative} Associative containers & \tcode{<map>} \\
+ & \tcode{<set>} \\
+\ref{lib.template.bitset} \tcode{bitset} & \tcode{<bitset>} \\ \rowsep
+\ref{lib.unord} \addedB{Unordered associative containers}& \tcode{<unordered_map>} \\
+ & \tcode{<unordered_set>} \\
+\end{libsumtab}
+
+\rSec1[lib.container.requirements]{Container requirements}
+\index{requirements!container}%
+
+\pnum
+Containers are objects that store other objects.
+They control allocation and deallocation of these objects
+through constructors, destructors, insert and erase operations.
+
+\pnum
+All of the complexity requirements in this clause are stated solely
+in terms of the number of operations on the contained objects.
+\enterexample\
+the copy constructor of type
+\tcode{vector <vector<int> >}\
+has linear complexity,
+even though the complexity of copying each contained
+\tcode{vector<int>}\
+is itself linear.
+\exitexample\
+
+\pnum
+\removedConcepts{The type of objects stored in these components shall meet the requirements of
+CopyConstructible
+types (20.1.3).}
+
+\pnum
+\removedConcepts{Table~79 defines the Assignable requirement.
+Some containers require this property of the types to be stored in the
+container.
+T
+is the type used to instantiate the container,
+t is a value of T,
+and u is a value of (possibly
+const) T.}
+
+\eremove{Remove Table 79: Assignable requirements. Assignable is now a
+ concept in Chapter 20.}
+
+\color{addclr}
+\synopsis{Header \tcode{<container>}\ synopsis}
+
+\color{black}
+\editorial{Note: Synchronize this with the rest of the text.}
+\color{addclr}
+
+\pnum
+\removedConcepts{In Tables~80 and
+81, X
+denotes a container class containing objects of type
+T, a and b
+denote values of type X, u
+denotes an identifier and r
+denotes a value of X\&.} \color{addclr} The \tcode{Container}\ concept
+describes the requirements common to all containers.
+
+\begin{itemdecl}
+concept Container<typename X> : DefaultConstructible<X>
+{
+ typename value_type = X::value_type;
+ typename reference = X::reference;
+ typename const_reference = X::const_reference;
+ InputIterator iterator = X::iterator;
+ InputIterator const_iterator = X::const_iterator;
+ SignedIntegral difference_type = X::difference_type;
+ UnsignedIntegral size_type = X::size_type;
+
+ where Convertible<reference, value_type&> &&
+ Convertible<const_reference, value_type const&>;
+
+ where Convertible<iterator, const_iterator> &&
+ SameType<iterator::value_type, value_type> &&
+ SameType<const_iterator::value_type, value_type>;
+
+ where SameType<difference_type, iterator::difference_type> &&
+ SameType<difference_type, const_iterator::difference_type>;
+
+ iterator X::begin();
+ const_iterator X::begin() const;
+ iterator X::end();
+ const_iterator X::end() const;
+
+ const_iterator X::cbegin() const;
+ const_iterator X::cend() const;
+
+ void X::swap(X&);
+
+ size_type X::size() const;
+ size_type X::max_size() const;
+ bool X::empty() const;
+}
+\end{itemdecl}
+
+\color{black}
+\eremove{Remove Table 80: Container requirements}
+
+\editorial{In translating the requirements table into a concept, we
+ have fixed numerous places where the requirements table required a
+ non-constant container, but where a constant container would
+ work. This should not break any existing code.}
+\color{addclr}
+
+\begin{itemdecl}
+X::X()
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\postcondition\
+\tcode{size() == 0}
+
+\pnum
+\complexity\
+constant
+\end{itemdescr}
+
+\begin{itemdecl}
+X::~X()
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\note\
+the destructor is applied to every element of \changedConcepts{a}{the
+ container}; all the memory is deallocated
+
+\pnum
+\complexity\
+linear
+\end{itemdescr}
+
+\begin{itemdecl}
+iterator X::begin();
+const_iterator X::begin() const;
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+an iterator referring to the first element in the container.
+\pnum
+\complexity\
+constant
+\end{itemdescr}
+
+\begin{itemdecl}
+iterator X::end();
+const_iterator X::end() const;
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+returns an iterator which is the past-the-end value for the container.
+If the container is empty, then
+\tcode{begin() == end()};
+
+\pnum
+\complexity\
+constant
+\end{itemdescr}
+
+\begin{itemdecl}
+const_iterator X::cbegin() const;
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{const_cast<X const\&>(*this).begin()}
+
+\pnum
+\complexity\
+constant
+\end{itemdescr}
+
+\begin{itemdecl}
+const_iterator X::cend() const;
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{const_cast<X const\&>(*this).end()}
+
+\pnum
+\complexity\
+constant
+\end{itemdescr}
+
+\begin{itemdecl}
+void X::swap(X& b)
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+\tcode{swap(*this, b)}
+
+\pnum
+\complexity\
+should be constant
+\end{itemdescr}
+
+\begin{itemdecl}
+size_type X::size() const
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+returns the number of elements in the container.
+
+\pnum
+\complexity\
+should be constant
+
+\pnum
+\note\
+\changedConcepts{Its semantics}{The semantics of size()} is defined by the rules of constructors, inserts, and erases.
+\end{itemdescr}
+
+\begin{itemdecl}
+size_type X::max_size() const
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{size()}\ of the largest possible container
+
+\pnum
+\complexity\
+should be constant
+\end{itemdescr}
+
+\begin{itemdecl}
+bool X::empty() const;
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{size() == 0}
+
+\pnum
+\complexity\
+constant
+\end{itemdescr}
+
+\pnum
+In the expressions
+\begin{codeblock}
+ i == j
+ i != j
+ i < j
+ i <= j
+ i >= j
+ i > j
+ i - j
+\end{codeblock}
+where
+\tcode{i}\
+and
+\tcode{j}\
+denote objects of a container's
+\tcode{iterator}\
+type, either or both may be replaced by an object of the container's
+\tcode{const_iterator}\
+type referring to the same element with no change in semantics.
+
+\color{black}
+\editorial{The requirements table for containers calls for copy
+ construction, assignment, and various comparison operators. However,
+ these operators only work when the value type supports copy
+ construction, assignment, etc. To capture this behaviro, we state
+ these requirements via concept map templates.}
+\color{addclr}
+
+\begin{itemdecl}
+@\textcolor{addclr}{template}@<Container X>
+where CopyConstructible<X::value_type>
+concept_map CopyConstructible<X> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+If the \tcode{value_type}\ of a container is
+\tcode{CopyConstructible}, the container shall be
+\tcode{CopyConstructible}
+
+\pnum
+\complexity\
+linear
+\end{itemdescr}
+
+\begin{itemdecl}
+template<Container X>
+where Assignable<X::value_type>
+concept_map Assignable<X> { }
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+If the \tcode{value_type}\ of a container is
+\tcode{Assignable}, the container shall be
+\tcode{Assignable}
+
+\pnum
+\complexity\
+linear
+\end{itemdescr}
+
+\begin{itemdecl}
+template<Container X>
+where EqualityComparable<X::value_type>
+concept_map EqualityComparable<X>
+{
+ bool operator==(X a, X b);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+If the \tcode{value_type}\ of a container is
+\tcode{EqualityComparable}, the container shall be
+\tcode{EqualityComparable}
+\end{itemdescr}
+
+\begin{itemdecl}
+bool operator==(X a, X b);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+ \tcode{==}\ is an equivalence relation.
+
+\pnum
+\returns\
+ \tcode{a.size() == b.size()}
+ \tcode{\&\& equal(a.begin(),}
+ \tcode{a.end(), b.begin()}
+
+\pnum
+\complexity\
+linear
+\end{itemdescr}
+
+\begin{itemdecl}
+template<Container X>
+where LessThanComparable<X::value_type>
+concept_map LessThanComparable<X>
+{
+ bool operator<(X a, X b);
+}
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+If the \tcode{value_type}\ of a container is
+\tcode{LessThanComparable}, the container shall be
+\tcode{LessThanComparable}
+\end{itemdescr}
+
+\begin{itemdecl}
+bool operator<(X a, X b);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+ \tcode{lexicographical_compare( a.begin(), a.end(), b.begin(), b.end())}
+
+\pnum
+\complexity\
+linear
+\end{itemdescr}
+
+\color{black}
+
+\pnum
+Copy constructors for all container types defined in this clause
+copy an allocator argument from their respective first parameters.
+All other constructors for these container types take an
+\tcode{Allocator\&}\
+argument (\ref{lib.allocator.requirements}),
+an allocator whose value type is the same as the container's value type.
+A copy of this argument is used for any memory allocation
+performed, by these constructors and by all member functions, during
+the lifetime of each container object.
+In all container types defined
+in this clause, the member \tcode{get_allocator()}\ returns a copy
+of the Allocator object used to construct the container.%
+\footnote{As specified in~\ref{lib.allocator.requirements}, \removedConcepts{paragraphs 4-5},
+the semantics described in this clause applies only to the case where
+allocators compare equal.
+}
+
+\pnum
+\addedConcepts{Containers that provide the ability to traverse their
+ elements in reverse order are called reversible.}
+
+\color{addclr}
+\begin{itemdecl}
+concept ReversibleContainer<typename X> : Container<X> {
+ MutableBidirectionalIterator reverse_iterator = X::reverse_iterator;
+ BidirectionalIterator const_reverse_iterator = X::const_reverse_iterator;
+
+ where MutableBidirectionalIterator<iterator> &&
+ BidirectionalIterator<const_iterator>;
+
+ where SameType<iterator::value_type, reverse_iterator::value_type> &&
+ SameType<const_iterator::value_type, const_reverse_iterator::value_type>;
+
+ reverse_iterator X::rbegin();
+ const_reverse_iterator X::rbegin() const;
+ reverse_iterator X::rend();
+ const_reverse_iterator X::rend() const;
+ const_reverse_iterator X::crbegin() const;
+ const_reverse_iterator X::crend() const;
+}
+\end{itemdecl}
+\color{black}
+
+\eremove{Remove Table 81: Reversible container requirements}
+
+\pnum
+If the iterator type of a container \changedConcepts{belongs to the bidirectional or
+random access iterator categories}{is bidirectional or random access} (\ref{lib.iterator.requirements}),
+\changedConcepts{the container is called
+reversible
+and satisfies the additional requirements
+in Table~81}{the container is reversible.}
+
+\color{addclr}
+\begin{itemdecl}
+template<Container X>
+where MutableBidirectionalIterator<X::iterator> &&
+ BidirectionalIterator<X::const_iterator>
+concept_map ReversibleContainer<X>
+{
+ typedef std::reverse_iterator<X::iterator> reverse_iterator;
+ typedef std::reverse_iterator<X::const_iterator> const_reverse_iterator;
+
+ @\textcolor{addclr}{reverse}@_iterator X::rbegin();
+ const_reverse_iterator X::rbegin() const;
+ reverse_iterator X::rend();
+ const_reverse_iterator X::rend() const;
+ const_reverse_iterator X::crbegin() const;
+ const_reverse_iterator X::crend() const;
+}
+\end{itemdecl}
+
+\begin{itemdecl}
+reverse_iterator X::rbegin();
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{reverse_iterator(end())}
+\end{itemdescr}
+
+\begin{itemdecl}
+const_reverse_iterator X::rbegin() const;
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{const_reverse_iterator(end())}
+\end{itemdescr}
+
+\begin{itemdecl}
+reverse_iterator X::rend();
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{const_reverse_iterator(begin())}
+\end{itemdescr}
+
+\begin{itemdecl}
+const_reverse_iterator X::rend() const;
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{const_reverse_iterator(begin())}
+\end{itemdescr}
+
+\begin{itemdecl}
+const_reverse_iterator X::crbegin() const;
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{const_cast<const X\&>(*this).rbegin()}
+\end{itemdescr}
+
+\begin{itemdecl}
+const_reverse_iterator X::crend() const;
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{const_cast<const X\&>(*this).rend()}
+\end{itemdescr}
+
+\color{black}
+
+\pnum
+Unless otherwise specified (see~\ref{lib.deque.modifiers}\ and
+\ref{lib.vector.modifiers})
+all container types defined in this clause meet
+the following additional requirements:
+
+\begin{itemize}
+\item
+if an exception is thrown by an
+\tcode{insert()}
+function while inserting a single element, that
+function has no effects.
+\item
+if an exception is thrown by a
+\tcode{push_back()}
+or
+\tcode{push_front()}
+function, that function has no effects.
+\item
+no
+\tcode{erase()},
+\tcode{pop_back()}
+or
+\tcode{pop_front()}
+function throws an exception.
+\item
+no copy constructor or assignment operator of a returned iterator
+throws an exception.
+\item
+no
+\tcode{swap()}
+function throws an exception unless that
+exception is thrown by the copy constructor or
+assignment operator of the container's
+Compare object (if any; see \ref{lib.associative.reqmts}).
+\item
+no
+\tcode{swap()}
+function invalidates any references,
+pointers, or iterators referring to the elements
+of the containers being swapped.
+\end{itemize}
+
+\pnum
+Unless otherwise specified (either explicitly or by defining a
+function in terms of other functions), invoking a container member
+function or passing a container as an argument to a library function
+shall not invalidate iterators to, or change the values of, objects
+within that container.
+
+\rSec2[lib.sequence.reqmts]{\textcolor{black}{Sequences}}
+
+\pnum
+A sequence is a kind of container that organizes a finite set of objects, all of the same type,
+into a strictly linear arrangement.
+The library provides three basic kinds of sequence containers:
+\tcode{vector},
+\tcode{list},
+and
+\tcode{deque}.
+It also provides container adaptors that make it easy to construct abstract data types, such as
+\tcode{stack}s
+or
+\tcode{queue}s,
+out of the basic sequence kinds (or out of other kinds of sequences that the user might define).
+
+\pnum
+\tcode{vector},
+\tcode{list},
+and
+\tcode{deque}
+offer the programmer different complexity trade-offs and should be used
+accordingly.
+\tcode{vector}\
+is the type of sequence that should be used by default.
+\tcode{list}\
+should be used when there are frequent insertions and deletions from the middle of the sequence.
+\tcode{deque}\
+is the data structure of choice
+when most insertions and deletions take place at the beginning or at the end of the sequence.
+
+\pnum
+\removedConcepts{In Tables~82
+and 83, X
+denotes a sequence class,
+a denotes a value of X,
+i and j
+denote iterators satisfying input iterator requirements,
+[i, j)
+denotes a valid range, n
+denotes a value of X::size\_type,
+p denotes a valid iterator to
+a, q
+denotes a valid dereferenceable iterator to
+a, [q1, q2)
+denotes a valid range in
+a, and t
+denotes a value of X::value\_type.}
+
+\pnum
+The complexities of the expressions are sequence dependent.
+
+\eremove{Remove Table 82: Sequence requirements (in addition to
+ container)}
+
+\color{addclr}
+\pnum
+Sequences are described by the \tcode{Sequence},
+\tcode{FrontInsertionSequence}, and \tcode{BackInsertionSequence} concepts.
+
+\begin{itemdecl}
+concept Sequence<typename X> : Container<X>
+{
+ where MutableForwardIterator<iterator> && ForwardIterator<const_iterator>;
+
+ X::X(size_type n, value_type t);
+
+ template<InputIterator Iter>
+ where Convertible<Iter::value_type, value_type>
+ X::X(Iter first, Iter last);
+
+ iterator X::insert(iterator p, value_type t);
+ void X::insert(iterator p, size_type n, value_type t);
+ template<InputIterator Iter>
+ where Convertible<Iter::value_type, value_type>
+ void X::insert(iterator p, Iter first, Iter last);
+
+ iterator X::erase(iterator q);
+ iterator X::erase(iterator q1, iterator q2);
+
+ void X::clear();
+
+ template<InputIterator Iter>
+ where Convertible<Iter::value_type, value_type>
+ void X::assign(Iter first, Iter last);
+ void X::assign(size_type n, value_type);
+}
+\end{itemdecl}
+
+\begin{itemdecl}
+X::X(size_type n, value_type t);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+constructs a sequence with \tcode{n}\ copies of \tcode{t}\
+
+\pnum
+\postcondition\
+\tcode{size() == n}
+\end{itemdescr}
+
+\begin{itemdecl}
+template<InputIterator Iter>
+ where Convertible<Iter::value_type, value_type>
+ X::X(Iter first, Iter last);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+constructs a sequence equal to the range \tcode{[i, j)}
+
+\pnum
+\postconditions\
+\tcode{size() == distance}\ between \tcode{i}\ and \tcode{j}
+\end{itemdescr}
+
+\begin{itemdecl}
+iterator X::insert(iterator p, value_type t);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+inserts a copy of \tcode{t}\ before \tcode{p}
+
+\pnum
+\returns\
+\addedConcepts{an iterator that} points to the copy of
+\tcode{t}\
+inserted into
+\tcode{a}.
+\end{itemdescr}
+
+\begin{itemdecl}
+void X::insert(iterator p, size_type n, value_type t);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+inserts \tcode{n}\ copies of \tcode{t}\ before \tcode{p}
+\end{itemdescr}
+
+\begin{itemdecl}
+template<InputIterator Iter>
+ where Convertible<Iter::value_type, value_type>
+ void X::insert(iterator p, Iter first, Iter last);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\precondition\
+\tcode{i}\ and \tcode{j}\ are not iterators into \tcode{a}
+
+\pnum
+\effects\
+inserts copies of elements in \tcode{[i, j)} before \tcode{p}
+\end{itemdescr}
+
+\begin{itemdecl}
+iterator X::erase(iterator q);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+erases the element pointed to by \tcode{q}
+
+\pnum
+\returns\
+\changedConcepts{The iterator returned from
+a.erase(q)}{An iterator that}\
+points to the element immediately following
+\tcode{q}\
+prior to the element being erased.
+If no such element exists,
+\tcode{a.end()}\
+is returned.
+\end{itemdescr}
+
+\begin{itemdecl}
+iterator X::erase(iterator q1, iterator q2);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+erases the elements in the range \tcode{[q1, q2)}.
+
+\pnum
+\returns\
+\changedConcepts{The iterator returned by
+a.erase(q1,q2)}{An iterator that}\
+points to the element pointed to by
+\tcode{q2}\
+prior to any elements being erased.
+If no such element exists,
+\tcode{a.end()}\
+is returned.
+\end{itemdescr}
+
+\begin{itemdecl}
+void X::clear();
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+\tcode{erase(begin(), end())}
+
+\pnum
+\postconditions\
+\tcode{size() == 0}
+\end{itemdescr}
+
+\begin{itemdecl}
+template<InputIterator Iter>
+ where Convertible<Iter::value_type, value_type>
+ void X::assign(Iter first, Iter last);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\precondition\
+\tcode{i}, \tcode{j}\ are not iterators into \tcode{a}
+
+\pnum
+\effects\
+Replaces elements in \tcode{a}\ with a copy of \tcode{[i, j)}.
+\end{itemdescr}
+
+\begin{itemdecl}
+void X::assign(size_type n, value_type);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\precondition\
+\tcode{t}\ is not a reference into \tcode{a}.
+
+\pnum
+\effects\
+Replaces elements in \tcode{a}\ with \tcode{n}\ copies of \tcode{t}.
+\end{itemdescr}
+
+\eremove{Remove paragraphs 5--11, including the ``do the right thing''
+clause.}
+
+\pnum
+\changedConcepts{Table~83 lists sequence operations
+that are provided for some types of
+sequential containers but not others.
+An implementation shall provide
+these operations for all container types shown in the ``container''
+column, and shall implement them so as to take amortized constant
+time.}{The BackAccessSequence concept describes sequences for which
+the last element can be accessed in amortized constant time.}
+
+\eremove{Remove Table 83: Optional sequence operations}
+
+\begin{itemdecl}
+concept BackAccessSequence<typename X> : Sequence<X>
+{
+ reference X::back();
+ const_reference X::back() const;
+}
+\end{itemdecl}
+
+\begin{itemdecl}
+reference X::back();
+const_reference X::back() const;
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+ \tcode{\{ iterator tmp = end();}\\
+ \tcode{ --tmp;}\\
+ \tcode{ return *tmp; \}}
+\end{itemdescr}
+
+\pnum The \tcode{BackInsertionSequence} concept describes sequences for which
+one can insert, remove, or access an element at the end of a container in
+amortized constant time.
+
+\begin{itemdecl}
+concept BackInsertionSequence<typename X> : BackAccessSequence<X>
+{
+ void X::push_back(value_type x);
+ void X::pop_back();
+}
+\end{itemdecl}
+
+\begin{itemdecl}
+void X::push_back(value_type x);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+\tcode{insert(end(),x)}
+\end{itemdescr}
+
+\begin{itemdecl}
+void X::pop_back();
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+ \tcode{\{ iterator tmp = end();}\\
+ \tcode{ --tmp;}\\
+ \tcode{ erase(tmp); \}}
+\end{itemdescr}
+
+\pnum
+The \tcode{FrontAccessSequence}\ concept describes sequences for which
+one can access the element at the front of the container in amortized
+constant time.
+
+\begin{itemdecl}
+concept FrontAccessSequence<typename X> : Sequence<X>
+{
+ reference X::front();
+ const_reference X::front() const;
+}
+\end{itemdecl}
+
+\begin{itemdecl}
+reference X::front();
+const_reference X::front() const;
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{*begin()}
+\end{itemdescr}
+
+\pnum
+The \tcode{FrontInsertionSequence}\ concept describes sequences for which
+one can insert, remove, or access an element at the front of a container in
+amortized constant time.
+
+\begin{itemdecl}
+concept FrontInsertionSequence<typename X> : FrontAccessSequence<X>
+{
+ void X::push_front(value_type x);
+ void X::pop_front();
+}
+\end{itemdecl}
+
+\begin{itemdecl}
+void X::push_front(value_type x);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+\tcode{insert(begin(),x)}
+\end{itemdescr}
+
+\begin{itemdecl}
+void X::pop_front();
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+\tcode{erase(begin())}
+\end{itemdescr}
+
+\pnum
+The \tcode{RandomAccessSequence} concept describes sequences that
+provide access to any element in the container in amortized constant
+time.
+
+\begin{itemdecl}
+concept RandomAccessSequence<typename X>
+ : FrontAccessSequence<X>, BackAccessSequence<X>
+{
+ where MutableRandomAccessIterator<iterator> &&
+ RandomAccessIterator<const_iterator>;
+
+ reference operator[](X& a, size_type n);
+ const_reference operator[](const X& a, size_type n);
+
+ reference at(X& a, size_type n);
+ const_reference at(const X& a, size_type n);
+}
+\end{itemdecl}
+
+\begin{itemdecl}
+reference operator[](X& a, size_type n);
+const_reference operator[](const X& a, size_type n);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{*(a.begin() + n)}
+\end{itemdescr}
+
+\begin{itemdecl}
+reference at(X& a, size_type n);
+const_reference at(const X& a, size_type n);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{*(a.begin() + n)}
+
+\pnum
+\throws
+\tcode{out_of_range} if \tcode{n >= a.size()}.
+\end{itemdescr}
+
+\color{black}
+
+\pnum
+\addedConcepts{An implementation shall provide the following concept
+ maps. When the implementation provides a vector<bool>
+ specialization, vector<T> only meets the sequence concept when T is
+ not bool.}
+\color{addclr}
+\begin{itemdecl}
+@\textcolor{addclr}{template}@<CopyConstructible T, Allocator Alloc>
+ where !SameType<T, bool> // iff vector<bool> specialization is provided
+ concept_map RandomAccessSequence<vector<T, Alloc> > { }
+template<CopyConstructible T, Allocator Alloc>
+ where !SameType<T, bool> // iff vector<bool> specialization is provided
+ concept_map BackInsertionSequence<vector<T, Alloc> > { }
+
+template<CopyConstructible T, Allocator Alloc>
+ concept_map BackInsertionSequence<list<T, Alloc> > { }
+template<CopyConstructible T, Allocator Alloc>
+ concept_map FrontInsertionSequence<list<T, Alloc> > { }
+
+template<CopyConstructible T, Allocator Alloc>
+ concept_map RandomAccessSequence<deque<T, Alloc> > { }
+template<CopyConstructible T, Allocator Alloc>
+ concept_map BackInsertionSequence<deque<T, Alloc> > { }
+template<CopyConstructible T, Allocator Alloc>
+ concept_map FrontInsertionSequence<deque<T, Alloc> > { }
+\end{itemdecl}
+\color{black}
+
+\rSec1[lib.sequences]{Sequences}
+
+\pnum
+Headers \tcode{<array>}, \tcode{<deque>}, \tcode{<list>}, \tcode{<queue>},
+\tcode{<stack>}, and \tcode{<vector>}.
+
+\synopsis{Header \tcode{<vector>}\ synopsis}%
+\index{vector@\tcode{<vector>}}
+
+\begin{codeblock}
+namespace std {
+ template <class T, @\addedConcepts{Allocator Alloc}@ = allocator<T> >
+ @\addedConcepts{where SameType<T, Alloc::value_type>}@ class vector;
+ template <class T, class Alloc>
+ @\addedConcepts{where EqualityComparable<T>}@
+ bool operator==(const vector<T,Alloc>& x,
+ const vector<T,Alloc>& y);
+ template <class T, class Alloc>
+ @\addedConcepts{where LessThanComparable<T>}@
+ bool operator< (const vector<T,Alloc>& x,
+ const vector<T,Alloc>& y);
+ template <class T, class Alloc>
+ @\addedConcepts{where EqualityComparable<T>}@
+ bool operator!=(const vector<T,Alloc>& x,
+ const vector<T,Alloc>& y);
+ template <class T, class Alloc>
+ @\addedConcepts{where LessThanComparable<T>}@
+ bool operator> (const vector<T,Alloc>& x,
+ const vector<T,Alloc>& y);
+ template <class T, class Alloc>
+ @\addedConcepts{where LessThanComparable<T>}@
+ bool operator>=(const vector<T,Alloc>& x,
+ const vector<T,Alloc>& y);
+ template <class T, class Alloc>
+ @\addedConcepts{where LessThanComparable<T>}@
+ bool operator<=(const vector<T,Alloc>& x,
+ const vector<T,Alloc>& y);
+
+ // specialized algorithms:
+ template <class T, @\changedConcepts{class}{Allocator}@ Alloc>
+ void swap(vector<T,Alloc>& x, vector<T,Alloc>& y);
+}
+\end{codeblock}
+
+\setcounter{subsection}{3}
+\rSec2[lib.container.adaptors]{Container adaptors}
+
+\pnum
+The container adaptors each take a Container template parameter,
+and each constructor takes a Container reference argument.
+This
+container is copied into the Container member of each adaptor.
+
+\rSec3[lib.queue]{Class template \tcode{queue}}
+
+\pnum
+\index{queue@\tcode{queue}}%
+Any \changedConcepts{sequence supporting operations
+front(),
+back(),
+push_back()
+and
+pop_front()}{container that meets the requirements of the
+Back Insertion Sequence and Front Insertion Sequence concepts}
+can be used to instantiate
+\tcode{queue}.
+In particular,
+\tcode{list}\
+(\ref{lib.list})
+and
+\tcode{deque}\
+(\ref{lib.deque})
+can be used.
+
+\rSec4[lib.queue.defn]{\tcode{queue} definition}
+
+\begin{codeblock}
+namespace std {
+ template <class T, @\addedConcepts{FrontInsertionSequence Container}@ = deque<T> >
+ @\addedConcepts{where BackInsertionSequence<Cont>}@
+ class queue {
+ public:
+ typedef Container::value_type value_type;
+ typedef Container::reference reference;
+ typedef Container::const_reference const_reference;
+ typedef Container::size_type size_type;
+ typedef Container container_type;
+ protected:
+ Container c;
+
+ public:
+ explicit queue(const Container& = Container());
+
+ bool empty() const { return c.empty(); }
+ size_type size() const { return c.size(); }
+ reference front() { return c.front(); }
+ const_reference front() const { return c.front(); }
+ reference back() { return c.back(); }
+ const_reference back() const { return c.back(); }
+ void push(const value_type& x) { c.push_back(x); }
+ void pop() { c.pop_front(); }
+ };
+
+ template <class T, class Container>
+ @\addedConcepts{where EqualityComparable<Container>}@
+ bool operator==(const queue<T, Container>& x,
+ const queue<T, Container>& y);
+ template <class T, class Container>
+ @\addedConcepts{where LessThanComparable<Container>}@
+ bool operator< (const queue<T, Container>& x,
+ const queue<T, Container>& y);
+ template <class T, class Container>
+ @\addedConcepts{where EqualityComparable<Container>}@
+ bool operator!=(const queue<T, Container>& x,
+ const queue<T, Container>& y);
+ template <class T, class Container>
+ @\addedConcepts{where LessThanComparable<Container>}@
+ bool operator> (const queue<T, Container>& x,
+ const queue<T, Container>& y);
+ template <class T, class Container>
+ @\addedConcepts{where LessThanComparable<Container>}@
+ bool operator>=(const queue<T, Container>& x,
+ const queue<T, Container>& y);
+ template <class T, class Container>
+ @\addedConcepts{where LessThanComparable<Container>}@
+ bool operator<=(const queue<T, Container>& x,
+ const queue<T, Container>& y);
+}
+\end{codeblock}
+
+\rSec4[lib.queue.ops]{\tcode{queue} operators}
+
+\index{operator==@\tcode{operator==}!queue@\tcode{queue}}%
+\begin{itemdecl}
+template <class T, class Container>
+ @\addedConcepts{where EqualityComparable<Container>}@
+ bool operator==(const queue<T, Container>& x,
+ const queue<T, Container>& y);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{x.c == y.c}.
+\end{itemdescr}
+
+\index{operator"!=@\tcode{operator"!=}!queue@\tcode{queue}}%
+\begin{itemdecl}
+template <class T, class Container>
+ @\addedConcepts{where EqualityComparable<Container>}@
+ bool operator!=(const queue<T, Container>& x,
+ const queue<T, Container>& y);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{x.c != y.c}.
+\end{itemdescr}
+
+\index{operator<@\tcode{operator<}!queue@\tcode{queue}}%
+\begin{itemdecl}
+template <class T, class Container>
+ @\addedConcepts{where LessThanComparable<Container>}@
+ bool operator< (const queue<T, Container>& x,
+ const queue<T, Container>& y);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{x.c < y.c}.
+\end{itemdescr}
+
+\index{operator<=@\tcode{operator<=}!queue@\tcode{queue}}%
+\begin{itemdecl}
+template <class T, class Container>
+ @\addedConcepts{where LessThanComparable<Container>}@
+ bool operator<=(const queue<T, Container>& x,
+ const queue<T, Container>& y);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{x.c <= y.c}.
+\end{itemdescr}
+
+\index{operator>@\tcode{operator>}!queue@\tcode{queue}}%
+\begin{itemdecl}
+template <class T, class Container>
+ @\addedConcepts{where LessThanComparable<Container>}@
+ bool operator> (const queue<T, Container>& x,
+ const queue<T, Container>& y);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{x.c > y.c}.
+\end{itemdescr}
+
+\index{operator>=@\tcode{operator>=}!queue@\tcode{queue}}%
+\begin{itemdecl}
+template <class T, class Container>
+ @\addedConcepts{where LessThanComparable<Container>}@
+ bool operator>=(const queue<T, Container>& x,
+ const queue<T, Container>& y);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{x.c >= y.c}.
+\end{itemdescr}
+
+\rSec3[lib.priority.queue]{Class template \tcode{priority_queue}}
+
+\pnum
+\index{priority_queue@\tcode{priority_queue}}%
+Any sequence with random access iterator and supporting operations
+\tcode{front()},
+\tcode{push_back()}\
+and
+\tcode{pop_back()}\
+can be used to instantiate
+\tcode{priority_queue}.
+In particular,
+\tcode{vector}\
+(\ref{lib.vector})
+and
+\tcode{deque}\
+(\ref{lib.deque})
+can be used.
+Instantiating
+\tcode{priority_queue}\
+also involves supplying a function or function object for making priority comparisons;
+the library assumes that the function or function object defines a strict
+weak ordering (\ref{lib.alg.sorting}).
+
+\begin{codeblock}
+namespace std {
+ template <class T, @\addedConcepts{RandomAccessSequence Container}@ = vector<T>,
+ @\addedConcepts{BinaryPredicate<Container::value_type, Container::value_type>}@ Compare
+ = less<Container::value_type> >
+ @\addedConcepts{where CopyConstructible<Compare>}@
+ class priority_queue {
+ public:
+ typedef Container::value_type value_type;
+ typedef Container::reference reference;
+ typedef Container::const_reference const_reference;
+ typedef Container::size_type size_type;
+ typedef Container container_type;
+ protected:
+ Container c;
+ Compare comp;
+
+ public:
+ explicit priority_queue(const Compare& x = Compare(),
+ const Container& = Container());
+ template <@\addedConcepts{InputIterator Iter}@>
+ @\addedConcepts{where Convertible<Iter::value_type, value_type>}@
+ priority_queue(Iter first, Iter last,
+ const Compare& x = Compare(),
+ const Container& = Container());
+
+ bool empty() const { return c.empty(); }
+ size_type size() const { return c.size(); }
+ const_reference top() const { return c.front(); }
+ void push(const value_type& x);
+ void pop();
+ };
+ // no equality is provided
+}
+\end{codeblock}
+
+\rSec4[lib.priqueue.cons]{\tcode{priority_queue}\ constructors}
+
+\index{priority_queue@\tcode{priority_queue}!\tcode{priority_queue}}%
+\begin{itemdecl}
+priority_queue(const Compare& x = Compare(),
+ const Container& y = Container());
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\requires\
+\farg{x}\ defines a strict weak ordering (\ref{lib.alg.sorting}).
+
+\pnum
+\effects\
+Initializes
+\tcode{comp}\ with
+\tcode{x}\ and
+\tcode{c}\ with
+\tcode{y};
+calls
+\tcode{make_heap(c.begin(), c.end(), comp)}.
+\end{itemdescr}
+
+\begin{itemdecl}
+template <@\addedConcepts{InputIterator Iter}@>
+ @\addedConcepts{where Convertible<Iter::value_type, value_type>}@
+ priority_queue(Iter first, Iter last,
+ const Compare& x = Compare(),
+ const Container& y = Container());
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\requires\
+\farg{x}\ defines a strict weak ordering (\ref{lib.alg.sorting}).
+
+\pnum
+\effects\
+Initializes
+\tcode{c}\ with
+\tcode{y}\ and
+\tcode{comp}\ with
+\tcode{x};
+calls
+\tcode{c.insert(c.end(), first, last)};
+and finally calls
+\tcode{make_heap(c.begin(), c.end(), comp)}.
+\end{itemdescr}
+
+\rSec4[lib.priqueue.members]{\tcode{priority_queue}\ members}
+
+\index{push@\tcode{push}!\tcode{priority_queue}}%
+\begin{itemdecl}
+void push(const value_type& x);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+\begin{codeblock}
+c.push_back(x);
+push_heap(c.begin(), c.end(), comp);
+\end{codeblock}
+\end{itemdescr}
+
+\index{pop@\tcode{pop}!\tcode{priority_queue}}%
+\begin{itemdecl}
+void pop();
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+\begin{codeblock}
+pop_heap(c.begin(), c.end(), comp);
+c.pop_back();
+\end{codeblock}
+\end{itemdescr}
+
+\rSec3[lib.stack]{Class template \tcode{stack}}
+
+\pnum
+\index{stack@\tcode{stack}}%
+Any sequence supporting operations
+\tcode{back()},
+\tcode{push_back()}\
+and
+\tcode{pop_back()}\
+can be used to instantiate
+\tcode{stack}.
+In particular,
+\tcode{vector}\
+(\ref{lib.vector}),
+\tcode{list}\
+(\ref{lib.list})
+and
+\tcode{deque}\
+(\ref{lib.deque})
+can be used.
+
+\rSec4[lib.stack.defn]{\tcode{stack} definition}
+
+\begin{codeblock}
+namespace std {
+ template <class T, @\addedConcepts{BackInsertionSequence Container}@ = deque<T> >
+ class stack {
+ public:
+ typedef Container::value_type value_type;
+ typedef Container::reference reference;
+ typedef Container::const_reference const_reference;
+ typedef Container::size_type size_type;
+ typedef Container container_type;
+ protected:
+ Container c;
+
+ public:
+ explicit stack(const Container& = Container());
+
+ bool empty() const { return c.empty(); }
+ size_type size() const { return c.size(); }
+ reference top() { return c.back(); }
+ const_reference top() const { return c.back(); }
+ void push(const value_type& x) { c.push_back(x); }
+ void pop() { c.pop_back(); }
+ };
+
+ template <class T, class Container>
+ @\addedConcepts{where EqualityComparable<Container::value_type>}@
+ bool operator==(const stack<T, Container>& x,
+ const stack<T, Container>& y);
+ template <class T, class Container>
+ @\addedConcepts{where LessThanComparable<Container::value_type>}@
+ bool operator< (const stack<T, Container>& x,
+ const stack<T, Container>& y);
+ template <class T, class Container>
+ @\addedConcepts{where EqualityComparable<Container::value_type>}@
+ bool operator!=(const stack<T, Container>& x,
+ const stack<T, Container>& y);
+ template <class T, class Container>
+ @\addedConcepts{where LessThanComparable<Container::value_type>}@
+ bool operator> (const stack<T, Container>& x,
+ const stack<T, Container>& y);
+ template <class T, class Container>
+ @\addedConcepts{where LessThanComparable<Container::value_type>}@
+ bool operator>=(const stack<T, Container>& x,
+ const stack<T, Container>& y);
+ template <class T, class Container>
+ @\addedConcepts{where LessThanComparable<Container::value_type>}@
+ bool operator<=(const stack<T, Container>& x,
+ const stack<T, Container>& y);
+}
+\end{codeblock}
+
+\rSec4[lib.stack.ops]{\tcode{stack} operators}
+
+\index{operator==@\tcode{operator==}!stack@\tcode{stack}}%
+\begin{itemdecl}
+template <class T, class Container>
+ @\addedConcepts{where EqualityComparable<Container::value_type>}@
+ bool operator==(const stack<T, Container>& x,
+ const stack<T, Container>& y);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{x.c == y.c}.
+\end{itemdescr}
+
+\index{operator"!=@\tcode{operator"!=}!stack@\tcode{stack}}%
+\begin{itemdecl}
+template <class T, class Container>
+ @\addedConcepts{where EqualityComparable<Container::value_type>}@
+ bool operator!=(const stack<T, Container>& x,
+ const stack<T, Container>& y);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{x.c != y.c}.
+\end{itemdescr}
+
+\index{operator<@\tcode{operator<}!stack@\tcode{stack}}%
+\begin{itemdecl}
+template <class T, class Container>
+ @\addedConcepts{where LessThanComparable<Container::value_type>}@
+ bool operator< (const stack<T, Container>& x,
+ const stack<T, Container>& y);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{x.c < y.c}.
+\end{itemdescr}
+
+\index{operator<=@\tcode{operator<=}!stack@\tcode{stack}}%
+\begin{itemdecl}
+template <class T, class Container>
+ @\addedConcepts{where LessThanComparable<Container::value_type>}@
+ bool operator<=(const stack<T, Container>& x,
+ const stack<T, Container>& y);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{x.c <= y.c}.
+\end{itemdescr}
+
+\index{operator>@\tcode{operator>}!stack@\tcode{stack}}%
+\begin{itemdecl}
+template <class T, class Container>
+ @\addedConcepts{where LessThanComparable<Container::value_type>}@
+ bool operator> (const stack<T, Container>& x,
+ const stack<T, Container>& y);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{x.c > y.c}.
+\end{itemdescr}
+
+\index{operator>=@\tcode{operator>=}!stack@\tcode{stack}}%
+\begin{itemdecl}
+template <class T, class Container>
+ @\addedConcepts{where LessThanComparable<Container::value_type>}@
+ bool operator>=(const stack<T, Container>& x,
+ const stack<T, Container>& y);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{x.c >= y.c}.
+\end{itemdescr}
+
+\rSec2[lib.vector]{Class template \tcode{vector}}
+
+\pnum
+\index{vector@\tcode{vector}}%
+A
+\tcode{vector}\
+is a kind of sequence that supports random access iterators.
+In addition, it supports (amortized) constant time insert and erase operations at the end;
+insert and erase in the middle take linear time.
+Storage management is handled automatically, though hints can be given
+to improve efficiency.
+The elements of a vector are stored contiguously, meaning that if
+\tcode{v}\
+is a
+\tcode{vector<T, Alloc>}\
+where
+\tcode{T}\
+is some type other than
+\tcode{bool},
+then it obeys the identity
+\tcode{\&v[n] == \&v[0] + n}\
+for all
+\tcode{0 <= n < v.size()}.
+
+\pnum
+A
+\tcode{vector}\
+satisfies all of the requirements of a container and of a reversible container
+\removedConcepts{(given in two tables in~23.1)} and of a sequence,
+including most of the optional sequence requirements (\ref{lib.sequence.reqmts}).
+The exceptions are the
+\tcode{push_front}\
+and
+\tcode{pop_front}\
+member functions, which are not provided.
+\removedConcepts{In addition to the requirements on the stored object
+ described in 23.1, the stored object shall meet the requirements
+of Assignable.}
+Descriptions are provided here only for operations on
+\tcode{vector}\
+that are not described in one of these \changedConcepts{tables}{concepts}
+or for operations where there is additional semantic information.
+
+\begin{codeblock}
+namespace std {
+ template <class T, @\changedConcepts{class}{Allocator}@ Alloc = allocator<T> >
+ @\addedConcepts{where SameType<T, Alloc::value_type>}@
+ class vector {
+ public:
+ // types:
+ typedef typename Alloc::reference reference;
+ typedef typename Alloc::const_reference const_reference;
+ typedef @\impdef@ iterator; // See \ref{lib.container.requirements}
+ typedef @\impdef@ const_iterator; // See \ref{lib.container.requirements}
+ typedef @\impdef@ size_type; // See \ref{lib.container.requirements}
+ typedef @\impdef@ difference_type;// See \ref{lib.container.requirements}
+ typedef T value_type;
+ typedef Alloc allocator_type;
+ typedef typename Alloc::pointer pointer;
+ typedef typename Alloc::const_pointer const_pointer;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+ // \ref{lib.vector.cons} construct/copy/destroy:
+ explicit vector(const Alloc& = Alloc());
+ @\addedConcepts{where CopyConstructible<T>}@
+ explicit vector(size_type n, const T& value = T(), const Alloc& = Alloc());
+
+ template <@\addedConcepts{InputIterator Iter}@>
+ @\addedConcepts{where Convertible<Iter::value_type, T>}@
+ vector(Iter first, Iter last, const Alloc& = Alloc());
+ template <@\addedConcepts{ForwardIterator Iter}@>
+ @\addedConcepts{where Convertible<Iter::value_type, T>}@
+ vector(Iter first, Iter last, const Alloc& = Alloc());
+ @\addedConcepts{where CopyConstructible<T>}@ vector(const vector<T,Alloc>& x);
+ ~vector();
+ @\addedConcepts{where CopyConstructible<T> \&\& Assignable<T>}@
+ vector<T,Alloc>& operator=(const vector<T,Alloc>& x);
+ template <@\addedConcepts{InputIterator Iter}@>
+ @\addedConcepts{Convertible<Iter::value_type, T> \&\& CopyConstructible<T> \&\& Assignable<T>}@
+ void assign(Iter first, Iter last);
+ @\addedConcepts{where CopyConstructible<T> \&\& Assignable<T>}@ void assign(size_type n, const T& u);
+ allocator_type get_allocator() const;
+
+ // iterators:
+ iterator begin();
+ const_iterator begin() const;
+ iterator end();
+ const_iterator end() const;
+ reverse_iterator rbegin();
+ const_reverse_iterator rbegin() const;
+ reverse_iterator rend();
+ const_reverse_iterator rend() const;
+
+ // \ref{lib.vector.capacity} capacity:
+ size_type size() const;
+ size_type max_size() const;
+ @\addedConcepts{where CopyConstructible<T> \&\& Assignable<T>}@ void resize(size_type sz, T c = T());
+ size_type capacity() const;
+ bool empty() const;
+ @\addedConcepts{where CopyConstructible<T>}@ void reserve(size_type n);
+
+ // element access:
+ reference operator[](size_type n);
+ const_reference operator[](size_type n) const;
+ const_reference at(size_type n) const;
+ reference at(size_type n);
+ reference front();
+ const_reference front() const;
+ reference back();
+ const_reference back() const;
+
+ @\addedA{// \mbox{\ref{lib.vector.data}} data access}@
+ @\addedA{pointer data();}@
+ @\addedA{const_pointer data() const;}@
+
+ // \ref{lib.vector.modifiers} modifiers:
+ void push_back(const T& x);
+ void pop_back();
+ @\addedConcepts{where CopyConstructible<T> \&\& Assignable<T>}@
+ iterator insert(iterator position, const T& x);
+ @\addedConcepts{where CopyConstructible<T> \&\& Assignable<T>}@
+ void insert(iterator position, size_type n, const T& x);
+ template <@\addedConcepts{InputIterator Iter}@>
+ @\addedConcepts{Convertible<Iter::value_type, T> \&\& CopyConstructible<T> \&\& Assignable<T>}@
+ void insert(iterator position, Iter first, Iter last);
+ template <@\addedConcepts{ForwardIterator Iter}@>
+ @\addedConcepts{Convertible<Iter::value_type, T> \&\& CopyConstructible<T> \&\& Assignable<T>}@
+ void insert(iterator position, Iter first, Iter last);
+ @\addedConcepts{where Assignable<T>}@ iterator erase(iterator position);
+ @\addedConcepts{where Assignable<T>}@ iterator erase(iterator first, iterator last);
+ void swap(vector<T,Alloc>&);
+ void clear();
+ };
+
+ template <class T, class Alloc>
+ @\addedConcepts{where EqualityComparable<T>}@
+ bool operator==(const vector<T,Alloc>& x,
+ const vector<T,Alloc>& y);
+ template <class T, class Alloc>
+ @\addedConcepts{where LessThanComparable<T>}@
+ bool operator< (const vector<T,Alloc>& x,
+ const vector<T,Alloc>& y);
+ template <class T, class Alloc>
+ @\addedConcepts{where EqualityComparable<T>}@
+ bool operator!=(const vector<T,Alloc>& x,
+ const vector<T,Alloc>& y);
+ template <class T, class Alloc>
+ @\addedConcepts{where LessThanComparable<T>}@
+ bool operator> (const vector<T,Alloc>& x,
+ const vector<T,Alloc>& y);
+ template <class T, class Alloc>
+ @\addedConcepts{where LessThanComparable<T>}@
+ bool operator>=(const vector<T,Alloc>& x,
+ const vector<T,Alloc>& y);
+ template <class T, class Alloc>
+ @\addedConcepts{where LessThanComparable<T>}@
+ bool operator<=(const vector<T,Alloc>& x,
+ const vector<T,Alloc>& y);
+
+ // specialized algorithms:
+ template <class T, @\changedConcepts{class}{Allocator}@ Alloc>
+ void swap(vector<T,Alloc>& x, vector<T,Alloc>& y);
+}
+\end{codeblock}%
+\index{vector@\tcode{vector}!\tcode{operator==}}%
+\index{vector@\tcode{vector}!\tcode{operator<}}
+
+\rSec3[lib.vector.cons]{\tcode{vector}\ constructors, copy, and assignment}
+
+\index{vector@\tcode{vector}!\tcode{vector}}
+\begin{itemdecl}
+vector(const Allocator& = Allocator());
+@\addedConcepts{where CopyConstructible<T>}@
+ explicit vector(size_type n, const T& value = T(), const Allocator& = Allocator());
+template <@\addedConcepts{InputIterator Iter}@>
+ @\addedConcepts{where Convertible<Iter::value_type, T>}@
+ vector(Iter first, Iter last, const Allocator& = Allocator());
+template <@\addedConcepts{ForwardIterator Iter}@>
+ @\addedConcepts{where Convertible<Iter::value_type, T>}@
+ vector(Iter first, Iter last, const Allocator& = Allocator());
+@\addedConcepts{where CopyConstructible<T>}@ vector(const vector<T,Allocator>& x);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\complexity\
+The constructor
+\addedConcepts{that accepts a forward iterator range}
+makes only $N$
+calls to the copy constructor of
+\tcode{T}\
+(where $N$
+is the distance between
+\tcode{first}\
+and
+\tcode{last})
+and no reallocations if iterators
+\removedConcepts{
+first and last are of forward, bidirectional, or random access
+categories}.
+\changedConcepts{It}{The constructor that accepts an input iterator range}
+ makes order
+\tcode{N}\
+calls to the copy constructor of
+\tcode{T}\
+and order
+$\log(N)$
+reallocations\removedConcepts{ if they are just input iterators}.
+\end{itemdescr}
+
+\index{assign@\tcode{assign}!\tcode{vector}}%
+\begin{itemdecl}
+template <@\addedConcepts{InputIterator Iter}@>
+ @\addedConcepts{Convertible<Iter::value_type, T> \&\& CopyConstructible<T> \&\& Assignable<T>}@
+ void assign(Iter first, Iter last);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+\begin{codeblock}
+ erase(begin(), end());
+ insert(begin(), first, last);
+\end{codeblock}
+\end{itemdescr}
+
+\begin{itemdecl}
+@\addedConcepts{where CopyConstructible<T> \&\& Assignable<T>}@ void assign(size_type n, const T& t);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+\begin{codeblock}
+ erase(begin(), end());
+ insert(begin(), n, t);
+\end{codeblock}
+\end{itemdescr}
+
+\rSec3[lib.vector.capacity]{\tcode{vector}\ capacity}
+
+\index{capacity@\tcode{capacity}!\tcode{vector}}%
+\begin{itemdecl}
+size_type capacity() const;
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+The total number of elements that the vector can hold
+without requiring reallocation.
+\end{itemdescr}
+
+\index{reserve@\tcode{reserve}!\tcode{vector}}%
+\begin{itemdecl}
+@\addedConcepts{where CopyConstructible<T>}@ void reserve(size_type n);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+A directive that informs a
+\tcode{vector}\
+of a planned change in size, so that it can manage the storage allocation accordingly.
+After
+\tcode{reserve()},
+\tcode{capacity()}\
+is greater or equal to the argument of
+\tcode{reserve}\
+if reallocation happens; and equal to the previous value of
+\tcode{capacity()}\
+otherwise.
+Reallocation happens at this point if and only if the current capacity is less than the
+argument of
+\tcode{reserve()}.
+
+\pnum
+\complexity\
+It does not change the size of the sequence and takes at most linear time in the size of the sequence.
+
+\pnum
+\throws\
+\tcode{length_error}\
+if
+\tcode{\farg{n} > max_size()}.%
+\footnote{
+\tcode{reserve()}\
+uses
+\tcode{Allocator::allocate()}\
+which may throw an appropriate exception.
+}
+
+\pnum
+\notes\
+Reallocation invalidates all the references, pointers, and iterators
+referring to the elements in the sequence.
+It is guaranteed that no reallocation takes place during insertions that happen
+after a call to
+\tcode{reserve()}\
+until the time when an insertion would make the size of the vector
+greater than the value of
+\tcode{capacity()}.
+\end{itemdescr}
+
+\index{swap@\tcode{swap}!\tcode{vector}}%
+\begin{itemdecl}
+void swap(vector<T,Allocator>& x);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Exchanges the contents and
+\tcode{capacity()}\
+of
+\tcode{*this}\
+with that of \tcode{x}.
+
+\pnum
+\complexity\
+Constant time.
+\end{itemdescr}
+
+\index{resize@\tcode{resize}!\tcode{vector}}%
+\begin{itemdecl}
+@\addedConcepts{where CopyConstructible<T> \&\& Assignable<T>}@ void resize(size_type sz, T c = T());
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+\begin{codeblock}
+ if (sz > size())
+ insert(end(), sz-size(), c);
+ else if (sz < size())
+ erase(begin()+sz, end());
+ else
+ ; // do nothing
+\end{codeblock}
+\end{itemdescr}
+
+\rSec3[lib.vector.data]{\tcode{vector}\ data}
+\index{data@\tcode{data}!\tcode{vector}}%
+\begin{itemdecl}
+@\addedA{pointer data();}@
+@\addedA{const_pointer data() const;}@
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedA{\mbox{\returns}
+A pointer such that \mbox{\range{data()}{data() + size()}} is a valid range. For a
+non-empty vector, \mbox{\tcode{data()}} \mbox{\tcode{==}} \mbox{\tcode{\&front()}}.}
+
+\pnum
+\addedA{\mbox{\complexity}
+Constant time.}
+
+\pnum
+\addedA{\mbox{\throws}
+Nothing.}
+\end{itemdescr}
+
+\rSec3[lib.vector.modifiers]{\tcode{vector}\ modifiers}
+
+\index{insert@\tcode{insert}!\tcode{vector}}%
+\begin{itemdecl}
+@\addedConcepts{where CopyConstructible<T> \&\& Assignable<T>}@
+ iterator insert(iterator position, const T& x);
+@\addedConcepts{where CopyConstructible<T> \&\& Assignable<T>}@
+ void insert(iterator position, size_type n, const T& x);
+template <@\addedConcepts{InputIterator Iter}@>
+ @\addedConcepts{Convertible<Iter::value_type, T> \&\& CopyConstructible<T> \&\& Assignable<T>}@
+ void insert(iterator position, Iter first, Iter last);
+template <@\addedConcepts{ForwardIterator Iter}@>
+ @\addedConcepts{Convertible<Iter::value_type, T> \&\& CopyConstructible<T> \&\& Assignable<T>}@
+ void insert(iterator position, Iter first, Iter last);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\notes\
+Causes reallocation if the new size is greater than the old capacity.
+If no reallocation happens, all the iterators and references before the insertion point remain valid.
+If an exception is thrown other than by
+the copy constructor or assignment operator of
+\tcode{T}\ or by any \tcode{InputIterator} operation
+there are no effects.
+
+\pnum
+\complexity\
+If
+\tcode{first}\
+and
+\tcode{last}\
+are forward iterators\removedConcepts{bidirectional iterators, or random access
+iterators}, the complexity is linear in the number of elements in the range
+\range{first}{last}\
+plus the distance to the end of the vector.
+If they are input iterators, the complexity is proportional to
+the number of elements in the range
+\range{first}{last}\
+times the distance to the end of the vector.
+\end{itemdescr}
+
+\index{erase@\tcode{erase}!\tcode{vector}}%
+\begin{itemdecl}
+@\addedConcepts{where Assignable<T>}@ iterator erase(iterator position);
+@\addedConcepts{where Assignable<T>}@ iterator erase(iterator first, iterator last);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Invalidates iterators and references at or after the point of the erase.
+
+\pnum
+\complexity\
+The destructor of
+\tcode{T}\
+is called the number of times equal to the number of the elements erased,
+but the assignment operator of
+\tcode{T}\
+is called the number of times equal to the number of elements in the vector after the erased elements.
+
+\pnum
+\throws\
+Nothing unless an exception is thrown by the
+copy constructor or assignment operator of
+\tcode{T}.
+\end{itemdescr}
+
+\rSec3[lib.vector.special]{\tcode{vector}\ specialized algorithms}
+
+\begin{itemdecl}
+template <class T, @\addedConcepts{Allocator Alloc}@>
+ void swap(vector<T,Alloc>& x, vector<T,Alloc>& y);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+\begin{codeblock}
+ x.swap(y);
+\end{codeblock}
+\end{itemdescr}
+
+\rSec2[lib.vector.bool]{\addedConcepts{Deprecated} class \tcode{vector<bool>}}
+
+\pnum
+\index{vector<bool>@\tcode{vector<bool>}}%
+To optimize space allocation, a specialization of vector for
+\tcode{bool}
+elements may be provided:
+
+\begin{codeblock}
+namespace std {
+ template <@\addedConcepts{Allocator}@ Alloc> class vector<bool, Alloc> {
+ public:
+ // types:
+ typedef bool const_reference;
+ typedef @\impdef@ iterator; // See \ref{lib.container.requirements}
+ typedef @\impdef@ const_iterator; // See \ref{lib.container.requirements}
+ typedef @\impdef@ size_type; // See \ref{lib.container.requirements}
+ typedef @\impdef@ difference_type;// See \ref{lib.container.requirements}
+ typedef bool value_type;
+ typedef Alloc allocator_type;
+ typedef @\impdef@ pointer;
+ typedef @\impdef@ const_pointer;
+ typedef std::reverse_iterator<iterator> reverse_iterator;
+ typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
+
+ // bit reference:
+ class reference {
+ friend class vector;
+ reference();
+ public:
+ ~reference();
+ operator bool() const;
+ reference& operator=(const bool x);
+ reference& operator=(const reference& x);
+ void flip(); // flips the bit
+ };
+
+ // construct/copy/destroy:
+ explicit vector(const Alloc& = Alloc());
+ explicit vector(size_type n, const bool& value = bool(),
+ const Alloc& = Alloc());
+ template <@\addedConcepts{InputIterator Iter}@>
+ @\addedConcepts{where Convertible<Iter::value_type, bool>}@
+ vector(Iter first, Iter last, const Alloc& = Alloc());
+ template <@\addedConcepts{ForwardIterator Iter}@>
+ @\addedConcepts{where Convertible<Iter::value_type, bool>}@
+ vector(Iter first, Iter last, const Alloc& = Alloc());
+ vector(const vector<bool,Alloc>& x);
+ ~vector();
+ vector<bool,Alloc>& operator=(const vector<bool,Alloc>& x);
+ template <@\addedConcepts{InputIterator Iter}@>
+ @\addedConcepts{where Convertible<Iter::value_type, bool>}@
+ void assign(Iter first, Iter last);
+ template <@\addedConcepts{ForwardIterator Iter}@>
+ @\addedConcepts{where Convertible<Iter::value_type, bool>}@
+ void assign(Iter first, Iter last);
+ void assign(size_type n, const @\changedA{T}{bool}@& t);
+ allocator_type get_allocator() const;
+
+ // iterators:
+ iterator begin();
+ const_iterator begin() const;
+ iterator end();
+ const_iterator end() const;
+ reverse_iterator rbegin();
+ const_reverse_iterator rbegin() const;
+ reverse_iterator rend();
+ const_reverse_iterator rend() const;
+
+ // capacity:
+ size_type size() const;
+ size_type max_size() const;
+ void resize(size_type sz, bool c = false);
+ size_type capacity() const;
+ bool empty() const;
+ void reserve(size_type n);
+
+ // element access:
+ reference operator[](size_type n);
+ const_reference operator[](size_type n) const;
+ const_reference at(size_type n) const;
+ reference at(size_type n);
+ reference front();
+ const_reference front() const;
+ reference back();
+ const_reference back() const;
+
+ // modifiers:
+ void push_back(const bool& x);
+ void pop_back();
+ iterator insert(iterator position, const bool& x);
+ void insert (iterator position, size_type n, const bool& x);
+ template <@\addedConcepts{InputIterator Iter}@>
+ @\addedConcepts{Convertible<Iter::value_type, bool>}@
+ void insert(iterator position, Iter first, Iter last);
+ template <@\addedConcepts{ForwardIterator Iter}@>
+ @\addedConcepts{Convertible<Iter::value_type, bool>}@
+ void insert(iterator position, Iter first, Iter last);
+ iterator erase(iterator position);
+ iterator erase(iterator first, iterator last);
+ void swap(vector<bool,Alloc>&);
+ static void swap(reference x, reference y);
+ void flip(); // flips all bits
+ void clear();
+ };
+
+ // specialized algorithms:
+ template <@\addedConcepts{Allocator Alloc}@>
+ void swap(vector<bool,Alloc>& x, vector<bool,Alloc>& y);
+}
+\end{codeblock}%
+\index{vector<bool>@\tcode{vector<bool>}!\tcode{operator==}}%
+\index{vector<bool>@\tcode{vector<bool>}!\tcode{operator<}}
+
+\pnum
+\tcode{reference}
+is a class that simulates the behavior of references of a single bit in
+\tcode{vector<bool>}.
+
+\pnum
+\addedConcepts{The vector<bool> specialization meets all of the
+ container and sequence requirements except that its iterators do not
+ meet the ForwardIterator requirements.}
+
+\bibliographystyle{plain}
+\bibliography{../local}
+
+\end{document}
\ No newline at end of file

Added: sandbox/committee/concepts/stdlib/clib-intro.tex
==============================================================================
--- (empty file)
+++ sandbox/committee/concepts/stdlib/clib-intro.tex 2008-03-03 15:03:07 EST (Mon, 03 Mar 2008)
@@ -0,0 +1,392 @@
+\documentclass[american,twoside]{book}
+\usepackage{hyperref}
+\usepackage{refbib}
+\input{macros}
+
+%%--------------------------------------------------
+%% Set section numbering limit, toc limit
+\setcounter{secnumdepth}{5}
+\setcounter{tocdepth}{1}
+
+%%--------------------------------------------------
+%% Parameters that govern document appearance
+\setlength{\oddsidemargin}{0pt}
+\setlength{\evensidemargin}{0pt}
+\setlength{\textwidth}{6.6in}
+
+%%--------------------------------------------------
+%% Handle special hyphenation rules
+\hyphenation{tem-plate ex-am-ple in-put-it-er-a-tor}
+
+% Do not put blank pages after chapters that end on odd-numbered pages.
+\def\cleardoublepage{\clearpage\if_at_twoside%
+ \ifodd\c_at_page\else\hbox{}\thispagestyle{empty}\newpage%
+ \if_at_twocolumn\hbox{}\newpage\fi\fi\fi}
+
+\begin{document}
+\raggedbottom
+
+\begin{titlepage}
+\begin{center}
+\huge
+Concepts for the C++0x Standard Library: Introduction
+
+\vspace{0.5in}
+
+\normalsize
+Douglas Gregor, Jeremiah Willcock, and Andrew Lumsdaine \\
+Open Systems Laboratory \\
+Indiana University \\
+Bloomington, IN\ \ 47405 \\
+\{\href{mailto:dgregor_at_[hidden]}{dgregor}, \href{mailto:jewillco_at_[hidden]}{jewillco}, \href{mailto:lums_at_[hidden]}{lums}\}@cs.indiana.edu
+\end{center}
+
+\vspace{1in}
+\par\noindent Document number: N2037=06-0107\vspace{-6pt}
+\par\noindent Date: \today\vspace{-6pt}
+\par\noindent Project: Programming Language \Cpp{}, Library Working Group\vspace{-6pt}
+\par\noindent Reply-to: Douglas Gregor $<$\href{mailto:dgregor_at_[hidden]}{dgregor_at_[hidden]}$>$\vspace{-6pt}
+
+\section*{Introduction}
+\libintrotext{Chapter 17}.
+\end{titlepage}
+
+%%--------------------------------------------------
+%% Headers and footers
+\pagestyle{fancy}
+\fancyhead[LE,RO]{\textbf{\rightmark}}
+\fancyhead[RE]{\textbf{\leftmark\hspace{1em}\thepage}}
+\fancyhead[LO]{\textbf{\thepage\hspace{1em}\leftmark}}
+\fancyfoot[C]{Draft}
+
+\fancypagestyle{plain}{
+\renewcommand{\headrulewidth}{0in}
+\fancyhead[LE,RO]{}
+\fancyhead[RE,LO]{}
+\fancyfoot{}
+}
+
+\renewcommand{\sectionmark}[1]{\markright{\thesection\hspace{1em}#1}}
+\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
+
+\setcounter{chapter}{16}
+\rSec0[lib.library]{Library introduction}
+\rSec1[lib.definitions]{Definitions}
+
+\setcounter{subsection}{18}
+\definition{traits class}{defns.traits}
+
+\removedConcepts{a class that encapsulates a set of types and
+ functions necessary for class templates and function templates to
+ manipulate objects of types for which they are instantiated. Traits
+ classes defined in clauses 21, 22 and 27 are chararacter traits,
+ which provide the character handling support needed by the string
+ and iostream classes.}
+
+\definition{wide-oriented iostream classes}{defns.wide.iostream}
+
+\index{classes!wide-oriented iostream}%
+the instantiations of the iostream class templates
+on the character container class
+\tcode{wchar_t}
+\removedConcepts{and the default value of the
+traits
+parameter}
+(\ref{lib.wide.stream.objects}).
+
+\setcounter{section}{2}
+\rSec1[lib.description]{Method of description (Informative)}
+\rSec2[lib.structure]{Structure of each subclause}
+\setcounter{subsubsection}{1}
+\rSec3[lib.structure.requirements]{Requirements}
+
+\pnum
+\index{requirements}%
+The library can be extended by a \Cpp\ program.
+Each clause, as applicable, describes the requirements that such extensions must meet.
+Such extensions are generally one of the following:
+
+\begin{itemize}
+\item
+Template arguments
+\item
+Derived classes
+\item
+Containers, iterators, and/or algorithms that meet an interface convention
+\end{itemize}
+
+\pnum
+\removedConcepts{The string and iostreams components use an explicit representation of operations required of template arguments.
+They use a
+class template
+char_traits
+to define these constraints.}
+
+\pnum
+\removedConcepts{Interface convention requirements are stated as generally as possible.
+Instead of stating ``class X has to define a member function
+operator++(),''
+the interface requires ``for any object
+x
+of class
+X,
+++x
+is defined.''
+That is, whether the operator is a member is unspecified.}
+
+\pnum
+Requirements are stated in terms of \changedConcepts{well-defined
+expressions}{concepts}, which define \changedConcepts{valid terms}{capabilities} of the types that satisfy the requirements.
+For every set of requirements there is a \changedConcepts{table}{concept} that specifies \changedConcepts{an initial set of the valid expressions}{the requirements} and their semantics
+(\ref{lib.allocator.requirements}, \ref{lib.container.requirements}, \ref{lib.iterator.requirements}).
+Any generic algorithm (clause \ref{lib.algorithms}) that uses the \changedConcepts{requirements}{concepts} \changedConcepts{is described in terms of the valid expressions for}{places requirements on} its
+formal type parameters.
+
+\pnum
+\removedConcepts{Template argument requirements are sometimes referenced by name.
+See 17.3.2.1}.
+
+\pnum
+In some cases the semantic requirements are presented as \Cpp\ code.
+Such code is intended as a
+specification of equivalence of a construct to another construct, not necessarily as the way the construct
+must be implemented.%
+\footnote{
+Although in some cases the code given is unambiguously the optimum implementation.
+}
+
+\rSec2[lib.conventions]{Other conventions}
+\rSec3[lib.type.descriptions]{Type descriptions}
+\pnum
+\removedConcepts{
+The Requirements subclauses may describe names that are used to specify
+constraints on template arguments.}%
+\footnote{
+\removedConcepts{
+Examples from 20.1 include:
+EqualityComparable,
+LessThanComparable,
+CopyConstructable,
+etc.
+Examples from 24.1 include:
+InputIterator,
+ForwardIterator,
+Function,
+Predicate,
+etc.}
+}
+\removedConcepts{These names are used in clauses 20, 23, 25, and 26
+to describe the types that
+may be supplied as arguments by a C++ program when instantiating template components from
+the library.}
+
+\pnum
+Certain types defined in clause \ref{lib.input.output} are used to describe implementation-defined types.
+\index{types!implementation-defined}%
+They are based on other types, but with added constraints.
+
+\rSec1[lib.requirements]{Library-wide requirements}
+\rSec2[lib.organization]{Library contents and organization}
+\rSec3[lib.contents]{Library contents}
+\pnum
+The \Cpp\ Standard Library provides definitions for the following types of entities:
+Macros, Values, Types, \addedConcepts{Concepts, Concept maps, }Templates, Classes,
+Functions, Objects.
+
+\pnum
+All library entities except macros,
+\tcode{operator new}
+and
+\tcode{operator delete}
+are defined within the namespace
+\tcode{std}\
+or namespaces nested within namespace
+\tcode{std}.%
+\index{namespace}\
+
+\pnum
+Whenever a name \tcode{x}\ defined in the standard library is mentioned,
+the name \tcode{x}\ is assumed to be fully qualified as
+\tcode{::std::x},
+unless explicitly described otherwise. For example, if the Effects section
+for library function \tcode{F}\ is described as calling library function \tcode{G},
+the function
+\tcode{::std::G}\
+is meant.
+
+\rSec3[lib.headers]{Headers}
+
+% 17.3.1.2 Headers [lib.headers]
+% CD2 comment UK 682
+% Steve Rumsby
+\pnum
+The elements of the \Cpp\ Standard Library are declared or defined (as appropriate) in a
+\techterm{header}.%
+\footnote{
+A header is not necessarily a source file, nor are the sequences delimited by
+\tcode{<}
+and
+\tcode{>}
+in header names necessarily valid source file names (\ref{cpp.include}).
+}
+
+% 17.3.1.2 Headers [lib.headers]
+% CD2 comment UK 682
+% Steve Rumsby
+\pnum
+The \Cpp\ Standard Library provides
+\changedConcepts{33}{34}
+\techterm{\Cpp\ headers},
+\index{headers!\Cpp\ }%
+as shown in Table~\ref{tab:cpp.library.headers}.
+
+\setcounter{table}{10}
+\begin{floattable}{\Cpp\ Library Headers}{tab:cpp.library.headers}
+{lllll}
+\topline
+\tcode{<algorithm>} & \tcode{<functional>} & \tcode{<limits>} & \tcode{<ostream>} & \tcode{<streambuf>} \\
+\tcode{<bitset>} & \tcode{<iomanip>} & \tcode{<list>} & \tcode{<queue>} & \tcode{<string>} \\
+\tcode{<complex>} & \tcode{<ios>} & \tcode{<locale>} & \tcode{<set>} & \tcode{<typeinfo>} \\
+\tcode{\textcolor{addclr}{<concepts>}} & \tcode{<iosfwd>} & \tcode{<map>} & \tcode{<sstream>} & \tcode{<utility>} \\
+\tcode{<deque>} & \tcode{<iostream>} & \tcode{<memory>} & \tcode{<stack>} & \tcode{<valarray>} \\
+\tcode{<exception>} & \tcode{<istream>} & \tcode{<new>} & \tcode{<stdexcept>} & \tcode{<vector>} \\
+\tcode{<fstream>} & \tcode{<iterator>} & \tcode{<numeric>} & \tcode{<strstream>} & \\
+\end{floattable}
+
+\pnum
+The facilities of the Standard C Library are provided in 18
+\index{library!Standard C}%
+additional headers, as shown in Table~\ref{tab:cpp.c.headers}.
+
+\begin{floattable}{\Cpp\ Headers for C Library Facilities}{tab:cpp.c.headers}
+{lllll}
+\topline
+\tcode{<cassert>} & \tcode{<ciso646>} & \tcode{<csetjmp>} & \tcode{<cstdio>} & \tcode{<ctime>} \\
+\tcode{<cctype>} & \tcode{<climits>} & \tcode{<csignal>} & \tcode{<cstdlib>} & \tcode{<cwchar>} \\
+\tcode{<cerrno>} & \tcode{<clocale>} & \tcode{<cstdarg>} & \tcode{<cstring>} & \tcode{<cwctype>} \\
+\tcode{<cfloat>} & \tcode{<cmath>} & \tcode{<cstddef>} & & \\
+\end{floattable}
+
+\pnum
+Except as noted in clauses~\ref{lib.language.support}\ through \ref{lib.input.output}\
+and Annex~\ref{depr}\, the contents of each header
+\tcode{c\textit{name}}
+shall be the same as that of the corresponding header
+\tcode{\textit{name}.h},
+as specified in ISO/IEC 9899:1990 Programming Languages C (clause 7),
+or ISO/IEC:1990 Programming Languages --- C AMENDMENT 1: C Integrity,
+(clause 7), as appropriate, as if by inclusion.
+In the \Cpp\ Standard
+% 17.3.1.2 Headers [lib.headers]
+% CD2 comment UK 682
+% Steve Rumsby
+Library, however, the declarations and definitions (except for
+names which are defined as macros in C) are within namespace scope
+(\ref{basic.scope.namespace}) of the namespace
+\tcode{std.}
+
+\pnum
+Names which are defined as macros in C shall be defined as macros in
+% 17.3.1.2 Headers [lib.headers]
+% CD2 comment UK 682
+% Steve Rumsby
+the \Cpp\ Standard Library, even if C grants license for
+implementation as functions.
+\enternote\
+the names defined as macros
+in C include the following:
+\tcode{assert},
+\tcode{offsetof},
+\tcode{setjmp},
+\tcode{va_arg},
+\tcode{va_end},
+and
+\tcode{va_start}.
+\exitnote\
+
+\pnum
+Names that are defined as functions in C shall be defined as
+% 17.3.1.2 Headers [lib.headers]
+% CD2 comment UK 682
+% Steve Rumsby
+functions in the \Cpp\ Standard Library.%
+\footnote{
+This disallows the practice, allowed in C, of providing a
+"masking macro" in addition to the function prototype.
+The only
+way to achieve equivalent "inline" behavior in \Cpp\ is to provide
+a definition as an extern inline function.
+}
+
+\pnum
+\addedA{Identifiers that are keywords or operators in \mbox{\Cpp} shall not be defined
+as macros in \mbox{\Cpp} standard library headers.}%
+\footnote{\addedA{In particular, including the standard header \mbox{\tcode{<iso646.h>}}
+or \mbox{\tcode{<ciso646>}} has no effect.}}
+
+\pnum
+\ref{depr.c.headers}, Standard C library headers, describes the effects of using the
+\tcode{\textit{name}.h}
+(C header) form in a \Cpp\ program.%
+\footnote{
+The \tcode{".h"}\ headers dump all their names into the global namespace,
+whereas the newer forms keep their names in namespace
+\tcode{std}.
+Therefore, the newer forms are the preferred forms for all uses except
+for \Cpp\ programs which are intended to be strictly compatible with C.
+}
+
+\setcounter{subsubsection}{2}
+\rSec3[lib.reserved.names]{Reserved names}
+
+\pnum
+It is undefined for a \Cpp\ program to add declarations or definitions to namespace
+\tcode{std}
+or namespaces within namespace
+\tcode{std}
+unless otherwise specified.
+A program may add template specializations for any standard library template
+to namespace
+\tcode{std}.
+\addedConcepts{A program may add concept maps for any standard library
+ concept to namespace std, unless explicitly prohibited.}
+Such a specialization \addedConcepts{or concept map} (complete or partial) of a standard library
+template results in undefined behavior unless the declaration
+depends on a user-defined type of external linkage
+and unless the specialization meets the standard library requirements
+for the original template.%
+\footnote{
+Any library code that instantiates other library templates
+must be prepared to work adequately with any user-supplied specialization
+that meets the minimum requirements of the Standard.
+}
+A program may explicitly instantiate any templates in the standard library
+only if the declaration depends on the name of a user-defined type of external
+linkage and the instantiation meets the standard library requirements for the
+original template.
+
+% 17.3.3.1 Reserved names [lib.reserved.names]
+% CD2 comment UK 682
+% Steve Rumsby
+\pnum
+The \Cpp\ Standard Library reserves the following kinds of names:
+\begin{itemize}
+\item
+Macros
+\item
+Global names
+\item
+Names with external linkage
+\end{itemize}
+
+\pnum
+If the program declares or defines a name in a context where it is
+reserved, other than as explicitly allowed by this clause, the behavior is
+undefined.
+\index{undefined}%
+
+\color{black}
+\bibliographystyle{plain}
+\bibliography{../local}
+
+\end{document}
\ No newline at end of file

Added: sandbox/committee/concepts/stdlib/clib-iterators.tex
==============================================================================
--- (empty file)
+++ sandbox/committee/concepts/stdlib/clib-iterators.tex 2008-03-03 15:03:07 EST (Mon, 03 Mar 2008)
@@ -0,0 +1,1276 @@
+\documentclass[american,twoside]{book}
+\usepackage{hyperref}
+\usepackage{refbib}
+\usepackage{pdfsync}
+\input{macros}
+
+%%--------------------------------------------------
+%% Set section numbering limit, toc limit
+\setcounter{secnumdepth}{5}
+\setcounter{tocdepth}{1}
+
+%%--------------------------------------------------
+%% Parameters that govern document appearance
+\setlength{\oddsidemargin}{0pt}
+\setlength{\evensidemargin}{0pt}
+\setlength{\textwidth}{6.6in}
+
+%%--------------------------------------------------
+%% Handle special hyphenation rules
+\hyphenation{tem-plate ex-am-ple in-put-it-er-a-tor}
+
+% Do not put blank pages after chapters that end on odd-numbered pages.
+\def\cleardoublepage{\clearpage\if_at_twoside%
+ \ifodd\c_at_page\else\hbox{}\thispagestyle{empty}\newpage%
+ \if_at_twocolumn\hbox{}\newpage\fi\fi\fi}
+
+\begin{document}
+\raggedbottom
+
+\begin{titlepage}
+\begin{center}
+\huge
+Iterator Concepts for the C++0x Standard Library
+
+\vspace{0.5in}
+
+\normalsize
+Douglas Gregor, Jeremy Siek and Andrew Lumsdaine \\
+\href{mailto:dgregor_at_[hidden]}{dgregor_at_[hidden]}, \href{mailto:jeremy.siek_at_[hidden]}{jeremy.siek_at_[hidden]}, \href{mailto:lums_at_[hidden]}{lums_at_[hidden]}
+\end{center}
+
+\vspace{1in}
+\par\noindent Document number: N2500=08-0010 \vspace{-6pt}
+\par\noindent Revises document number: N2323=07-0183 \vspace{-6pt}
+\par\noindent Date: \today\vspace{-6pt}
+\par\noindent Project: Programming Language \Cpp{}, Library Working Group\vspace{-6pt}
+\par\noindent Reply-to: Douglas Gregor $<$\href{mailto:dgregor_at_[hidden]}{dgregor_at_[hidden]}$>$\vspace{-6pt}
+
+\section*{Introduction}
+This document proposes new iterator concepts in the \Cpp0x Standard
+Library. It describes a new header \tcode{<iterator_concepts>} that
+contains these concepts, along with concept maps and
+\tcode{iterator_traits} specializations that provide backward
+compatibility for existing iterators and generic algorithms.
+
+This proposal adds new functionality into the Standard Library for
+concepts. More thorough changes to the Standard Library will follow in
+future revisions of the ``Concepts for the \Cpp0x Standard Library''
+proposals.
+
+The concepts in this proposal replace the requirements tables
+currently in [iterator.requirements]. This leaves the Standard Library
+in an interesting (but consistent!) state, where the template
+requirements of the Standard Library are described in terms of actual
+concepts, but the templates themselves are not constrained
+templates. For example, a type \tcode{Iter} in a Standard Library
+algorithm might be stated to be an \tcode{InputIterator} in the
+current text: previously, that text referred (implicitly or otherwise)
+to a requirements table for \tcode{InputIterator}, whereas now it
+refers to the \tcode{InputIterator} concept itself. When the Standard
+Library is fully evolved to use concepts, this informally-stated
+requirement will be made formal by a \tcode{requires} claus. Thus, the
+approach of this proposal is designed to provide an evolutionary step
+toward complete concepts support in the library, while improving the
+description of the library and support for concepts with each step.
+
+Within the proposed wording, text that has been added
+\textcolor{addclr}{will be presented in blue} \addedConcepts{and
+underlined when possible}. Text that has been removed will be
+presented \textcolor{remclr}{in red},\removedConcepts{with
+strike-through when possible}. Non-editorial
+changes from the previous wording are \addedCC{highlighted in green}.
+
+\editorial{Purely editorial comments will be written in a separate,
+ shaded box.}
+\end{titlepage}
+
+%% --------------------------------------------------
+%% Headers and footers
+\pagestyle{fancy}
+\fancyhead[LE,RO]{\textbf{\rightmark}}
+\fancyhead[RE]{\textbf{\leftmark\hspace{1em}\thepage}}
+\fancyhead[LO]{\textbf{\thepage\hspace{1em}\leftmark}}
+\fancyfoot[C]{Draft}
+
+\fancypagestyle{plain}{
+\renewcommand{\headrulewidth}{0in}
+\fancyhead[LE,RO]{}
+\fancyhead[RE,LO]{}
+\fancyfoot{}
+}
+
+\renewcommand{\sectionmark}[1]{\markright{\thesection\hspace{1em}#1}}
+\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
+
+\setcounter{chapter}{23}
+\rSec0[iterators]{Iterators library}
+
+\begin{paras}
+
+\setcounter{Paras}{1}
+
+\textcolor{black}{\pnum}
+The following subclauses describe
+iterator \changedConcepts{requirements}{concepts}, and
+components for
+iterator primitives,
+predefined iterators,
+and stream iterators,
+as summarized in Table~\ref{tab:iterators.lib.summary}.
+
+\begin{libsumtab}{Iterators library summary}{tab:iterators.lib.summary}
+\ref{iterator.concepts} \changedConcepts{Requirements}{Concepts} & \addedConcepts{\tt <iterator_concepts>} \\ \rowsep
+\ref{depr.lib.iterator.primitives} Iterator primitives & \tcode{<iterator>} \\
+\ref{predef.iterators} Predefined iterators & \\
+\ref{stream.iterators} Stream iterators & \\
+\end{libsumtab}
+
+\editorial{The following section has been renamed from ``Iterator requirements'' to ``Iterator concepts''.}
+\rSec1[iterator.concepts]{Iterator concepts}
+
+\pnum
+\addedConcepts{The \mbox{\tcode{<iterator_concepts>}} header describes requirements on iterators.}
+
+\color{addclr}
+\synopsis{Header \tcode{<iterator_concepts>}\ synopsis}
+\begin{codeblock}
+namespace std {
+ concept IteratorBase<typename X> @\textit{see below}@;
+
+ // \ref{input.iterators}, input iterators:
+ concept InputIterator<typename X> @\textit{see below}@;
+
+ // \ref{output.iterators}, output iterators:
+ concept OutputIterator<typename X, typename Value> @\textit{see below}@;
+ concept BasicOutputIterator<typename X> @\textit{see below}@;
+
+ template<BasicOutputIterator X, typename Value>
+ requires CopyAssignable<X::reference, Value>
+ concept_map OutputIterator<X, Value> @\textit{see below}@;
+
+ // \ref{forward.iterators}, forward iterators:
+ concept ForwardIterator<typename X> @\textit{see below}@;
+ concept MutableForwardIterator<typename X> @\textit{see below}@;
+
+ @\textcolor{addclr}{}@// \ref{bidirectional.iterators}, bidirectional iterators:
+ concept BidirectionalIterator<typename X> @\textit{see below}@;
+ concept MutableBidirectionalIterator<typename X> @\textit{see below}@;
+
+ // \ref{random.access.iterators}, random access iterators:
+ concept RandomAccessIterator<typename X> @\textit{see below}@;
+ concept MutableRandomAccessIterator<typename X> @\textit{see below}@;
+ template<ObjectType T> concept_map MutableRandomAccessIterator<T*> @\textit{see below}@;
+ template<ObjectType T> concept_map RandomAccessIterator<const T*> @\textit{see below}@;
+
+ // \ref{swappable.iterators}, swappable iterators:
+ concept SwappableIterator<typename X> @\textit{see below}@;
+}
+\end{codeblock}
+\color{black}
+
+\pnum
+\index{requirements!iterator}%
+Iterators are a generalization of pointers that allow a \Cpp\ program to work with different data structures
+(containers) in a uniform manner.
+To be able to construct template algorithms that work correctly and
+efficiently on different types of data structures, the library formalizes not just the interfaces but also the
+semantics and complexity assumptions of iterators.
+All input iterators
+\tcode{i}\
+support the expression
+\tcode{*i},
+resulting in a value of some class, enumeration, or built-in type
+\tcode{T},
+called the
+\techterm{value type}\
+of the iterator.
+All output iterators support the expression
+\tcode{*i = o}\
+where
+\tcode{o}\
+is a value of some type that is in the set of types that are
+\techterm{writable}\
+to the particular iterator type of
+\tcode{i}.
+All iterators
+\tcode{i}\
+for which the expression
+\tcode{(*i).m}\
+is well-defined, support the expression
+\tcode{i->m}\
+with the same semantics as
+\tcode{(*i).m}.
+For every iterator type
+\tcode{X}\
+for which
+equality is defined, there is a corresponding signed integral type called the
+\techterm{difference type}\
+of the iterator.
+
+\color{addclr}
+\begin{itemdecl}
+concept IteratorBase<typename X> {
+ typename value_type = typename X::value_type;
+ MoveConstructible reference = typename X::reference;
+ MoveConstructible pointer = typename X::pointer;
+}
+\end{itemdecl}
+\color{black}
+
+\pnum
+Since iterators are an abstraction of pointers, their semantics is
+a generalization of most of the semantics of pointers in \Cpp.
+This ensures that every
+function template
+that takes iterators
+works as well with regular pointers.
+This International Standard defines
+\changedConcepts{five categories of iterators}{nine iterator concepts}, according to the operations
+defined on them:
+\techterm{input iterators},
+\techterm{output iterators},
+\techterm{forward iterators}, \addedConcepts{mutable forward iterators},
+\techterm{bidirectional iterators}, \addedConcepts{mutable bidirectional iterators},
+\techterm{random access iterators}, \removedConcepts{and}
+\addedConcepts{mutable random access iterators},
+\addedConcepts{and swappable iterators,}
+as shown in Table~\ref{tab:iterators.relations}.
+
+\begin{floattable}{Relations among iterator \changedConcepts{categories}{concepts}}{tab:iterators.relations}
+{cccc}
+\topline
+\textbf{Random Access} & $\rightarrow$ \textbf{Bidirectional} &
+$\rightarrow$ \textbf{Forward} & $\rightarrow$ \textbf{Input} \\
+$\uparrow$ & $\uparrow$ & $\uparrow$ & \\
+\addedConcepts{\bf Mutable Random Access} & $\rightarrow$ \addedConcepts{\bf Mutable Bidirectional} & $\rightarrow$ \addedConcepts{\bf Mutable Forward} & $\rightarrow$ \textbf{Output} \\
+\end{floattable}
+
+\pnum
+Forward iterators satisfy all the requirements of the input
+\removedConcepts{and output} iterators and can be used whenever
+\changedConcepts{either kind}{an input iterator} is specified.
+\addedConcepts{Mutable forward iterators satisfy all the requirements
+ of forward and output iterators, an can be used whenever either kind
+is specified}.
+Bidirectional iterators also satisfy all the requirements of the
+forward iterators and can be used whenever a forward iterator is specified.
+Random access iterators also satisfy all the requirements of bidirectional
+iterators and can be used whenever a bidirectional iterator is specified.
+
+\pnum
+\changedConcepts{
+Besides its category, a forward, bidirectional, or random access iterator
+can also be
+mutable
+or
+constant
+depending on
+whether the result of the expression
+*i
+behaves as a reference or as a reference to a constant.
+Constant iterators do not satisfy the requirements for output iterators,
+and the result of the expression
+*i
+(for constant iterator
+i)
+cannot be used in an expression where an lvalue is required.}{
+The mutable variants of the forward, bidirectional, and random access
+iterator concepts satisfy the requirements for output iterators, and
+can be used wherever an output iterator is required. Non-mutable
+iterators are referred to as constant iterators.}
+
+\pnum
+Just as a regular pointer to an array guarantees that there is a pointer value pointing past the last element
+of the array, so for any iterator type there is an iterator value that points past the last element of a
+corresponding container.
+These values are called
+\techterm{past-the-end}\
+values.
+Values of an iterator
+\tcode{i}\
+for which the expression
+\tcode{*i}\
+is defined are called
+\techterm{dereferenceable}.
+The library never assumes that past-the-end values are dereferenceable.
+Iterators can also have singular values that are not associated with any
+container.
+\enterexample\
+After the declaration of an uninitialized pointer
+\tcode{x}\
+(as with
+\tcode{int* x;}),
+\tcode{x}\
+must always be assumed to have a singular value of a pointer.
+\exitexample\
+Results of most expressions are undefined for singular values;
+the only exceptions are destroying an iterator that holds a singular value
+and the assignment of a non-singular value to
+an iterator that holds a singular value.
+In this case the singular
+value is overwritten the same way as any other value.
+Dereferenceable
+values are always non-singular.
+
+\pnum
+An iterator
+\tcode{j}\
+is called
+\techterm{reachable}\
+from an iterator
+\tcode{i}\
+if and only if there is a finite sequence of applications of
+the expression
+\tcode{++i}\
+that makes
+\tcode{i == j}.
+If
+\tcode{j}\
+is reachable from
+\tcode{i},
+they refer to the same container.
+
+\pnum
+Most of the library's algorithmic templates that operate on data structures have interfaces that use ranges.
+A
+\techterm{range}\
+is a pair of iterators that designate the beginning and end of the computation.
+A range \range{i}{i}\
+is an empty range;
+in general, a range \range{i}{j}\
+refers to the elements in the data structure starting with the one
+pointed to by
+\tcode{i}\
+and up to but not including the one pointed to by
+\tcode{j}.
+Range \range{i}{j}\
+is valid if and only if
+\tcode{j}\
+is reachable from
+\tcode{i}.
+The result of the application of functions in the library to invalid ranges is
+undefined.
+
+\pnum
+All the \changedConcepts{categories of iterators}{iterator concepts} require only those functions that are realizable \removedConcepts{for a given category} in
+constant time (amortized).
+\removedConcepts{Therefore, requirement tables for the iterators do not have a complexity column.}
+
+\pnum
+Destruction of an iterator may invalidate pointers and references
+previously obtained from that iterator.
+
+\pnum
+An
+\techterm{invalid}\
+iterator is an iterator that may be singular.%
+\footnote{This definition applies to pointers, since pointers are iterators.
+The effect of dereferencing an iterator that has been invalidated
+is undefined.
+}
+
+\pnum
+\removedConcepts{
+In the following sections,
+a
+and
+b
+denote values of type
+const X,
+n
+denotes a value of the difference type
+Distance,
+u,
+tmp,
+and
+m
+denote identifiers,
+r
+denotes a value of
+X\&,
+t
+denotes a value of value type
+T,
+o
+denotes a value of some type that is writable to the output iterator.}
+
+\rSec2[input.iterators]{Input iterators}
+
+\pnum
+A class or a built-in type
+\tcode{X}\
+satisfies the requirements of an input iterator for the value type
+\tcode{T}\
+if \changedConcepts{the following expressions are valid,
+where
+U
+is the type of any specified member of type
+T,
+as shown in Table~95.}{it meets the syntactic and semantic
+requirements of the }\addedConcepts{\tt InputIterator}\addedConcepts{ concept.}
+
+\color{addclr}
+\begin{codeblock}
+concept InputIterator<typename X> : IteratorBase<X>, Semiregular<X>, EqualityComparable<X> {
+ SignedIntegral@\addedCC{Like}@ difference_type = typename X::difference_type;
+
+ requires @\addedCC{IntegerType<difference_type>}@
+ && Convertible<reference, value_type>;
+ @\textcolor{addclr}{}@&& Convertible<pointer, const value_type*>;
+
+ MoveConstructible postincrement_result;
+ requires Dereferenceable<postincrement_result> &&
+ Convertible<Dereferenceable<postincrement_result>::reference, value_type>;
+
+ reference operator*(X @\addedCC{const\&}@);
+ pointer operator->(X @\addedCC{const\&}@);
+ X& operator++(X&);
+ postincrement_result operator++(X&, int);
+}
+\end{codeblock}
+\color{black}
+
+\pnum
+\changedConcepts{In Table~95}{In the }\addedConcepts{\tt
+ InputIterator}\addedConcepts{ concept}, the term
+\techterm{the domain of \tcode{==}}\
+is used in the ordinary mathematical sense to denote
+the set of values over which
+\tcode{==}\ is (required to be) defined.
+This set can change over time.
+Each algorithm places additional requirements on the domain of
+\tcode{==}\ for the iterator values it uses.
+These requirements can be inferred from the uses that algorithm
+makes of \tcode{==}\ and \tcode{!=}.
+\enterexample
+the call \tcode{find(a,b,x)}\
+is defined only if the value of \tcode{a}\
+has the property \textit{p}\
+defined as follows:
+\tcode{b}\ has property \textit{p}\
+and a value \tcode{i}\
+has property \textit{p}\
+if
+\tcode{(*i==x)}\
+or if
+\tcode{(*i!=x}\
+and
+\tcode{++i}\
+has property
+\tcode{p}).
+\exitexample\
+
+\eremove{Remove Table 96: Input iterator requirements}
+
+\pnum
+\enternote\
+For input iterators,
+\tcode{a == b}\
+does not imply
+\tcode{++a == ++b}.
+(Equality does not guarantee the substitution property or referential transparency.)
+Algorithms on input iterators should never attempt to pass through the same iterator twice.
+They should be
+\techterm{single pass}\
+algorithms.
+\removedConcepts{Value type T is not required to be an Assignable type (23.1).}\
+These algorithms can be used with istreams as the source of the input data through the
+\tcode{istream_iterator}\
+class.
+\exitnote\
+
+\color{addclr}
+\begin{itemdecl}
+reference operator*(X @\addedCC{const\&}@ @\farg{a}@);
+\end{itemdecl}
+
+\pnum
+\requires\
+\tcode{\farg{a}}\
+is dereferenceable.
+
+\pnum
+\returns\
+the value referenced by the iterator
+
+\pnum
+\notes\
+If \tcode{b} is a value of type \tcode{X}, \tcode{a == b} and
+\tcode{(a, b)} is in the domain of \tcode{==}
+then \tcode{*a} is equivalent to \tcode{*b}.
+
+\begin{itemdecl}
+pointer operator->(X @\addedCC{const\&}@ a);
+\end{itemdecl}
+
+\pnum
+\returns\
+ a pointer to the value referenced by
+ the iterator
+
+\pnum
+If two iterators \tcode{a}\ and \tcode{b}\ of the same type are equal, then either \tcode{a}\ and \tcode{b}\
+are both dereferenceable
+or else neither is dereferenceable.
+
+\pnum
+If two iterators \tcode{a}\ and \tcode{b}\ of the same type are both dereferenceable, then \tcode{a == b}\
+if and only if
+\tcode{*a}\ and \tcode{*b}\ are the same object.
+
+\begin{itemdecl}
+X& operator++(X& r);
+\end{itemdecl}
+
+\pnum
+\precondition\
+\tcode{r} is dereferenceable
+
+\pnum
+\postcondition\
+\tcode{r} is dereferenceable or \tcode{r} is past-the-end. any copies
+of the previous value of \tcode{r} are no longer required either to be
+dereferenceable or in the domain of \tcode{==}.
+
+\begin{itemdecl}
+postincrement_result operator++(X&, int);
+\end{itemdecl}
+
+\pnum
+\effects\
+\tcode{++r}
+
+\end{paras}
+
+\rSec2[output.iterators]{Output iterators}
+
+\pnum
+A class or a built-in type
+\tcode{X}\
+satisfies the requirements of an output iterator
+if
+\changedConcepts{X
+is a CopyConstructible (20.1.3)
+and Assignable type (23.1) and also
+the following expressions are
+valid, as shown in Table~96}{meets the syntactic and semantic requirements of the \mbox{\tcode{OutputIterator}} or \mbox{\tcode{BasicOutputIterator}} concepts.}
+
+\eremove{Remove Table 97: Output iterator requirements}
+
+\pnum
+\enternote\
+The only valid use of an
+\tcode{operator*}\
+is on the left side of the assignment statement.
+\textit{Assignment through the same value of the iterator happens only once.}\
+Algorithms on output iterators should never attempt to pass through the same iterator twice.
+They should be
+\techterm{single pass}\
+algorithms.
+Equality and inequality might not be defined.
+Algorithms that take output iterators can be used with ostreams as the destination
+for placing data through the
+\tcode{ostream_iterator}\
+class as well as with insert iterators and insert pointers.
+\exitnote\
+
+\pnum
+The \tcode{OutputIterator} concept describes an output iterator that
+may permit output of many different value types.
+
+\color{addclr}
+\begin{itemdecl}
+concept OutputIterator<typename X, typename Value> : CopyConstructible<X> {
+ typename reference;
+ requires CopyAssignable<reference, Value>;
+
+ typename postincrement_result;
+ requires Dereferenceable<postincrement_result&> &&
+ Convertible<postincrement_result, const X&> &&
+ CopyAssignable<Dereferenceable<postincrement_result&>::reference, Value>;
+
+ reference operator*(X&);
+ X& operator++(X&);
+ postincrement_result operator++(X&, int);
+}
+\end{itemdecl}
+\color{black}
+
+\color{addclr}
+\begin{itemdecl}
+X& operator++(X& r);
+\end{itemdecl}
+
+\pnum
+\postcondition\
+\tcode{\&\farg{r} == \&++\farg{r}}
+
+\begin{itemdecl}
+postincrement_result operator++(X& r, int);
+\end{itemdecl}
+
+\pnum
+\effects\
+equivalent to
+\begin{codeblock}
+{ X tmp = r;
+++r;
+return tmp; }
+\end{codeblock}
+
+\pnum
+The \tcode{BasicOutputIterator} concept describes an output iterator
+that has one, fixed value type. Unlike \tcode{OutputIterator},
+\tcode{BasicOutputIterator} is a part of the iterator refinement
+hierarchy.
+
+\color{addclr}
+\begin{itemdecl}
+concept BasicOutputIterator<typename X> : IteratorBase<X>, CopyConstructible<X> {
+ requires CopyAssignable<reference, value_type>;
+
+ typename postincrement_result;
+ requires Dereferenceable<postincrement_result&>,
+ CopyAssignable<Dereferenceable<postincrement_result&>::reference, value_type>,
+ Convertible<postincrement_result, const X&>;
+
+ reference operator*(X&);
+ X& operator++(X&);
+ postincrement_result operator++(X&, int);
+}
+\end{itemdecl}
+\color{black}
+
+\color{addclr}
+\begin{itemdecl}
+X& operator++(X& r);
+\end{itemdecl}
+
+\pnum
+\postcondition\
+\tcode{\&\farg{r} == \&++\farg{r}}
+
+\begin{itemdecl}
+postincrement_result operator++(X& r, int);
+\end{itemdecl}
+
+\pnum
+\effects\
+equivalent to
+\begin{codeblock}
+{ X tmp = r;
+++r;
+return tmp; }
+\end{codeblock}
+
+\pnum
+Every \tcode{BasicOutputIterator} is an \tcode{OutputIterator} for
+value types \tcode{CopyAssignable} to its
+\tcode{reference} type. \footnote{This allows algorithms specified with
+ \tcode{OutputIterator} (the less restrictive concept) to work with
+ iterators that have concept maps for the more common
+ \tcode{BasicOutputIterator} concept.}
+\color{black}
+
+\color{addclr}
+\begin{itemdecl}
+template<BasicOutputIterator X, typename Value>
+requires CopyAssignable<X::reference, Value>
+concept_map OutputIterator<X, Value> {
+ typedef X::reference reference;
+ typedef X::postincrement_result postincrement_result;
+}
+\end{itemdecl}
+\color{black}
+
+\rSec2[forward.iterators]{Forward iterators}
+
+\pnum
+A class or a built-in type
+\tcode{X}\
+satisfies the requirements of a forward iterator if
+\changedConcepts{the following expressions are
+valid, as shown in Table~97.}{it meets the syntactic and semantic
+requirements of the ForwardIterator or
+MutableForwardIterator concepts.}
+
+\eremove{Remove Table 98: Forward iterator requirements.}
+
+\color{addclr}
+\begin{itemdecl}
+concept ForwardIterator<typename X> : InputIterator<X>, Regular<X> {
+ requires Convertible<postincrement_result, const X&>;
+}
+
+concept MutableForwardIterator<typename X> : ForwardIterator<X>, BasicOutputIterator<X> { }
+\end{itemdecl}
+\color{black}
+
+\editorial{The \tcode{ForwardIterator} concept here provides weaker
+ requirements on the \tcode{reference} and \tcode{pointer} types than
+ the associated requirements table in C++03, because these types do
+ not need do not need to be true references or pointers to
+ \tcode{value_type}. This change weakens the concept, meaning that
+ C++03 iterators (which meet the stronger requirements) still meet
+ these requirements, but algorithms that relied on these stricter
+ requirements will no longer work just with the iterator
+ requirements: they will need to specify true references or pointers
+ as additional requirements. By weakening the requirements, however,
+ we permit proxy iterators to model the forward, bidirectional, and
+ random access iterator concepts.}
+
+\textcolor{black}{}\pnum
+\enternote\
+The condition that
+\tcode{a == b}\
+implies
+\tcode{++a == ++b}\
+(which is not true for input and output iterators)
+and the removal of the restrictions on the number of the assignments through the iterator
+(which applies to output iterators)
+allows the use of multi-pass one-directional algorithms with forward iterators.
+\exitnote\
+
+\rSec2[bidirectional.iterators]{Bidirectional iterators}
+
+\pnum
+A class or a built-in type
+\tcode{X}\
+satisfies the requirements of a bidirectional iterator if
+\changedConcepts{,
+in addition to satisfying the requirements for forward iterators,
+the following expressions are valid as shown in
+Table~98.}{it meets the
+syntactic and semantic requirements of the
+BidirectionalIterator or MutableBidirectionalIterator concept.}
+
+\eremove{Remove Table 99: Bidirectional iterator requirements.}
+
+\color{addclr}
+\begin{itemdecl}
+concept BidirectionalIterator<typename X> : ForwardIterator<X> {
+ MoveConstructible postdecrement_result;
+ requires Dereferenceable<postdecrement_result> &&
+ Convertible<Dereferenceable<postdecrement_result>::reference, value_type> &&
+ Convertible<postdecrement_result, const X&>;
+
+ X& operator--(X&);
+ postdecrement_result operator--(X&, int);
+}
+
+concept MutableBidirectionalIterator<typename X>
+ : BidirectionalIterator<X>, MutableForwardIterator<X> { }
+\end{itemdecl}
+\color{black}
+
+\pnum
+\enternote\
+Bidirectional iterators allow algorithms to move iterators backward as well as forward.
+\exitnote\
+
+\color{addclr}
+\begin{itemdecl}
+X& operator--(X& r);
+\end{itemdecl}
+
+\pnum
+\precondition\
+there exists \tcode{s}\ such that \tcode{r == ++s}.
+
+\pnum
+\postcondition\
+\tcode{r}\ is dereferenceable.
+
+\pnum
+\effects\
+\tcode{\dcr(++r) == r}. \\
+ \tcode{\dcr r == \dcr s}\ implies \tcode{r == s}. \\
+ \tcode{\&r == \&\dcr r}.
+
+\begin{itemdecl}
+postdecrement_result operator--(X& r, int);
+\end{itemdecl}
+
+\pnum
+\effects\
+equivalent to
+\begin{codeblock}
+{ X tmp = r;
+--r;
+return tmp; }
+\end{codeblock}
+\color{black}
+
+\rSec2[random.access.iterators]{Random access iterators}
+
+\pnum
+A class or a built-in type
+\tcode{X}\
+satisfies the requirements of a random access iterator if
+\changedConcepts{,
+in addition to satisfying the requirements for bidirectional iterators,
+the following expressions are valid as shown in Table~99.}
+{it meets the syntactic and semantic requirements of the
+\mbox{\tcode{RandomAccessIterator}} or \mbox{\tcode{MutableRandomAccessIterator}} concept.}
+
+\color{addclr}
+\begin{itemdecl}
+concept RandomAccessIterator<typename X> : BidirectionalIterator<X>, LessThanComparable<X> {
+ X& operator+=(X&, difference_type);
+ X operator+ (X @\addedCC{const\&}@, difference_type);
+ X operator+ (difference_type, X@\addedCC{const\&}@);
+ X& operator-=(X&, difference_type);
+ X operator- (X @\addedCC{const\&}@, difference_type);
+
+ difference_type operator-(X @\addedCC{const\&}@, X @\addedCC{const\&}@);
+ reference operator[](X @\addedCC{const\&}@, difference_type);
+}
+
+concept MutableRandomAccessIterator<typename X>
+ : RandomAccessIterator<X>, MutableBidirectionalIterator<X> { }
+\end{itemdecl}
+\color{black}
+
+\eremove{Remove Table 100: Random access iterator requirements.}
+
+\color{addclr}
+\begin{itemdecl}
+X& operator+=(X&, difference_type);
+\end{itemdecl}
+
+\pnum
+\effects\
+equivalent to
+\begin{codeblock}
+{ difference_type m = n;
+ if (m >= 0) while (m--) ++r;
+ else while (m++) --r;
+ return r; }
+\end{codeblock}
+
+\begin{itemdecl}
+X operator+(X @\addedCC{const\&}@ a, difference_type n);
+X operator+(difference_type n, X @\addedCC{const\&}@ a);
+\end{itemdecl}
+
+\pnum
+\effects\
+equivalent to
+\begin{codeblock}
+{ X tmp = a;
+return tmp += n; }
+\end{codeblock}
+
+\pnum
+\postcondition\
+\tcode{a + n == n + a}
+
+\begin{itemdecl}
+@\textcolor{addclr}{X}@& operator-=(X& r, difference_type n);
+\end{itemdecl}
+
+\pnum
+\returns\
+\tcode{r += -n}
+
+\begin{itemdecl}
+X operator-(X @\addedCC{const\&}@, difference_type);
+\end{itemdecl}
+
+\pnum
+\effects\
+equivalent to
+\begin{codeblock}
+{ X tmp = a;
+ return tmp -= n; }
+\end{codeblock}
+
+\begin{itemdecl}
+difference_type operator-(X @\addedCC{const\&}@ a, X @\addedCC{const\&}@ b);
+\end{itemdecl}
+
+\pnum
+\precondition\
+there exists a value \tcode{n}\ of \tcode{difference_type} such that \tcode{a + n == b}.
+
+\pnum
+\effects\
+\tcode{b == a + (b - a)}
+
+\pnum
+\returns\
+\tcode{(a < b) ? distance(a,b) : -distance(b,a)}
+
+\pnum
+Pointers are mutable random access iterators with the following
+concept map
+
+\begin{codeblock}
+@\textcolor{addclr}{}@namespace std {
+ template<ObjectType T> concept_map MutableRandomAccessIterator<T*> {
+ typedef T value_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef T& reference;
+ typedef T* pointer;
+ }
+}
+\end{codeblock}
+
+and pointers to const are random access iterators
+
+\begin{codeblock}
+namespace std {
+ template<ObjectType T> concept_map RandomAccessIterator<const T*> {
+ typedef T value_type;
+ typedef std::ptrdiff_t difference_type;
+ typedef const T& reference;
+ typedef const T* pointer;
+ }
+}
+\end{codeblock}
+
+\pnum
+\enternote\
+If there is an additional pointer type
+\tcode{\,\xname{far}}\
+such that the difference of two
+\tcode{\,\xname{far}}\
+is of type
+\tcode{long},
+an implementation may define
+
+\color{addclr}
+\begin{codeblock}
+ template <ObjectType T> concept_map MutableRandomAccessIterator<T @\xname{far}@*> {
+ typedef long difference_type;
+ typedef T value_type;
+ typedef T @\xname{far}@* pointer;
+ typedef T @\xname{far}@& reference;
+ }
+
+ template <ObjectType T> concept_map RandomAccessIterator<const T @\xname{far}@*> {
+ typedef long difference_type;
+ typedef T value_type;
+ typedef const T @\xname{far}@* pointer;
+ typedef const T @\xname{far}@& reference;
+ }
+\end{codeblock}
+\textcolor{addclr}{\exitnote}
+\color{black}
+
+\editorial{Add the following new section}
+
+\rSec2[swappable.iterators]{Swappable iterators}
+\pnum
+\addedConcepts{A class or built-in type \mbox{\tcode{X}} satisfies the
+requirements of a swappable iterator if it meets the syntactic and
+semantic requirements of the \mbox{\tcode{SwappableIterator}}
+concept.}
+
+\color{addclr}
+\begin{itemdecl}
+auto concept SwappableIterator<typename X> {
+ void iter_swap(X @\addedCC{const\&}@, X @\addedCC{const\&}@);
+}
+\end{itemdecl}
+
+\begin{itemdecl}
+void iter_swap(X @\addedCC{const\&}@ a, X @\addedCC{const\&}@ b);
+\end{itemdecl}
+\color{black}
+
+\pnum
+\addedConcepts{Swaps the elements referenced by iterators \mbox{\tcode{a}}
+ and \mbox{\tcode{b}}.}
+
+\appendix
+\setcounter{chapter}{3}
+\normannex{depr}{Compatibility features}
+\begin{paras}
+
+\setcounter{section}{9}
+\rSec1[depr.lib.iterator.primitives]{Iterator primitives}
+
+\textcolor{black}{\pnum}
+To simplify the \changedConcepts{task of defining iterators}{use of
+ iterators and provide backward compatibility with previous C++
+ Standard Libraries}, the library provides
+several classes and functions.
+
+\pnum
+\addedConcepts{The \mbox{\tcode{iterator_traits}} and supporting
+ facilities described
+in this section are deprecated. \mbox{\enternote} the iterator
+concepts (\mbox{\ref{iterator.concepts}}) provide the equivalent
+functionality using the concept mechanism. \mbox{\exitnote}}
+
+\end{paras}
+
+\rSec2[iterator.traits]{Iterator traits}
+
+\pnum
+\changedConcepts{
+To implement algorithms only in terms of iterators, it is often necessary to
+determine the value and
+difference types that correspond to a particular iterator type.
+Accordingly, it is required that if}
+{Iterator traits provide an auxiliary mechanism for
+accessing the associated types of an iterator. If}
+\tcode{Iterator}\
+is the type of an iterator,
+the types
+
+\begin{codeblock}
+iterator_traits<Iterator>::difference_type
+iterator_traits<Iterator>::value_type
+iterator_traits<Iterator>::iterator_category
+\end{codeblock}
+
+\addedConcepts{shall} be defined as the iterator's difference type, value type and iterator
+category \addedConcepts{(24.3.3)}, respectively.
+In addition, the types
+
+\begin{codeblock}
+iterator_traits<Iterator>::reference
+iterator_traits<Iterator>::pointer
+\end{codeblock}
+
+shall be defined as the iterator's reference and pointer types, that is, for an
+iterator object \tcode{a}, the same type as the type of \tcode{*a} and \tcode{a->},
+respectively. \removedConcepts{In the case of an output iterator, the types}
+
+\begin{codeblock}
+@\removedConcepts{iterator_traits<Iterator>::difference_type}@
+@\removedConcepts{iterator_traits<Iterator>::value_type}@
+@\removedConcepts{iterator_traits<Iterator>::reference}@
+@\removedConcepts{iterator_traits<Iterator>::pointer}@
+\end{codeblock}
+
+\removedConcepts{may be defined as void.}
+
+\setcounter{Paras}{5}
+\pnum
+\addedConcepts{\mbox{\tcode{iterator_traits}}
+is specialized for any type
+\mbox{\tcode{Iterator}}
+for which there is a concept map for any of the iterator concepts
+(\mbox{\ref{iterator.concepts}}) and \mbox{\tcode{Iterator}} meets the requirements
+stated in the corresponding requirements table of ISO/IEC 14882:2003.
+\mbox{\enternote} these specializations
+ permit forward compatibility of iterators, allowing those iterators
+ that provide only concept maps to be used through
+ \mbox{\tcode{iterator_traits}}. They can be implemented via class template
+ partial specializations such as the following.}
+\color{addclr}
+\begin{codeblock}
+template<InputIterator Iterator> struct iterator_traits<Iterator> {
+ typedef Iterator::difference_type difference_type;
+ typedef Iterator::value_type value_type;
+ typedef Iterator::pointer pointer;
+ typedef Iterator::reference reference;
+ typedef input_iterator_tag iterator_category;
+};
+
+template<BasicOutputIterator Iterator> struct iterator_traits<Iterator> {
+ typedef Iterator::difference_type difference_type;
+ typedef Iterator::value_type value_type;
+ typedef Iterator::pointer pointer;
+ typedef Iterator::reference reference;
+ typedef output_iterator_tag iterator_category;
+};
+\end{codeblock}
+\exitnote\
+\color{black}
+
+\rSec2[iterator.basic]{Basic iterator}
+
+\editorial{We deprecated the basic \tcode{iterator} template because
+ it isn't really the right way to specify iterators any more. Even
+ when using this template, users should write concept maps so that
+ (1) their iterators will work when \tcode{iterator_traits} and the
+ backward-compatibility models go away, and (2) so that their
+ iterators will be checked against the iterator concepts as early as
+ possible.}
+
+\pnum
+The
+\tcode{iterator}
+template may be used as a base class to ease the definition of required types
+for new iterators.
+
+\begin{codeblock}
+namespace std {
+ template<class Category, class T, class Distance = ptrdiff_t,
+ class Pointer = T*, class Reference = T&>
+ struct iterator {
+ typedef T value_type;
+ typedef Distance difference_type;
+ typedef Pointer pointer;
+ typedef Reference reference;
+ typedef Category iterator_category;
+ };
+}
+\end{codeblock}
+
+\rSec2[std.iterator.tags]{Standard iterator tags}
+
+\pnum
+\index{input_iterator_tag@\tcode{input_iterator_tag}}%
+\index{output_iterator_tag@\tcode{output_iterator_tag}}%
+\index{forward_iterator_tag@\tcode{forward_iterator_tag}}%
+\index{bidirectional_iterator_tag@\tcode{bidirectional_iterator_tag}}%
+\index{random_access_iterator_tag@\tcode{random_access_iterator_tag}}%
+\changedConcepts{It is often desirable for a
+function template specialization
+to find out what is the most specific category of its iterator
+argument, so that the function can select the most efficient algorithm at compile time.
+To facilitate this, the}{The}
+library \textcolor{black}{}introduces
+\techterm{category tag}\
+classes which are used as compile time tags
+\changedConcepts{for algorithm selection.}{to distinguish the
+ different iterator concepts when using the \mbox{\tcode{iterator_traits}} mechanism.}
+They are:
+\tcode{input_iterator_tag},
+\tcode{output_iterator_tag},
+\tcode{forward_iterator_tag},
+\tcode{bidirectional_iterator_tag}\
+and
+\tcode{random_access_iterator_tag}.
+For every iterator of type
+\tcode{Iterator},
+\tcode{iterator_traits<Iterator>::it\-er\-a\-tor_ca\-te\-go\-ry}
+shall be defined to be the most specific category tag that describes the
+iterator's behavior.
+
+\begin{codeblock}
+namespace std {
+ struct input_iterator_tag {};
+ struct output_iterator_tag {};
+ @\color{black}@struct forward_iterator_tag: public input_iterator_tag {};
+ struct bidirectional_iterator_tag: public forward_iterator_tag {};
+ struct random_access_iterator_tag: public bidirectional_iterator_tag {};
+}
+\end{codeblock}
+
+\pnum
+\eremove{Remove this paragraph: It gives an example using
+ \tcode{iterator_traits}, which we no longer encourage.}
+
+\color{addclr}
+\rSec2[iterator.backward]{Iterator backward compatibility}
+
+\pnum
+The library provides concept maps that allow iterators specified with
+\tcode{iterator_traits}
+to interoperate with algorithms that require iterator concepts.
+
+\pnum
+The
+associated types
+\tcode{difference_type},
+\tcode{value_type},
+\tcode{pointer}
+and
+\tcode{reference}
+are given the same values as their counterparts in
+\tcode{iterator_traits}.
+
+\pnum
+\color{addclr}
+These concept maps shall only be defined when the
+\tcode{iterator_traits}
+specialization contains the nested types
+\tcode{difference_type},
+\tcode{value_type},
+\tcode{pointer},
+\tcode{reference}
+and
+\tcode{iterator_category}.
+
+\enterexample\
+The following example is well-formed. The backward-compatbility
+concept map for \tcode{InputIterator} does not match because
+\tcode{iterator_traits<int>} fails to provide the required nested
+types.
+\begin{codeblock}
+@\color{addclr}@template<Integral T> void f(T);
+template<InputIterator T> void f(T);
+
+void g(int x) {
+ f(x); // okay
+}
+\end{codeblock}
+\exitexample\
+
+\pnum
+The library shall provide a concept map
+\tcode{InputIterator}
+for any type \tcode{Iterator} with
+\\\tcode{iterator_traits<Iterator>::it\-er\-a\-tor_ca\-te\-go\-ry} convertible to
+\tcode{input_iterator_tag}.
+
+\pnum
+The library shall provide a concept map
+\tcode{OutputIterator}
+for any type \tcode{Iterator} with
+\\\tcode{iterator_traits<Iterator>::it\-er\-a\-tor_ca\-te\-go\-ry} convertible to
+\tcode{output_iterator_tag}. \enternote\ the \tcode{reference} type of
+the \tcode{OutputIterator} must be deduced, because
+\tcode{iterator_traits} specifies that it will be \tcode{void}. \exitnote\
+
+\textcolor{addclr}{\pnum}
+The library shall provide a concept map
+\tcode{ForwardIterator}
+for any type \tcode{Iterator} with
+\\\tcode{iterator_traits<Iterator>::it\-er\-a\-tor_ca\-te\-go\-ry} convertible to
+\tcode{forward_iterator_tag}.
+
+\pnum
+The library shall provide a concept map
+\tcode{MutableForwardIterator}
+for any type \tcode{Iterator} with
+\\\tcode{iterator_traits<Iterator>::it\-er\-a\-tor_ca\-te\-go\-ry} convertible to
+\tcode{forward_iterator_tag} for which the \tcode{reference} type is
+\tcode{CopyAssignable} from the \tcode{value_type}.
+
+\textcolor{addclr}{\pnum}
+The library shall provide a concept map
+\tcode{BidirectionalIterator}
+for any type \tcode{Iterator} with
+\\\tcode{iterator_traits<Iterator>::it\-er\-a\-tor_ca\-te\-go\-ry} convertible to
+\tcode{bidirectional_iterator_tag}.
+
+\pnum
+The library shall provide a concept map
+\tcode{MutableBidirectionalIterator}
+for any type \tcode{Iterator} with
+\\\tcode{iterator_traits<Iterator>::it\-er\-a\-tor_ca\-te\-go\-ry} convertible to
+\tcode{bidirectional_iterator_tag} for which the \tcode{reference}
+type is \tcode{CopyAssignable} from the \tcode{value_type}.
+
+\pnum
+The library shall provide a concept map
+\tcode{RandomAccessIterator}
+for any type \tcode{Iterator} with
+\\\tcode{iterator_traits<Iterator>::it\-er\-a\-tor_ca\-te\-go\-ry} convertible to
+\tcode{random_access_iterator_tag}.
+
+\pnum
+The library shall provide a concept map
+\tcode{MutableRandomAccessIterator}
+for any type \tcode{Iterator} with
+\\\tcode{iterator_traits<Iterator>::it\-er\-a\-tor_ca\-te\-go\-ry} convertible to
+\tcode{random_access_iterator_tag} for which the \tcode{reference} type is
+\tcode{CopyAssignable} from the \tcode{value_type}.
+\color{black}
+
+\section*{Acknowledgments}
+Thanks to Beman Dawes for alerting us to omissions from the iterator
+concepts.
+
+\bibliographystyle{plain}
+\bibliography{../local}
+
+\end{document}
\ No newline at end of file

Added: sandbox/committee/concepts/stdlib/clib-numerics.tex
==============================================================================
--- (empty file)
+++ sandbox/committee/concepts/stdlib/clib-numerics.tex 2008-03-03 15:03:07 EST (Mon, 03 Mar 2008)
@@ -0,0 +1,403 @@
+\documentclass[american,twoside]{book}
+\usepackage{refbib}
+\usepackage{hyperref}
+\input{macros}
+
+%%--------------------------------------------------
+%% Set section numbering limit, toc limit
+\setcounter{secnumdepth}{5}
+\setcounter{tocdepth}{1}
+
+%%--------------------------------------------------
+%% Parameters that govern document appearance
+\setlength{\oddsidemargin}{0pt}
+\setlength{\evensidemargin}{0pt}
+\setlength{\textwidth}{6.6in}
+
+%%--------------------------------------------------
+%% Handle special hyphenation rules
+\hyphenation{tem-plate ex-am-ple in-put-it-er-a-tor}
+
+% Do not put blank pages after chapters that end on odd-numbered pages.
+\def\cleardoublepage{\clearpage\if_at_twoside%
+ \ifodd\c_at_page\else\hbox{}\thispagestyle{empty}\newpage%
+ \if_at_twocolumn\hbox{}\newpage\fi\fi\fi}
+
+\begin{document}
+\raggedbottom
+
+\begin{titlepage}
+\begin{center}
+\huge
+Concepts for the C++0x Standard Library: Numerics
+
+\vspace{0.5in}
+
+\normalsize
+Douglas Gregor, Jeremiah Willcock, and Andrew Lumsdaine \\
+Open Systems Laboratory \\
+Indiana University \\
+Bloomington, IN\ \ 47405 \\
+\{\href{mailto:dgregor_at_[hidden]}{dgregor}, \href{mailto:jewillco_at_[hidden]}{jewillco}, \href{mailto:lums_at_[hidden]}{lums}\}@cs.indiana.edu
+\end{center}
+
+\vspace{1in}
+\par\noindent Document number: N2041=06-0111\vspace{-6pt}
+\par\noindent Date: \today\vspace{-6pt}
+\par\noindent Project: Programming Language \Cpp{}, Library Working Group\vspace{-6pt}
+\par\noindent Reply-to: Douglas Gregor $<$\href{mailto:dgregor_at_[hidden]}{dgregor_at_[hidden]}$>$\vspace{-6pt}
+
+\section*{Introduction}
+\libintrotext{Chapter 26}
+\end{titlepage}
+
+%%--------------------------------------------------
+%% Headers and footers
+\pagestyle{fancy}
+\fancyhead[LE,RO]{\textbf{\rightmark}}
+\fancyhead[RE]{\textbf{\leftmark\hspace{1em}\thepage}}
+\fancyhead[LO]{\textbf{\thepage\hspace{1em}\leftmark}}
+\fancyfoot[C]{Draft}
+
+\fancypagestyle{plain}{
+\renewcommand{\headrulewidth}{0in}
+\fancyhead[LE,RO]{}
+\fancyhead[RE,LO]{}
+\fancyfoot{}
+}
+
+\renewcommand{\sectionmark}[1]{\markright{\thesection\hspace{1em}#1}}
+\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
+
+\color{black}
+
+\setcounter{chapter}{25}
+\rSec0[lib.numerics]{Numerics library}
+\begin{paras}
+
+\setcounter{section}{3}
+\rSec1[lib.numeric.ops]{Generalized numeric operations}
+
+\synopsis{Header \tcode{<numeric>}\ synopsis}
+\index{numeric@\tcode{<numeric>}}%
+
+\color{addclr}
+\begin{codeblock}
+namespace std {
+ template <InputIterator Iter, Addable<Iter::reference> T>
+ where Assignable<T, T::result_type>
+ T accumulate(Iter @\farg{first}@, Iter @\farg{last}@, T @\farg{init}@);
+ template <InputIterator Iter, class T, Callable2<T, Iter::reference> BinaryOperation>
+ where Assignable<T, BinaryOperation::result_type>
+ T accumulate(Iter @\farg{first}@, Iter @\farg{last}@, T @\farg{init}@,
+ BinaryOperation @\farg{binary_op}@);
+ template <InputIterator Iter1, InputIterator Iter2, class T>
+ where Multiplicable<Iter1::reference, Iter2::reference> &&
+ Addable<T, Multiplicable<Iter1::reference, Iter2::reference>::result_type> &&
+ Assignable<
+ T,
+ Addable<T,
+ Multiplicable<Iter1::reference, Iter2::reference>::result_type>::result_type>
+ T inner_product(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, T @\farg{init}@);
+ template <InputIterator Iter1, InputIterator Iter2, class T,
+ class BinaryOperation1, Callable2<Iter1::reference, Iter2::reference> BinaryOperation2>
+ where Callable2<BinaryOperation1, T, BinaryOperation2::result_type> &&
+ Assignable<T,
+ Callable2<BinaryOperation1, T, BinaryOperation2::result_type>::result_type>
+ T inner_product(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, T @\farg{init}@,
+ BinaryOperation1 @\farg{binary_op1}@,
+ BinaryOperation2 @\farg{binary_op2}@);
+ template <InputIterator InIter, OutputIterator<InIter::value_type> OutIter>
+ where Addable<InIter::value_type> &&
+ Assignable<InIter::value_type, Addable<InIter::value_type>::result_type> &&
+ CopyConstructible<InIter::value_type>
+ OutIter partial_sum(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@);
+ template<InputIterator InIter, OutputIterator<InIter::value_type> OutIter,
+ Callable2<InIter::value_type, InIter::value_type> BinaryOperation>
+ where Assignable<InIter::value_type, BinaryOperation::result_type> &&
+ CopyConstructible<InIter::value_type>
+ OutIter partial_sum(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@, BinaryOperation @\farg{binary_op}@);
+ template <InputIterator InIter, OutputIterator<InIter::value_type> OutIter>
+ where Subtractable<InIter::value_type, InIter::value_type> &&
+ Assignable<OutIter, Subtractable<InIter::value_type, InIter::value_type>::result_type> &&
+ CopyConstructible<InIter::value_type> && Assignable<InIter::value_type>
+ OutIter adjacent_difference(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@);
+ template <InputIterator InIter, OutputIterator<InIter::value_type> OutIter,
+ Callable2<InIter::value_type, InIter::value_type> BinaryOperation>
+ where Assignable<OutIter::reference, BinaryOperation::result_type> &&
+ CopyConstructible<InIter::value_type> && Assignable<InIter::value_type>
+ OutIter adjacent_difference(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@,
+ BinaryOperation @\farg{binary_op}@);
+}
+\end{codeblock}
+\color{black}
+
+\pnum
+The requirements on the types of algorithms' arguments that are
+described in the introduction to clause \ref{lib.algorithms}\ also
+apply to the following algorithms.
+
+\rSec2[lib.accumulate]{Accumulate}
+
+\color{addclr}
+\index{accumulate@\tcode{accumulate}}%
+\begin{itemdecl}
+template <InputIterator Iter, Addable<Iter::reference> T>
+ where Assignable<T, T::result_type>
+ T accumulate(Iter @\farg{first}@, Iter @\farg{last}@, T @\farg{init}@);
+template <InputIterator Iter, class T, Callable2<T, Iter::reference> BinaryOperation>
+ where Assignable<T, BinaryOperation::result_type>
+ T accumulate(Iter @\farg{first}@, Iter @\farg{last}@, T @\farg{init}@,
+ BinaryOperation @\farg{binary_op}@);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Computes its result by initializing the accumulator
+\tcode{acc}\
+with the initial value
+\tcode{init}\
+and then modifies it with
+\tcode{acc = acc + *i}\
+or
+\tcode{acc = binary_op(acc, *i)}\
+for every iterator
+\tcode{i}\
+in the range \range{first}{last}\
+in order.%
+\footnote{
+\tcode{accumulate}\
+is similar to the APL reduction operator and Common Lisp reduce function, but it avoids the
+difficulty of defining the result of reduction on an empty sequence by always requiring an initial value.
+}
+
+\pnum
+\requires\
+\removedConcepts{T shall meet the requirements of CopyConstructible (20.1.3)
+and Assignable (21.3) types.}
+In the range
+\crange{first}{last},
+\tcode{binary_op}\
+shall neither modify elements nor invalidate iterators or subranges.%
+\footnote{The use of fully closed ranges is intentional
+}
+\end{itemdescr}
+
+\rSec2[lib.inner.product]{Inner product}
+\index{inner_product@\tcode{inner_product}}%
+
+\color{addclr}
+\begin{itemdecl}
+template <InputIterator Iter1, InputIterator Iter2, class T>
+ where Multiplicable<Iter1::reference, Iter2::reference> &&
+ Addable<T, Multiplicable<Iter1::reference, Iter2::reference>::result_type> &&
+ Assignable<
+ T,
+ Addable<T,
+ @\color{addclr}@Multiplicable<Iter1::reference, Iter2::reference>::result_type>::result_type>
+ T inner_product(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, T @\farg{init}@);
+template <InputIterator Iter1, InputIterator Iter2, class T,
+ class BinaryOperation1, Callable2<Iter1::reference, Iter2::reference> BinaryOperation2>
+ where Callable2<BinaryOperation1, T, BinaryOperation2::result_type> &&
+ Assignable<T,
+ Callable2<BinaryOperation1, T, BinaryOperation2::result_type>::result_type>
+ T inner_product(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, T @\farg{init}@,
+ BinaryOperation1 @\farg{binary_op1}@,
+ BinaryOperation2 @\farg{binary_op2}@);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Computes its result by initializing the accumulator
+\tcode{acc}\
+with the initial value
+\tcode{init}\
+and then modifying it with
+\tcode{acc = acc + (*i1) * (*i2)}\
+or
+\tcode{acc = binary_op1(acc, binary_op2(*i1, *i2))}\
+for every iterator
+\tcode{i1}\
+in the range \range{first}{last}\
+and iterator
+\tcode{i2}\
+in the range
+\range{first2}{first2 + (last - first)}
+in order.
+
+\pnum
+\requires\
+\removedConcepts{T shall meet the requirements of CopyConstructible (20.1.3)
+and Assignable (21.3) types.}
+In the ranges
+\crange{first}{last}\
+and
+\crange{first2}{first2 + (last - first)}\
+\tcode{binary_op1}\
+and
+\tcode{binary_op2}\
+shall neither modify elements nor invalidate iterators or subranges.%
+\footnote{The use of fully closed ranges is intentional
+}
+\end{itemdescr}
+
+\rSec2[lib.partial.sum]{Partial sum}
+\index{partial_sum@\tcode{partial_sum}}%
+\color{addclr}
+\begin{itemdecl}
+template <InputIterator InIter, OutputIterator<InIter::value_type> OutIter>
+ where Addable<InIter::value_type> &&
+ Assignable<InIter::value_type, Addable<InIter::value_type>::result_type> &&
+ CopyConstructible<InIter::value_type>
+ OutIter partial_sum(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@);
+template<InputIterator InIter, OutputIterator<InIter::value_type> OutIter,
+ Callable2<InIter::value_type, InIter::value_type> BinaryOperation>
+ where Assignable<InIter::value_type, BinaryOperation::result_type> &&
+ CopyConstructible<InIter::value_type>
+ OutIter partial_sum(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@, BinaryOperation @\farg{binary_op}@);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Assigns to every element referred to by iterator
+\tcode{i}\
+in the range
+\range{result}{result + (last - first)}
+a value
+correspondingly equal to
+
+\begin{codeblock}
+((...(*first + *(first + 1)) + ...) + *(first + (i - result)))
+\end{codeblock}
+
+or
+
+\begin{codeblock}
+binary_op(binary_op(...,
+ binary_op(*first, *(first + 1)),...), *(first + (i - result)))
+\end{codeblock}
+
+\pnum
+\returns\
+\tcode{result + (last - first)}.
+
+\pnum
+\complexity\
+Exactly
+\tcode{(last - first) - 1}\
+applications of
+\tcode{binary_op}.
+
+\pnum
+\requires\
+In the ranges
+\crange{first}{last}\
+and
+\crange{result}{result + (last - first)}\
+\tcode{binary_op}\
+shall neither modify elements nor invalidate iterators or subranges.%
+\footnote{The use of fully closed ranges is intentional.
+}
+
+\pnum
+\notes\
+\tcode{result}\
+may be equal to
+\tcode{first}.
+\end{itemdescr}
+
+\rSec2[lib.adjacent.difference]{Adjacent difference}
+
+\index{adjacent_difference@\tcode{adjacent_difference}}%
+\color{addclr}
+\begin{itemdecl}
+template <InputIterator InIter, OutputIterator<InIter::value_type> OutIter>
+ where Subtractable<InIter::value_type, InIter::value_type> &&
+ Assignable<OutIter, Subtractable<InIter::value_type, InIter::value_type>::result_type> &&
+ CopyConstructible<InIter::value_type> && Assignable<InIter::value_type>
+ OutIter adjacent_difference(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@);
+template <InputIterator InIter, OutputIterator<InIter::value_type> OutIter,
+ Callable2<InIter::value_type, InIter::value_type> BinaryOperation>
+ where Assignable<OutIter::reference, BinaryOperation::result_type> &&
+ CopyConstructible<InIter::value_type> && Assignable<InIter::value_type>
+ OutIter adjacent_difference(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@,
+ BinaryOperation @\farg{binary_op}@);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Assigns to every element referred to by iterator
+\tcode{i}\
+in the range
+\range{result + 1}{result + (last - first)}
+a value correspondingly equal to
+
+\begin{codeblock}
+*(first + (i - result)) - *(first + (i - result) - 1)
+\end{codeblock}
+
+or
+
+\begin{codeblock}
+binary_op(*(first + (i - result)), *(first + (i - result) - 1)).
+\end{codeblock}
+
+\tcode{result}
+gets the value of
+\tcode{*first}.
+
+\pnum
+\requires\
+In the ranges
+\crange{first}{last}\
+and
+\crange{result}{result + (last - first)},
+\tcode{binary_op}\
+shall neither modify elements nor invalidate iterators or subranges.%
+\footnote{The use of fully closed rangs is intentional.
+}
+
+\pnum
+\notes\
+\tcode{result}\
+may be equal to
+\tcode{first}.
+
+\pnum
+\returns\
+\tcode{result + (last - first)}.
+
+\pnum
+\complexity\
+Exactly
+\tcode{(last - first) - 1}\
+applications of
+\tcode{binary_op}.
+\end{itemdescr}
+
+\end{paras}
+
+\bibliographystyle{plain}
+\bibliography{../local}
+
+\end{document}
\ No newline at end of file

Added: sandbox/committee/concepts/stdlib/clib-utilities.tex
==============================================================================
--- (empty file)
+++ sandbox/committee/concepts/stdlib/clib-utilities.tex 2008-03-03 15:03:07 EST (Mon, 03 Mar 2008)
@@ -0,0 +1,3688 @@
+\documentclass[american,twoside]{book}
+\usepackage{hyperref}
+\usepackage{refbib}
+\input{macros}
+
+%%--------------------------------------------------
+%% Set section numbering limit, toc limit
+\setcounter{secnumdepth}{5}
+\setcounter{tocdepth}{1}
+
+%%--------------------------------------------------
+%% Parameters that govern document appearance
+\setlength{\oddsidemargin}{0pt}
+\setlength{\evensidemargin}{0pt}
+\setlength{\textwidth}{6.6in}
+
+%%--------------------------------------------------
+%% Handle special hyphenation rules
+\hyphenation{tem-plate ex-am-ple in-put-it-er-a-tor}
+
+% Do not put blank pages after chapters that end on odd-numbered pages.
+\def\cleardoublepage{\clearpage\if_at_twoside%
+ \ifodd\c_at_page\else\hbox{}\thispagestyle{empty}\newpage%
+ \if_at_twocolumn\hbox{}\newpage\fi\fi\fi}
+
+\newsavebox\rebindbox
+
+\begin{document}
+\raggedbottom
+
+\begin{titlepage}
+\begin{center}
+\huge
+Concepts for the C++0x Standard Library: Utilities\\
+(Revision 3)
+
+\vspace{0.5in}
+
+\normalsize
+Douglas Gregor and Andrew Lumsdaine \\
+Open Systems Laboratory \\
+Indiana University \\
+Bloomington, IN\ \ 47405 \\
+\{\href{mailto:dgregor_at_[hidden]}{dgregor}, \href{mailto:lums_at_[hidden]}{lums}\}@osl.iu.edu
+\end{center}
+
+\vspace{1in}
+\par\noindent Document number: NNNNN=07-XXXX\vspace{-6pt}
+\par\noindent Revises document number: N2322=07-0182\vspace{-6pt}
+\par\noindent Date: \today\vspace{-6pt}
+\par\noindent Project: Programming Language \Cpp{}, Library Working Group\vspace{-6pt}
+\par\noindent Reply-to: Douglas Gregor $<$\href{mailto:dgregor_at_[hidden]}{dgregor_at_[hidden]}$>$\vspace{-6pt}
+
+\section*{Introduction}
+\libintrotext{Chapter 20}.
+
+\section*{Changes since N2322}
+\begin{itemize}
+\item Renamed \tcode{Modulus} concept to \tcode{Remainder}.
+\item Fixed description of concepts \tcode{LogicalAnd},
+ \tcode{LogicalOr}, and \tcode{LogicalNot}.
+\item Added concepts \tcode{BitAnd}, \tcode{BitOr}, \tcode{BitXor},
+ and \tcode{Complement}.
+\item Renamed the \tcode{Floating} concept to \tcode{FloatingPoint}.
+\item Made \tcode{operator=} in \tcode{MoveAssignable} and
+ \tcode{CopyAssignable} member operations, as required by N2307.
+\item Dropped the redundant \tcode{CopyAssignable} requirement in
+ \tcode{Arithmetic}.
+\item Note the concept maps required for extended integer types,
+ \tcode{bool}, \tcode{char16_t}, and \tcode{char32_t}.
+\item Loosened the \tcode{Allocator} requirements to not require the
+ allocator itself to be \tcode{CopyAssignable}; \tcode{Allocator} now
+ better matches the pre-concept standard library.
+\item Make \tcode{Allocator}'s \tcode{max_size} and \tcode{address}
+ associated functions \tcode{const}.
+\item Added concept requirements to \tcode{make_pair} and
+ \tcode{make_tuple}.
+\item Fixed definition of \tcode{rebind_allocator}.
+\end{itemize}
+
+\end{titlepage}
+
+%%--------------------------------------------------
+%% Headers and footers
+\pagestyle{fancy}
+\fancyhead[LE,RO]{\textbf{\rightmark}}
+\fancyhead[RE]{\textbf{\leftmark\hspace{1em}\thepage}}
+\fancyhead[LO]{\textbf{\thepage\hspace{1em}\leftmark}}
+\fancyfoot[C]{Draft}
+
+\fancypagestyle{plain}{
+\renewcommand{\headrulewidth}{0in}
+\fancyhead[LE,RO]{}
+\fancyhead[RE,LO]{}
+\fancyfoot{}
+}
+
+\renewcommand{\sectionmark}[1]{\markright{\thesection\hspace{1em}#1}}
+\renewcommand{\chaptermark}[1]{\markboth{#1}{}}
+
+\setcounter{chapter}{19}
+\rSec0[utilities]{General utilities library}
+\setcounter{Paras}{1}
+\textcolor{black}{\pnum}
+The following clauses describe utility and allocator \changedConcepts{requirements}{concepts}, utility
+components, \addedB{tuples, type traits templates,} function objects, dynamic
+memory management utilities, and date/time utilities, as summarized in
+Table~\ref{tab:util.lib.summary}.
+
+\setcounter{table}{29}
+\begin{libsumtab}{General utilities library summary}{tab:util.lib.summary}
+\ref{utility.concepts}
+\changedConcepts{Requirements}{Concepts} & \addedConcepts{\ttfamily <concepts>} \\ \rowsep
+\ref{utility} Utility components & \tcode{<utility>} \\ \rowsep
+\ref{tuple} \addedB{Tuples} & \tcode{\addedB{<tuple>}} \\ \rowsep
+\ref{meta} \addedB{Type traits} & \tcode{\addedB{<type_traits>}} \\ \rowsep
+\ref{function.objects} Function objects & \tcode{<functional>}\\ \rowsep
+ & \tcode{<memory>} \\
+\ref{memory} Memory & \tcode{<cstdlib>} \\
+ & \tcode{<cstring>} \\ \rowsep
+\ref{date.time} Date and time & \tcode{<ctime>} \\
+\end{libsumtab}
+
+\noindent\editorial{Replace the section [utility.requirements] with
+ the following section [utility.concepts]}
+
+\color{addclr}
+\rSec1[utility.concepts]{Concepts}
+
+\pnum The \tcode{<concepts>} header describes requirements on template
+arguments used throughout the \Cpp\ Standard Library.
+
+\synopsis{Header \tcode{<concepts>}\ synopsis}
+\begin{codeblock}
+namespace std {
+ // \ref{concept.support}, support concepts:
+ concept SameType<typename T, typename U> { }
+ concept DerivedFrom<typename Derived, typename Base> { }
+ concept ObjectType<typename T> { }
+
+ // \ref{concept.comparison}, comparisons:
+ auto concept EqualityComparable<typename T, typename U = T> @\textit{see below}@;
+ auto concept LessThanComparable<typename T, typename U = T> @\textit{see below}@;
+
+ // \ref{concept.destruct}, destruction:
+ auto concept Destructible<typename T> @\textit{see below}@;
+
+ // \ref{concept.construct}, construction:
+ auto concept Constructible<typename T, typename... Args> @\textit{see below}@;
+ auto concept DefaultConstructible<typename T> @\textit{see below}@;
+
+ // \ref{concept.copymove}, copy and move:
+ auto concept MoveConstructible<typename T> @\textit{see below}@;
+ auto concept CopyConstructible<typename T> @\textit{see below}@;
+ auto concept MoveAssignable<typename T, typename U = T> @\textit{see below}@;
+ auto concept CopyAssignable<typename T, typename U = T> @\textit{see below}@;
+ auto concept Swappable<typename T> @\textit{see below}@;
+
+ // \ref{concept.regular}, regular types:
+ auto concept Semiregular<typename T> @\textit{see below}@;
+ auto concept Regular<typename T> @\textit{see below}@;
+
+ // \ref{concept.convertible}, convertibility:
+ auto concept Convertible<typename T, typename U> @\textit{see below}@;
+
+ // \ref{concept.true}, true:
+ concept True<bool> { }
+ concept_map True<true> { }
+
+ // \ref{concept.arithmetic}, arithmetic concepts:
+ auto concept Addable<typename T, typename U = T> @\textit{see below}@;
+ auto concept Subtractable<typename T, typename U = T> @\textit{see below}@;
+ auto concept Multiplicable<typename T, typename U = T> @\textit{see below}@;
+ auto concept Divisible<typename T, typename U = T> @\textit{see below}@;
+ auto concept Remainder<typename T, typename U = T> @\textit{see below}@;
+ auto concept Negatable<typename T> @\textit{see below}@;
+ concept Arithmetic<typename T> @\textit{see below}@;
+ concept Integral<typename T> @\textit{see below}@;
+ concept SignedIntegral<typename T> @\textit{see below}@;
+ concept UnsignedIntegral<typename T> @\textit{see below}@;
+ concept FloatingPoint<typename T> @\textit{see below}@;
+
+ // \ref{concept.logical}, logical concepts:
+ auto concept LogicalAnd<typename T, typename U = T> @\textit{see below}@;
+ auto concept LogicalOr<typename T, typename U = T> @\textit{see below}@;
+ auto concept LogicalNot<typename T> @\textit{see below}@;
+
+ // \ref{concept.logical}, bitwise concepts:
+ auto concept BitAnd<typename T, typename U = T> @\textit{see below}@;
+ auto concept BitOr<typename T, typename U = T> @\textit{see below}@;
+ auto concept BitXor<typename T, typename U = T> @\textit{see below}@;
+ auto concept Complement<typename T> @\textit{see below}@;
+
+ // \ref{concept.operator}, operator concepts:
+ auto concept Dereferenceable<typename T> @\textit{see below}@;
+
+ // \ref{concept.callable}, callable:
+ auto concept Callable<typename F, typename... Args> @\textit{see below}@;
+
+ // \ref{concept.predicate}, predicates:
+ auto concept Predicate<typename F, typename... Args> @\textit{see below}@;
+
+ // \ref{concept.allocator}, allocators:
+ concept Allocator<typename X> @\textit{see below}@;
+ concept AllocatorGenerator<typename X> @\textit{see below}@;
+ template<Allocator X> concept_map AllocatorGenerator<X> @\textit{see below}@;
+}
+\end{codeblock}
+
+\rSec2[concept.support]{Support concepts}
+\pnum
+Concept \tcode{SameType} describes a same-type requirement ([temp.req]).
+
+\begin{itemdecl}
+concept SameType<typename T, typename U> { }
+\end{itemdecl}
+
+\pnum
+A program shall not provide a concept map for the
+\tcode{SameType} concept.
+
+\pnum
+Concept \tcode{DerivedFrom} describes a derivation requirement ([temp.req]).
+
+\begin{itemdecl}
+concept DerivedFrom<typename Derived, typename Base> { }
+\end{itemdecl}
+
+\pnum
+A program shall not provide a concept map for the
+\tcode{DerivedFrom} concept.
+
+\pnum
+Concept \tcode{ObjectType} requires that the type \tcode{T} be an \emph{object type} ([intro.object]).
+
+\begin{itemdecl}
+concept ObjectType<typename T> { }
+\end{itemdecl}
+
+\pnum
+A program shall not provide a concept map for the
+\tcode{ObjectType} concept.
+
+\rSec2[concept.comparison]{Comparisons}
+
+\pnum
+Concept \tcode{EqualityComparable} requires that two values be
+comparable with \tcode{operator==}.
+\begin{itemdecl}
+auto concept EqualityComparable<typename T, typename U = T> {
+ bool operator==(T a, U b);
+ bool operator!=(T a, U b) { return !(a == b); }
+}
+\end{itemdecl}
+
+\pnum
+When \tcode{T} and \tcode{U} are identical, \tcode{operator==} is an
+equivalence relation, that is, it has the following properties:
+\begin{itemize}
+\item
+For all \tcode{a}, \tcode{a == a}.
+\item
+If \tcode{a == b}, then \tcode{b == a}.
+\item
+If \tcode{a == b} and \tcode{b == c}, then \tcode{a == c}.
+\end{itemize}
+
+\pnum Concept \tcode{LessThanComparable} requires the ability to order
+values via \tcode{operator<}.
+\begin{itemdecl}
+auto concept LessThanComparable<typename T, typename U = T> {
+ bool operator<(T a, U b);
+ bool operator>(U a, T b) { return b < a; }
+ bool operator<=(U a, T b) { return !(b < a); }
+ bool operator>=(T a, U b) { return !(a < b); }
+}
+\end{itemdecl}
+
+\pnum
+\tcode{operator<} is a strict weak ordering relation (\ref{alg.sorting})
+
+\rSec2[concept.destruct]{Destruction}
+\pnum
+Concept \tcode{Destructible} requires a destructor.
+\begin{itemdecl}
+auto concept Destructible<typename T> {
+ T::~T();
+}
+\end{itemdecl}
+
+\begin{itemdecl}
+T::~T();
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\postconditions\
+All resources owned by the object are reclaimed.
+
+\pnum
+\throws\
+nothing.
+\end{itemdescr}
+
+\rSec2[concept.construct]{Construction}
+\pnum
+Concept \tcode{Constructible} requires the existence of a constructor
+that accepts a given set of arguments.
+\begin{itemdecl}
+auto concept Constructible<typename T, typename... Args>
+ : Destructible<T>
+{
+ T::T(Args...);
+}
+\end{itemdecl}
+
+\pnum
+Concept \tcode{DefaultConstructible} requires the existence of a
+default constructor.
+\begin{itemdecl}
+auto concept DefaultConstructible<typename T> : Constructible<T> { }
+\end{itemdecl}
+
+\rSec2[concept.copymove]{Copy and move}
+\pnum
+Concept \tcode{MoveConstructible} requires the ability to construct an
+object from an rvalue of the same type, potentially altering the rvalue.
+\begin{itemdecl}
+auto concept MoveConstructible<typename T>
+ : Destructible<T>
+{
+ T::T(T&&);
+}
+\end{itemdecl}
+
+\begin{itemdecl}
+T::T(T&& rv);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\postcondition\
+The constructed \tcode{T} object is equivalent to the value of
+\tcode{rv} before the construction.
+\enternote\ there is no requirement on the value of \tcode{rv} after
+the construction. \exitnote\
+\end{itemdescr}
+
+\pnum
+Concept \tcode{CopyConstructible} requires the ability to create a
+copy of an object.
+\begin{itemdecl}
+auto concept CopyConstructible<typename T> : MoveConstructible<T> {
+ T::T(const T&);
+
+ axiom CopyPreservation(T x) {
+ T(x) == x;
+ }
+}
+\end{itemdecl}
+
+\pnum
+Concept \tcode{MoveAssignable} requires the ability to assign to an
+object from an rvalue, potentially altering the rvalue.
+
+\begin{itemdecl}
+auto concept MoveAssignable<typename T, typename U = T> {
+ typename result_type;
+ result_type operator=(T&, U&&);
+}
+\end{itemdecl}
+
+\begin{itemdecl}
+result_type T::operator=(U&& rv);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\postconditions\
+The constructed \tcode{T} object is equivalent to the value of
+\tcode{rv} before the assignment.
+\enternote\ there is no requirement on the value of \tcode{rv} after
+the assignment. \exitnote\
+\end{itemdescr}
+
+\pnum
+Concept \tcode{CopyAssignable} requires the ability to assign to an
+object.
+
+\begin{itemdecl}
+auto concept CopyAssignable<typename T, typename U = T> : MoveAssignable<T, U> {
+ typename result_type;
+ result_type T::operator=(const U&);
+
+ axiom CopyPreservation(T& x, U y) {
+ (x = y, x) == y;
+ }
+}
+\end{itemdecl}
+
+\editorial{\textcolor{black}{The CopyAssignable requirements in N2284 specify that
+ \tcode{operator=} must return a \tcode{T\&}. This is too strong a
+ requirement for most of the uses of \tcode{CopyAssignable}, so we have
+ weakened \tcode{CopyAssignable} to not require anything of its return
+ type. When we need a \tcode{T\&}, we'll add that as an explicit
+ requirement. See, e.g., the \tcode{Integral} concept.}}
+
+\pnum
+Concept \tcode{Swappable} requires that two values can be swapped.
+
+\begin{itemdecl}
+auto concept Swappable<typename T> {
+ void swap(T&, T&);
+}
+\end{itemdecl}
+
+\begin{itemdecl}
+void swap(T& t, T& u);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\postconditions\
+\tcode{t} has the value originally held by \tcode{u}, and \tcode{u}
+has the value originally held by \tcode{t}.
+\end{itemdescr}
+
+\rSec2[concept.regular]{Regular types}
+
+\pnum
+Concept \tcode{Semiregular} collects several common
+requirements supported by most \Cpp\ types.
+
+\begin{itemdecl}
+auto concept Semiregular<typename T> : CopyConstructible<T>, CopyAssignable<T> {
+ requires SameType<CopyAssignable<T>::result_type, T&>;
+}
+\end{itemdecl}
+
+\pnum
+Concept \tcode{Regular} describes semi-regular types that are default
+constructible and have equality comparison operators.
+
+\begin{itemdecl}
+auto concept Regular<typename T> : Semiregular<T>, DefaultConstructible<T>, EqualityComparable<T> { }
+\end{itemdecl}
+
+\rSec2[concept.convertible]{Convertibility}
+
+\pnum
+Concept \tcode{Convertible} requires an implicit conversion from one
+type to another.
+
+\begin{itemdecl}
+auto concept Convertible<typename T, typename U> {
+ operator U(T);
+}
+\end{itemdecl}
+
+\rSec2[concept.true]{True}
+
+\pnum
+Concept \tcode{True} requires that its argument (a \tcode{bool} value
+that must be an integral constant expression) be true.
+
+\begin{itemdecl}
+concept True<bool> { }
+concept_map True<true> { }
+\end{itemdecl}
+
+\pnum
+A program shall not provide a concept map for the
+\tcode{True} concept.
+
+\rSec2[concept.arithmetic]{Arithmetic concepts}
+\pnum
+Concept \tcode{Addable} requires an addition operator.
+\begin{itemdecl}
+auto concept Addable<typename T, typename U = T> {
+ typename result_type;
+ result_type operator+(T, U);
+}
+\end{itemdecl}
+
+\pnum
+Concept \tcode{Subtractable} requires a subtraction operator.
+\begin{itemdecl}
+auto concept Subtractable<typename T, typename U = T> {
+ typename result_type;
+ result_type operator-(T, U);
+}
+\end{itemdecl}
+
+\pnum
+Concept \tcode{Multiplicable} requires a multiplication operator.
+\begin{itemdecl}
+auto concept Multiplicable<typename T, typename U = T> {
+ typename result_type;
+ result_type operator*(T, U);
+}
+\end{itemdecl}
+
+\pnum
+Concept \tcode{Divisible} requires a division operator.
+\begin{itemdecl}
+auto concept Divisible<typename T, typename U = T> {
+ typename result_type;
+ result_type operator/(T, U);
+}
+\end{itemdecl}
+
+\pnum
+Concept \tcode{Remainder} requires the existance the remainder operator.
+\begin{itemdecl}
+auto concept Remainder<typename T, typename U = T> {
+ typename result_type;
+ result_type operator%(T, U);
+}
+\end{itemdecl}
+
+\pnum
+Concept \tcode{Negatable} requires a negation operator.
+\begin{itemdecl}
+auto concept Negatable<typename T> {
+ typename result_type;
+ result_type operator-(T);
+}
+\end{itemdecl}
+
+\pnum
+Concept \tcode{Arithmetic} requires all of the operations available on
+arithmetic types ([basic.fundamental]).
+
+\begin{itemdecl}
+concept Arithmetic<typename T> : Regular<T>, LessThanComparable<T> {
+ T::T(long long);
+
+ T& operator++(T&);
+ T operator++(T& t, int) { T tmp(t); ++t; return tmp; }
+ T& operator--(T&);
+ T operator--(T& t, int) { T tmp(t); --t; return tmp; }
+
+ T operator+(T);
+ T operator-(T);
+
+ T operator*(T x, T y) { T z(x); return z *= y; }
+ T operator/(T x, T y) { T z(x); return z /= y; }
+ T operator+(T x, T y) { T z(x); return z += y; }
+ T operator-(T x, T y) { T z(x); return z -= y; }
+
+ T& operator*=(T&, T);
+ T& operator/=(T&, T);
+ T& operator+=(T&, T);
+ T& operator-=(T&, T);
+}
+\end{itemdecl}
+
+\pnum
+Concept \tcode{Integral} describes the requirements for integral
+types.
+
+\begin{itemdecl}
+concept Integral<typename T> : Arithmetic<T> {
+ T operator~(T);
+
+ T operator%(T x, T y) { T z(x); return z %= y; }
+ T operator&(T x, T y) { T z(x); return z &= y; }
+ T operator^(T x, T y) { T z(x); return z ^= y; }
+ T operator|(T x, T y) { T z(x); return z |= y; }
+ T operator<<(T x, T y) { T z(x); return z <<= y; }
+ T operator>>(T x, T y) { T z(x); return z >>= y; }
+
+ T& operator%=(T&, T);
+ T& operator&=(T&, T);
+ T& operator^=(T&, T);
+ T& operator|=(T&, T);
+ T& operator<<=(T&, T);
+ T& operator>>=(T&, T);
+}
+\end{itemdecl}
+
+\pnum
+Concept \tcode{SignedIntegral} describes the requirements for signed
+integral types.
+
+\begin{itemdecl}
+concept SignedIntegral<typename T> : Integral<T> { }
+\end{itemdecl}
+
+\pnum
+For every signed integral type \tcode{T} ([basic.fundamental]), there exists an
+empty concept map \tcode{SignedIntegral<T>}.
+
+\pnum
+Concept \tcode{UnsignedIntegral} describes unsigned integral types.
+
+\begin{itemdecl}
+concept UnsignedIntegral<typename T> : Integral<T> { }
+\end{itemdecl}
+
+\pnum
+For every unsigned integral type \tcode{T} ([basic.fundamental]),
+there exists an empty concept map \tcode{UnsignedIntegral<T>}.
+
+\pnum
+If \tcode{char} is a signed integral type, there shall exist an empty
+concept map \tcode{SignedIntegral<char>} otherwise, there shall exist
+an empty concept map \tcode{UnsignedIntegral<char>}.
+
+\pnum
+If \tcode{wchar_t} is a signed integral type, there shall exist an empty
+concept map \tcode{SignedIntegral<wchar_t>} otherwise, there shall exist
+an empty concept map \tcode{UnsignedIntegral<wchar_t>}.
+
+\pnum
+For every extended integer type \tcode{T}, there shall exist an empty
+concept map \tcode{SignedIntegral<T>} or \tcode{UnsignedIntegral<T>}.
+
+\pnum
+There shall exist empty concept maps
+\tcode{UnsignedIntegral<char16_t>} and \tcode{UnsignedIntegral<char32_t>}.
+
+\pnum
+The \tcode{FloatingPoint} concept describes floating-point numbers.
+
+\begin{itemdecl}
+@\textcolor{addclr}{concept}@ FloatingPoint<typename T> : Arithmetic<T> { }
+\end{itemdecl}
+
+\pnum
+For every floating point type \tcode{T} ([basic.fundamental]), there
+exists an empty concept map \tcode{FloatingPoint<T>}.
+
+\rSec2[concept.logical]{Logical concepts}
+\pnum
+Concept \tcode{LogicalAnd} requires a logical conjunction operator.
+\begin{itemdecl}
+auto concept LogicalAnd<typename T, typename U = T> {
+ bool operator&&(T, U);
+}
+\end{itemdecl}
+
+\pnum
+Concept \tcode{LogicalOr} requires an logical disjunction operator.
+\begin{itemdecl}
+auto concept LogicalOr<typename T, typename U = T> {
+ bool operator||(T, U);
+}
+\end{itemdecl}
+
+\pnum
+Concept \tcode{LogicalNot} requires a logical negation operator.
+\begin{itemdecl}
+auto concept LogicalNot<typename T> {
+ bool operator!(T);
+}
+\end{itemdecl}
+
+\rSec2[concept.bitwise]{Bitwise concepts}
+\pnum
+Concept \tcode{BitAnd} requires a bitwise and operator.
+\begin{itemdecl}
+auto concept BitAnd<typename T, typename U = T> {
+ bool operator&(T, U);
+}
+\end{itemdecl}
+
+\pnum
+Concept \tcode{BitOr} requires a bitwise or operator.
+\begin{itemdecl}
+auto concept BitOr<typename T, typename U = T> {
+ bool operator|(T, U);
+}
+\end{itemdecl}
+
+\pnum
+Concept \tcode{BitXor} requires a bitwise exclusive-or operator.
+\begin{itemdecl}
+auto concept BitXor<typename T, typename U = T> {
+ bool operator^(T, U);
+}
+\end{itemdecl}
+
+\pnum
+Concept \tcode{Complement} requires a bitwise complement operator.
+\begin{itemdecl}
+auto concept Complement<typename T> {
+ bool operator~(T);
+}
+\end{itemdecl}
+
+\rSec2[concept.operator]{Operator concepts}
+\pnum
+Concept \tcode{Dereferenceable} requires a
+dereference operator \tcode{*}.
+\begin{itemdecl}
+auto concept Dereferenceable<typename T> {
+ typename reference;
+ reference operator*(T);
+}
+\end{itemdecl}
+
+\rSec2[concept.callable]{Callable}
+
+\pnum
+The \tcode{Callable} concepts requires that the given
+parameter \tcode{F} be callable given arguments of types \tcode{Args}.
+\begin{itemdecl}
+auto concept Callable<typename F, typename... Args> {
+ typename result_type;
+ result_type operator()(F&, Args...);
+}
+\end{itemdecl}
+
+
+\rSec2[concept.predicate]{Predicates}
+
+\pnum
+The \tcode{Predicate} concept requires that a function object be
+callable with some number of arguments, the result of which can be used in a
+context that requires a \tcode{bool}.
+
+\begin{itemdecl}
+auto concept Predicate<typename F, typename... Args> : Callable<F, Args...> {
+ requires Convertible<result_type, bool>;
+}
+\end{itemdecl}
+
+\textcolor{addclr}{\pnum}
+Predicate function objects shall not apply any non-constant function
+through the predicate arguments.
+
+\color{black}
+\rSec2[concept.allocator]{Allocators}
+\index{requirements!Allocator@\tcode{Allocator}}%
+\editorial{We have kept most of the text of [allocator.requirements]
+ here, although much of it has been moved from tables into numbered
+ paragraphs when translating the allocator requirements into concepts.}
+
+\pnum
+The library describes a standard set of requirements for \techterm{allocators},
+which are objects that encapsulate the information about an allocation model.
+This information includes the knowledge of pointer types, the type of their
+difference, the type of the size of objects in this allocation model, as well
+as the memory allocation and deallocation primitives for it. All of the
+containers (clause~\ref{containers}) are parameterized in terms of allocators.
+
+\eremove{Remove Table 39: Descriptive variable definitions}
+
+\eremove{Remove Table 40: Allocator requirements}
+
+\pnum
+\changedConcepts{Table~40 describes the requirements on types manipulated
+through allocators.}
+{The \mbox{\tcode{Allocator}} concept describes the requirements on
+ allocators.}
+\changedConcepts{All the operations on the allocators are expected to be
+amortized constant time.}{Each allocator operation shall have
+amortized constant time complexity.}
+\removedConcepts{Table~33
+describes the requirements on allocator types.}
+
+\color{addclr}
+\begin{itemdecl}
+concept Allocator<typename X> : DefaultConstructible<X>, CopyConstructible<X> {
+ ObjectType value_type = typename X::value_type;
+ MutableRandomAccessIterator pointer = typename X::pointer;
+ RandomAccessIterator const_pointer = typename X::const_pointer;
+ typename reference = typename X::reference;
+ typename const_reference = typename X::const_reference;
+ SignedIntegral difference_type = typename X::difference_type;
+ UnsignedIntegral size_type = typename X::size_type;
+ template<ObjectType T> class rebind = @\textit{see below}@;
+
+ requires Convertible<pointer, const_pointer> &&
+ Convertible<pointer, void*> &&
+ Convertible<pointer, value_type*> &&
+ SameType<pointer::value_type, value_type> &&
+ SameType<pointer::reference, value_type&> &&
+ SameType<pointer::reference, reference>;
+
+ requires Convertible<const_pointer, const void*> &&
+ @\textcolor{addclr}{Convertible}@<const_pointer, const value_type&> &&
+ SameType<const_pointer::value_type, value_type> &&
+ SameType<const_pointer::reference, const value_type&> &&
+ SameType<const_pointer::reference, const_reference>;
+
+ requires SameType<rebind<value_type>, X>;
+
+ pointer X::allocate(size_type n);
+ pointer X::allocate(size_type n, const_pointer p);
+ @\textcolor{addclr}{void}@ X::deallocate(pointer p, size_type n);
+
+ size_type X::max_size() const;
+
+ template<ObjectType T>
+ X::X(const rebind<T>& y);
+
+ @\removedConcepts{void X::construct(pointer p, const value_type\&);}@
+ template<typename V>
+ requires Convertible<V, value_type>
+ void X::construct(pointer p, V&&);
+
+ void X::destroy(pointer p);
+
+ pointer X::address(reference) const;
+ const_pointer X::address(const_reference) const;
+}
+\end{itemdecl}
+\color{black}
+
+\color{addclr}
+\begin{itemdecl}
+UnsignedIntegral size_type;
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\ctype\
+a type that can represent the size of the largest object in the allocation model
+\end{itemdescr}
+
+\color{addclr}
+\begin{itemdecl}
+SignedIntegral difference_type;
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\ctype\
+a type that can represent the difference between any two pointers
+in the allocation model
+\end{itemdescr}
+
+\color{addclr}
+\begin{itemdecl}
+template<ObjectType T> class rebind;
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\ctype}}
+The \changedConcepts{member class}{associated} template \tcode{rebind} \removedConcepts{in the table above is effectively a
+typedef template}{is a template that produces allocators in the same
+ family as \mbox{\tcode{X}}}: if the name
+\changedConcepts{\mbox{\tcode{Allocator}}}{\mbox{\tcode{X}}} is bound
+to \changedConcepts{\mbox{\tcode{SomeAllocator<T>}}}{
+\mbox{\tcode{SomeAllocator<value_type>}}},
+then \changedConcepts{\mbox{\tcode{Allocator::rebind<U>::other}}}{\mbox{\tcode{rebind<U>}}} is the same type as
+\mbox{\tcode{Some}}\-\mbox{\tcode{Allocator<U>}}.
+\addedConcepts{The resulting type
+\mbox{\tcode{SameAllocator<U>}} shall meet the requirements of the
+\mbox{\tcode{Allocator}} concept.}
+
+\addedConcepts{The
+ default value for \mbox{\tcode{rebind}} is a template
+ \mbox{\tcode{R}} for which \mbox{\tcode{R<U>}} is
+ \mbox{\tcode{X::template rebind<U>::other}}.}
+
+\begin{lrbox}\rebindbox
+\begin{minipage}{\linewidth}
+\begin{lstlisting}
+template<typename Alloc>
+struct rebind_allocator {
+ template<typename U>
+ using rebind = typename Alloc::template rebind<U>::other;
+};
+\end{lstlisting}
+\end{minipage}
+\end{lrbox}
+
+\editorial{The aforementioned default value for \tcode{rebind} can be
+ implemented as follows:
+
+\usebox \rebindbox
+
+The default value for \tcode{rebind} in the \tcode{Allocator} concept
+is, therefore, \tcode{rebind_allocator<X>::template rebind}.}
+
+\end{itemdescr}
+
+\color{addclr}
+\begin{itemdecl}
+pointer X::allocate(size_type n);
+pointer X::allocate(size_type n, const_pointer p);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Memory is allocated for \tcode{n}\ objects of type \changedConcepts{\mbox{\tcode{T}}}{\mbox{\tcode{value_type}}}\ but objects
+are not constructed. \footnote{It is intended that \tcode{a.allocate}\ be an efficient means
+of allocating a single object of type \tcode{T}, even when \tcode{sizeof(T)}\
+is small. That is, there is no need for a container to maintain its own
+``free list''.}
+
+\pnum
+\returns\
+\removedConcepts{The result is a random access iterator.}
+\addedConcepts{A pointer to the allocated memory.}
+\enternote\
+If \tcode{n == 0}, the return value is unspecified.
+\exitnote\
+
+\pnum
+\throws\
+\tcode{allocate}\ may raise an appropriate exception.
+\end{itemdescr}
+
+\color{addclr}
+\begin{itemdecl}
+void X::deallocate(pointer p, size_type n);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\preconditions\
+All \tcode{n }\ \changedConcepts{T}{value\_type} objects in the area pointed to by \tcode{p}\ shall be
+destroyed prior to this call. \tcode{n} shall match the value passed to
+\tcode{allocate}\ to obtain this memory.
+\enternote\ \tcode{p} shall not be \changedConcepts{null}{singular}.\exitnote
+
+\throws\ Does not throw exceptions.
+\end{itemdescr}
+
+\begin{itemdecl}
+@\addedConcepts{size_type X::max_size() const;}@
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+the largest value that can meaningfully be passed to \tcode{X::allocate()}
+\end{itemdescr}
+
+\color{addclr}
+\begin{itemdecl}
+template<typename V>
+ requires Constructible<value_type, V&&>
+ void X::construct(pointer p, V&&);
+\end{itemdecl}
+\color{black}
+
+\editorial{The non-templated \tcode{X::construct} has been removed
+from the \tcode{Allocator} requirements because it implies that the
+\tcode{value_type} is \tcode{CopyConstructible} (which we do not want
+as a requirement in the \tcode{Allocator} concept). The templated
+version is more general, allowing in-place and move construction.}
+
+\begin{itemdescr}
+\pnum
+\effects\
+\tcode{::new((void*)p) T(forward<V>(v))}
+\end{itemdescr}
+
+\color{addclr}
+\begin{itemdecl}
+void X::destroy(pointer p);
+\end{itemdecl}
+\color{black}
+
+\begin{itemdescr}
+\pnum
+\effects\
+\tcode{((T*)p)->$\sim$T()}
+\end{itemdescr}
+
+\pnum
+\addedConcepts{The \mbox{\tcode{AllocatorGenerator}} concept describes
+ the requirements on types that can be used to generate
+ \mbox{\tcode{Allocator}}s.}
+
+\color{addclr}
+\begin{itemdecl}
+concept AllocatorGenerator<typename X> : Regular<X> {
+ typename value_type = typename X::value_type;
+ template<typename T> class rebind = @\textit{see below}@;
+
+ @\textcolor{addclr}{requires}@ SameType<rebind<value_type>, X>;
+}
+\end{itemdecl}
+\color{black}
+
+\begin{itemdecl}
+@\addedConcepts{template<typename T> class rebind;}@
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedConcepts{\mbox{\ctype}}
+The \changedConcepts{member class}{associated} template \tcode{rebind} \removedConcepts{in the table above is effectively a
+typedef template}{is a template that produces allocator generators in the same
+ family as \mbox{\tcode{X}}}: if the name
+\changedConcepts{\mbox{\tcode{Allocator}}}{\mbox{\tcode{X}}} is bound
+to \changedConcepts{\mbox{\tcode{SomeAllocator<T>}}}{
+\mbox{\tcode{SomeAllocator<value_type>}}},
+then \changedConcepts{\mbox{\tcode{Allocator::rebind<U>::other}}}{\mbox{\tcode{rebind<U>}}} is the same type as
+\mbox{\tcode{Some}}\-\mbox{\tcode{Allocator<U>}}. \addedConcepts{The
+ default value for \mbox{\tcode{rebind}} is a template
+ \mbox{\tcode{R}} for which \mbox{\tcode{R<U>}} is
+ \mbox{\tcode{X::template}} \mbox{\tcode{rebind<U>::other}}.}
+\end{itemdescr}
+
+\pnum
+Two allocators \addedConcepts{or allocator generators} compare equal with \tcode{==}
+iff storage allocated from each can be deallocated via the other.
+
+\pnum \addedConcepts{Every \mbox{\tcode{Allocator}} also meets the
+ requirements of the \mbox{\tcode{AllocatorGenerator}} concept:}
+\color{addclr}
+\begin{itemdecl}
+template<Allocator X>
+concept_map AllocatorGenerator<X> {
+ typedef Allocator<X>::value_type value_type;
+ template<typename U> using rebind = Allocator<X>::rebind<U>;
+}
+\end{itemdecl}
+\color{black}
+
+\pnum
+Implementations of containers described in this International Standard
+are permitted to assume that their \tcode{Alloc}\removedConcepts{\mbox{\tcode{ator}}} template parameter meets
+the following two additional requirements beyond those in
+\changedConcepts{Table~40}{the Allocator concept}.
+
+\begin{itemize}
+\item
+All instances of a given allocator type are required to be interchangeable
+and always compare equal to each other.
+\item
+\removedConcepts{The typedef members pointer, const\_pointer, size\_type,
+and difference\_type are required to be T*, T const*,
+std::size\_t, and std::ptrdiff\_t, respectively.} \color{addclr}The
+requirements clause may contain the following additional requirements:
+\tcode{SameType<Alloc::pointer, Alloc::value_type*>}, \tcode{SameType<Alloc::const_pointer,
+ const Alloc::value_type*>}, \tcode{SameType<Alloc::size_type, std::size_t>}, and
+\tcode{SameType<Alloc::difference_type, std::ptrdiff_t>}.
+\end{itemize}
+
+\pnum
+Implementors are encouraged to supply libraries that can accept allocators
+that encapsulate more general memory models and that support non-equal
+instances.
+In such implementations, any requirements imposed on allocators
+by containers beyond those requirements that appear in
+\changedConcepts{Table~40}{concept Allocator}, and the
+semantics of containers and algorithms when allocator instances compare
+non-equal, are implementation-defined.
+
+\rSec1[utility]{Utility components}
+
+\pnum
+This subclause contains some basic function and class templates that are used
+throughout the rest of the library.
+
+\synopsis{Header \tcode{<utility>}\ synopsis}
+\index{utility@\tcode{<utility>}}%
+\index{rel_ops@\tcode{rel_ops}}%
+
+\begin{codeblock}
+namespace std {
+ // \ref{operators}, operators:
+ namespace rel_ops {
+ template<@\changedConcepts{class}{EqualityComparable}@ T> bool operator!=(const T&, const T&);
+ template<@\changedConcepts{class}{LessThanComparable}@ T> bool operator> (const T&, const T&);
+ template<@\changedConcepts{class}{LessThanComparable}@ T> bool operator<=(const T&, const T&);
+ template<@\changedConcepts{class}{LessThanComparable}@ T> bool operator>=(const T&, const T&);
+ }
+
+ // \ref{forward}, forward/move:
+ template <class T> struct identity;
+ template <@\changedConcepts{class}{ObjectType}@ T> T&& forward(typename identity<T>::type&&);
+ template <@\changedConcepts{class}{ObjectType}@ T> typename remove_reference<T>::type&& move(T&&);
+
+ // \ref{pairs}, pairs:
+ template <@\changedConcepts{class}{ObjectType}@ T1,@\changedConcepts{class}{ObjectType}@ T2> struct pair;
+ template <@\changedConcepts{class}{EqualityComparable}@ T1, @\changedConcepts{class}{EqualityComparable}@ T2>
+ bool operator==(const pair<T1,T2>&, const pair<T1,T2>&);
+ template <@\changedConcepts{class}{LessThanComparable}@ T1, @\changedConcepts{class}{LessThanComparable}@ T2>
+ bool operator< (const pair<T1,T2>&, const pair<T1,T2>&);
+ template <@\changedConcepts{class}{EqualityComparable}@ T1, @\changedConcepts{class}{EqualityComparable}@ T2>
+ bool operator!=(const pair<T1,T2>&, const pair<T1,T2>&);
+ template <@\changedConcepts{class}{LessThanComparable}@ T1, @\changedConcepts{class}{LessThanComparable}@ T2>
+ bool operator> (const pair<T1,T2>&, const pair<T1,T2>&);
+ template <@\changedConcepts{class}{LessThanComparable}@ T1, @\changedConcepts{class}{LessThanComparable}@ T2>
+ bool operator>=(const pair<T1,T2>&, const pair<T1,T2>&);
+ template <@\changedConcepts{class}{LessThanComparable}@ T1, @\changedConcepts{class}{LessThanComparable}@ T2>
+ bool operator<=(const pair<T1,T2>&, const pair<T1,T2>&);
+ template <@\changedConcepts{class}{Swappable}@ T1, @\changedConcepts{class}{Swappable}@ T2>
+ void swap(pair<T1,T2>&, pair<T1,T2>&);
+ template <@\changedConcepts{class}{Swappable}@ T1, @\changedConcepts{class}{Swappable}@ T2>
+ void swap(pair<T1,T2>&&, pair<T1,T2>&);
+ template <@\changedConcepts{class}{Swappable}@ T1, @\changedConcepts{class}{Swappable}@ T2>
+ void swap(pair<T1,T2>&, pair<T1,T2>&&);
+ template <@\changedConcepts{class}{MoveConstructible}@ T1, @\changedConcepts{class}{MoveConstructible}@ T2> pair<T1,T2> make_pair(T1, T2);
+}
+\end{codeblock}
+
+\rSec2[operators]{Operators}
+
+\editorial{By adding concept constraints to the operators in
+ \tcode{rel_ops}, we eliminate nearly all of the problems with
+ \tcode{rel_ops} that caused them to be banished. We could consider
+ bringing them back into namespace \tcode{std}, if they are deemed
+ useful.}
+
+\pnum
+To avoid redundant definitions of \tcode{operator!=} out of \tcode{operator==}
+and operators \tcode{>}, \tcode{<=}, and \tcode{>=} out of \tcode{operator<},
+the library provides the following:
+
+\index{operator"!=@\tcode{operator"!=}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{EqualityComparable}@ T> bool operator!=(const T& x, const T& y);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{Requires:
+Type T is EqualityComparable~(20.1.1).}
+
+\pnum
+\returns\
+\tcode{!(x == y)}.
+\end{itemdescr}
+
+\index{operator>@\tcode{operator>}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{LessThanComparable}@ T> bool operator>(const T& x, const T& y);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{Requires:
+Type T is LessThanComparable~(20.1.2).}
+
+\pnum
+\returns\
+\tcode{y < x}.
+\end{itemdescr}
+
+\index{operator<=@\tcode{operator<=}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{LessThanComparable}@ T> bool operator<=(const T& x, const T& y);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{Requires:
+Type T is LessThanComparable~(20.1.2).}
+
+\pnum
+\returns\
+\tcode{!(y < x)}.
+\end{itemdescr}
+
+\index{operator>=@\tcode{operator>=}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{LessThanComparable}@ T> bool operator>=(const T& x, const T& y);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{Requires:
+Type T is LessThanComparable~(20.1.2).}
+
+\pnum
+\returns\
+\tcode{!(x < y)}.
+\end{itemdescr}
+
+\pnum
+In this library, whenever a declaration is provided for an \tcode{operator!=},
+\tcode{operator>}, \tcode{operator>=}, or \tcode{operator<=},
+and requirements and semantics are not explicitly provided,
+the requirements and semantics are as specified in this clause.
+
+\rSec2[forward]{forward/move helpers}
+
+\pnum
+\addedD{The library provides templated helper functions to simplify
+applying move semantics to an lvalue and to simplify the implementation
+of forwarding functions.}
+
+\index{identity@\tcode{identity}}%
+\begin{itemdecl}
+template <class T> struct identity { typedef T type; };
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedD{\mbox{\enternote} The use of \mbox{\tcode{identity}} in
+\mbox{\tcode{forward}} forces users to explicitly specify the
+template parameter. This is necessary to get the correct forwarding
+semantics.\mbox{\exitnote}}
+\end{itemdescr}
+
+\index{forward@\tcode{forward}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{ObjectType}@ T> T&& forward(typename identity<T>::type&& t);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedD{\mbox{\returns} \mbox{\tcode{t}}.}
+\end{itemdescr}
+
+\setcounter{Paras}{6}
+\index{move@\tcode{move}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{ObjectType}@ T> typename remove_reference<T>::type&& move(T&& t);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedD{\mbox{\returns} \mbox{\tcode{t}}.}
+\end{itemdescr}
+
+\rSec2[pairs]{Pairs}
+
+\pnum
+The library provides a template for heterogeneous pairs of values.
+The library also provides a matching function template to simplify
+their construction and several templates that provide access to \tcode{pair}
+objects as if they were \tcode{tuple} objects (see~\ref{tuple.helper}
+and~\ref{tuple.elem}).%
+\index{pair@\tcode{pair}}%
+\index{pair@\tcode{pair}!tuple interface to}%
+\index{tuple@\tcode{tuple}!and pair_at_and \tcode{pair}}%
+
+\index{pair@\tcode{pair}}%
+\begin{codeblock}
+template <@\changedConcepts{class}{ObjectType}@ T1, @\changedConcepts{class}{ObjectType}@ T2>
+struct pair {
+ typedef T1 first_type;
+ typedef T2 second_type;
+
+ T1 first;
+ T2 second;
+ @\addedConcepts{requires DefaultConstructible<T1> \&\& DefaultConstructible<T2>}@ pair();
+ @\addedConcepts{requires CopyConstructible<T1> \&\& CopyConstructible<T2>}@ pair(const T1& @\farg{x}@, const T2& @\farg{y}@);
+ template<class @\farg{U}@, class @\farg{V}@>
+ @\addedConcepts{requires Constructible<T1, U\&\&> \&\& Constructible<T2, V\&\&>}@
+ pair(U&& @\farg{x}@, V&& @\farg{y}@);
+ @\addedConcepts{requires MoveConstructible<T1> \&\& MoveConstructible<T2>}@ pair(pair&& @\farg{p}@);
+ template<class @\farg{U}@, class @\farg{V}@>
+ @\addedConcepts{requires Constructible<T1, U> \&\& Constructible<T2, V>}@
+ pair(const pair<@\farg{U}@, @\farg{V}@>& @\farg{p}@);
+ template<class @\farg{U}@, class @\farg{V}@>
+ @\addedConcepts{requires Constructible<T1, U\&\&> \&\& Constructible<T2, V\&\&>}@
+ pair(pair<@\farg{U}@, @\farg{V}@>&& @\farg{p}@);
+
+ @\addedConcepts{requires MoveAssignable<T1> \&\& MoveAssignable<T2>}@ pair& operator=(pair&& p );
+ template<class U , class V>
+ @\addedConcepts{requires MoveAssignable<T1, U> \&\& MoveAssignable<T2, V>}@
+ pair& operator=(pair<U , V>&& p );
+
+ @\addedConcepts{requires Swappable<T1> \&\& Swappable<T2>}@ void swap(pair&& p );
+};
+\end{codeblock}
+
+\begin{itemdecl}
+@\addedConcepts{requires DefaultConstructible<T1> \&\& DefaultConstructible<T2>}@ pair();
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Initializes its members as if implemented: \tcode{pair() : first(), second() \{\}}\
+\end{itemdescr}
+
+\begin{itemdecl}
+@\addedConcepts{requires CopyConstructible<T1> \&\& CopyConstructible<T2>}@ pair(const T1& @\farg{x}@, const T2& @\farg{y}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+The constructor initializes \tcode{first} with \farg{x}\ and \tcode{second}
+with \farg{y}.
+\end{itemdescr}
+
+\begin{itemdecl}
+template<class @\farg{U}@, class @\farg{V}@>
+ @\addedConcepts{requires Constructible<T1, U\&\&> \&\& Constructible<T2, V\&\&>}@
+ pair(U&& @\farg{x}@, V&& @\farg{y}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\mbox{\effects}
+The constructor initializes \mbox{\tcode{first}} with
+\mbox{\tcode{forward<U>(\farg{x})}} and \mbox{\tcode{second}}
+with \mbox{\tcode{forward<T>(\farg{y})}}.
+\end{itemdescr}
+
+\begin{itemdecl}
+@\addedConcepts{requires MoveConstructible<T1> \&\& MoveConstructible<T2>}@ pair(pair&& @\farg{p}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\mbox{\effects}
+The constructor initializes \mbox{\tcode{first}} with
+\mbox{\tcode{move(\farg{p}.first)}}
+and \mbox{\tcode{second}} with
+\mbox{\tcode{move(\farg{p}.second)}}.
+\end{itemdescr}
+
+\begin{itemdecl}
+template<class @\farg{U}@, class @\farg{V}@>
+ @\addedConcepts{requires Constructible<T1, U> \&\& Constructible<T2, V>}@
+ pair(const pair<@\farg{U}@, @\farg{V}@> &@\farg{p}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+Initializes members from the corresponding members of the argument,
+performing implicit conversions as needed.
+\end{itemdescr}
+
+\begin{itemdecl}
+template<class @\farg{U}@, class @\farg{V}@>
+ @\addedConcepts{requires Constructible<T1, U\&\&> \&\& Constructible<T2, V\&\&>}@
+ pair(pair<@\farg{U}@, @\farg{V}@>&& @\farg{p}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\mbox{\effects}
+The constructor initializes \mbox{\tcode{first}} with
+\mbox{\tcode{move(\farg{p}.first)}}
+and \mbox{\tcode{second}} with
+\mbox{\tcode{move(\farg{p}.second)}}.
+\end{itemdescr}
+
+\begin{itemdecl}
+@\addedConcepts{requires MoveAssignable<T1> \&\& MoveAssignable<T2>}@ pair& operator=(pair&& @\farg{p}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\mbox{\effects}
+Assigns to \mbox{\tcode{first}} with \mbox{\tcode{move(\farg{p}.first)}}
+and to \mbox{\tcode{second}} with \mbox{\tcode{move(\farg{p}.second)}}.
+
+\pnum
+\mbox{\returns} \mbox{\tcode{*this}}.
+\end{itemdescr}
+
+\begin{itemdecl}
+template<class @\farg{U}@, class @\farg{V}@>
+ @\addedConcepts{requires MoveAssignable<T1, U> \&\& MoveAssignable<T2, V>}@
+ pair& operator=(pair<@\farg{U}@, @\farg{V}@>&& @\farg{p}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\mbox{\effects}
+Assigns to \mbox{\tcode{first}} with \mbox{\tcode{move(\farg{p}.first)}}
+and to \mbox{\tcode{second}} with \mbox{\tcode{move(\farg{p}.second)}}.
+
+\pnum
+\mbox{\returns} \mbox{\tcode{*this}}.
+\end{itemdescr}
+
+\begin{itemdecl}
+@\addedConcepts{requires Swappable<T1> \&\& Swappable<T2>}@ void swap(pair&& @\farg{p}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\mbox{\effects} Swaps
+\mbox{\tcode{first}} with \mbox{\tcode{\farg{p}.first}} and
+\mbox{\tcode{second}} with \mbox{\tcode{\farg{p}.second}}.
+
+\pnum
+\removedConcepts{\mbox{\requires} \mbox{\tcode{first_type}} and
+\mbox{\tcode{second_type}} must be \mbox{\tcode{Swappable}}.}
+\end{itemdescr}
+
+\index{operator==@\tcode{operator==}!\tcode{pair}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{EqualityComparable}@ T1, @\changedConcepts{class}{EqualityComparable}@ T2>
+ bool operator==(const pair<T1, T2>& @\farg{x}@, const pair<T1, T2>& @\farg{y}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{x.first == y.first \&\& x.second == y.second}.
+\end{itemdescr}
+
+\index{operator<@\tcode{operator<}!\tcode{pair}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{LessThanComparable}@ T1, @\changedConcepts{class}{LessThanComparable}@ T2>
+ bool operator<(const pair<T1, T2>& @\farg{x}@, const pair<T1, T2>& @\farg{y}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{x.first < y.first || (!(y.first < x.first) \&\& x.second < y.second)}.
+\end{itemdescr}
+
+\index{swap@\tcode{swap}!\tcode{pair}}%
+\begin{itemdecl}
+template<class @\farg{T1}@, class @\farg{T2}@>
+ @\addedConcepts{requires Swappable<T1> \&\& Swappable<T2>}@
+ void swap(pair<@\farg{T1}@, @\farg{T2}@>& @\farg{x}@, pair<@\farg{T1}@, @\farg{T2}@>& @\farg{y}@);
+template<class @\farg{T1}@, class @\farg{T2}@>
+ @\addedConcepts{requires Swappable<T1> \&\& Swappable<T2>}@
+ void swap(pair<@\farg{T1}@, @\farg{T2}@>&& @\farg{x}@, pair<@\farg{T1}@, @\farg{T2}@>& @\farg{y}@);
+template<class @\farg{T1}@, class @\farg{T2}@>
+ @\addedConcepts{requires Swappable<T1> \&\& Swappable<T2>}@
+ void swap(pair<@\farg{T1}@, @\farg{T2}@>& @\farg{x}@, pair<@\farg{T1}@, @\farg{T2}@>&& @\farg{y}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\mbox{\effects} \mbox{\tcode{\farg{x}.swap(\farg{y})}}
+\end{itemdescr}
+
+\index{make_pair@\tcode{make_pair}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{MoveConstructible}@ T1, @\changedConcepts{class}{MoveConstructible}@ T2>
+ pair<T1, T2> make_pair(T1 @\farg{x}@, T2 @\farg{y}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+% .Fs new
+\tcode{pair<T1, T2>(x, y)}.%
+\footnote{
+According to~(\ref{class.copy}), an implementation is permitted to not
+perform a copy of an argument, thus avoiding unnecessary copies.
+}
+
+\pnum
+\enterexample\
+In place of:
+
+\begin{codeblock}
+ return pair<int, double>(5, 3.1415926); // explicit types
+\end{codeblock}
+
+a \Cpp\ program may contain:
+
+\begin{codeblock}
+ return make_pair(5, 3.1415926); // types are deduced
+\end{codeblock}
+\exitexample\
+\end{itemdescr}
+
+\rSec1[tuple]{\marktr{}Tuples}
+
+\pnum
+\index{tuple@\tcode{tuple}}%
+\ref{tuple} describes the tuple library that provides a tuple type as
+the class template \tcode{tuple} that can be instantiated with any number
+of arguments. \removedD{An implementation can set an upper limit for the number
+of arguments. The minimum value for this implementation quantity is
+defined in Annex~\mbox{\ref{limits}}.} Each template argument specifies
+the type of an element in the \tcode{tuple}. Consequently, tuples are
+heterogeneous, fixed-size collections of values.
+
+
+\pnum
+\synopsis{Header \tcode{<tuple>} synopsis}
+
+\index{tuple@\tcode{<tuple>}}%
+\begin{codeblock}
+namespace std {
+ // \ref{tuple.tuple}, class template tuple:
+ template <@\changedConcepts{class}{ObjectType}@... Types> class tuple;
+
+ // \ref{tuple.creation}, tuple creation functions:
+ const @\textit{unspecified}@ ignore;
+
+ template <@\changedConcepts{class}{MoveConstructible}@... Types>
+ tuple<@\addedD{VTypes...}@> make_tuple(@\addedD{Types\&\&...}@);
+
+ template<@\changedConcepts{class}{ObjectType}@... Types>
+ tuple<@\addedD{Types\&...}@> tie(@\addedD{Types\&...}@);
+
+ // \ref{tuple.helper}, tuple helper classes:
+ template <class T> class tuple_size; // \addedD{undefined}
+ @\addedD{template <class... Types> class tuple_size<tuple<Types...> >;}@
+
+ template <int I, class T> class tuple_element; // \addedD{undefined}
+ @\addedD{template <int I, class... Types>}@
+ @\addedConcepts{requires True<0 <= I \&\& I < sizeof...(Types)>}@ class tuple_element<I, tuple<Types...> >;
+
+ // \ref{tuple.elem}, element access:
+ template <int I, @\changedConcepts{class}{ObjectType}@... Types>
+ @\addedConcepts{requires True<0 <= I \&\& I < sizeof...(Types)>}@
+ @\addedD{typename tuple_element<I, tuple<Types...> >::type\& get(tuple<Types...>\&);}@
+
+ template <int I, @\changedConcepts{class}{ObjectType}@... Types>
+ @\addedConcepts{requires True<0 <= I \&\& I < sizeof...(Types)>}@
+ @\addedD{typename tuple_element<I, tuple<Types...> >::type const\& get(const tuple<Types...>\&);}@
+
+ // \ref{tuple.rel}, relational operators:
+ template<class... TTypes, class... UTypes>
+ @\addedConcepts{requires EqualityComparable<TTypes, UTypes>...}@
+ bool operator==(const tuple<@\addedD{TTypes...}@>&, const tuple<@\addedD{UTypes...}@>&);
+
+ template<@\addedD{class... TTypes, class... UTypes}@>
+ @\addedConcepts{requires LessThanComparable<TTypes, UTypes>...}@
+ bool operator<(const tuple<@\addedD{TTypes...}@>&, const tuple<@\addedD{UTypes...}@>&);
+
+ template<@\addedD{class... TTypes, class... UTypes}@>
+ @\addedConcepts{requires EqualityComparable<TTypes, UTypes>...}@
+ bool operator!=(const tuple<@\addedD{TTypes...}@>&, const tuple<@\addedD{UTypes...}@>&);
+
+ template<@\addedD{class... TTypes, class... UTypes}@>
+ @\addedConcepts{requires LessThanComparable<UTypes, TTypes>...}@
+ bool operator>(const tuple<@\addedD{TTypes...}@>&, const tuple<@\addedD{UTypes...}@>&);
+
+ template<@\addedD{class... TTypes, class... UTypes}@>
+ @\addedConcepts{requires LessThanComparable<UTypes, TTypes>...}@
+ bool operator<=(const tuple<@\addedD{TTypes...}@>&, const tuple<@\addedD{UTypes...}@>&);
+
+ template<@\addedD{class... TTypes, class... UTypes}@>
+ @\addedConcepts{requires LessThanComparable<TTypes, UTypes>...}@
+ bool operator>=(const tuple<@\addedD{TTypes...}@>&, const tuple<@\addedD{UTypes...}@>&);
+
+} // namespace std
+\end{codeblock}
+
+\rSec2[tuple.tuple]{Class template \tcode{tuple}}
+
+\pnum
+\removedD{\mbox{\tcode{M}} denotes the implementation-defined number of template
+type parameters to the tuple class template, and \mbox{\tcode{N}}
+denotes the number of template arguments specified in an instantiation.}
+
+\pnum
+\removedD{\mbox{\enterexample} Given the instantiation
+ \mbox{\tcode{tuple<int, float, char>}}, \mbox{\tcode{N}} is 3. \mbox{\exitexample}}
+
+\index{tuple@\tcode{tuple}}%
+\begin{codeblock}
+template <@\changedConcepts{class}{ObjectType}@... Types>
+class tuple
+{
+public:
+ @\addedConcepts{requires DefaultConstructible<Types>...}@ tuple();
+ @\addedConcepts{requires CopyConstructible<Types>...}@ explicit tuple(@\addedD{const Types\&...}@);
+ @\addedD{template <class... UTypes>}@
+ @\addedConcepts{requires Constructible<Types, UTypes\&\&>...}@
+ @\addedD{explicit tuple(UTypes\&\&...);}@
+
+ @\addedConcepts{requires CopyConstructible<Types>...}@ tuple(const tuple&);
+ @\addedConcepts{requires MoveConstructible<Types>...}@ @\addedD{tuple(tuple\&\&);}@
+
+ template <@\addedD{class... UTypes}@>
+ @\addedConcepts{requires Constructible<Types, UTypes>...}@
+ tuple(const tuple<@\addedD{UTypes...}@>&);
+ @\addedD{template <class... UTypes>}@
+ @\addedConcepts{requires Constructible<Types, UTypes\&\&>...}@
+ @\addedD{tuple(tuple<UTypes...>\&\&);}@
+
+ template <class U1, class U2>
+ tuple(const pair<U1, U2>&); // iff \changedD{N}{\mbox{\tcode{sizeof...(Types) == 2}}}
+ @\addedD{template <class U1, class U2>}@
+ @\addedD{tuple(pair<U1, U2>\&\&);}@ // iff \addedD{\mbox{\tcode{sizeof...(Types) == 2}}}
+
+ @\addedConcepts{requires CopyAssignable<Types>...}@ tuple& operator=(const tuple&);
+ @\addedConcepts{requires MoveAssignable<Types>...}@ @\addedD{tuple\& operator=(tuple\&\&);}@
+
+ template <@\addedD{class... UTypes}@>
+ @\addedConcepts{requires CopyAssignable<Types, UTypes>...}@
+ tuple& operator=(const tuple<@\addedD{UTypes...}@>&);
+ @\addedD{template <class... UTypes>}@
+ @\addedConcepts{requires MoveAssignable<Types, UTypes>...}@
+ @\addedD{tuple\& operator=(tuple<UTypes...>\&\&);}@
+
+ template <class U1, class U2>
+ tuple& operator=(const pair<U1, U2>&); // iff \changedD{N}{\mbox{\tcode{sizeof...(Types) == 2}}}
+ @\addedD{template <class U1, class U2>}@
+ @\addedD{tuple\& operator=(pair<U1, U2>\&\&);}@ // iff \addedD{\mbox{\tcode{sizeof...(Types) == 2}}}
+};
+\end{codeblock}
+
+
+
+
+\rSec3[tuple.cnstr]{Construction}
+
+\index{tuple@\tcode{tuple}!tuple@\tcode{tuple}}%
+\begin{itemdecl}
+@\addedConcepts{requires DefaultConstructible<Types>...}@ tuple();
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{\mbox{\requires} Each type in \mbox{\tcode{Types}} shall be default constructible.}
+
+\pnum
+\effects\ Default initializes each element.
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!tuple@\tcode{tuple}}%
+\begin{itemdecl}
+@\addedConcepts{requires CopyConstructible<Types>...}@ tuple(@\addedD{const Types\&...}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedD{where \mbox{\tcode{Pi}} is \mbox{\tcode{Ti}} if \mbox{\tcode{Ti}}
+is a reference type, or \mbox{\tcode{const Ti\&}} otherwise.}
+
+\pnum
+\removedConcepts{\mbox{\requires} Each type in \mbox{\tcode{Types}}
+shall be copy constructible.}
+
+\pnum
+\effects\ Copy initializes each element with the value of the
+corresponding parameter.
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!tuple@\tcode{tuple}}%
+\begin{itemdecl}
+@\addedD{template <class... UTypes>}@
+ @\addedConcepts{requires Constructible<Types, UTypes\&\&>...}@
+ @\addedD{tuple(UTypes\&\&... u);}@
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{\mbox{\requires} Each type in \mbox{\tcode{Types}} shall be move
+constructible from the corresponding type in \mbox{\tcode{UTypes}}.
+\mbox{\tcode{sizeof...(Types)}} \mbox{\tcode{==}}
+\mbox{\tcode{sizeof...(UTypes)}}.}
+
+\pnum
+\addedD{\mbox{\effects} Initializes the elements in the tuple with the
+corresponding value in \mbox{\tcode{forward<UTypes>(u)}}.}
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!tuple@\tcode{tuple}}%
+\begin{itemdecl}
+@\addedConcepts{requires CopyConstructible<Types>...}@ tuple(const tuple& u);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{\mbox{\requires} Each type in \mbox{\tcode{Types}}
+shall be copy constructible.}
+
+\pnum
+\effects\ Copy constructs each element of \tcode{*this} with the
+corresponding element of \tcode{u}.
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!tuple@\tcode{tuple}}%
+\begin{itemdecl}
+@\addedConcepts{requires MoveConstructible<Types>...}@ @\addedD{tuple(tuple\&\& u);}@
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{\mbox{\requires} Each type in \mbox{\tcode{Types}} shall be
+move constructible.}
+
+\pnum
+\addedD{\mbox{\effects} Move-constructs each element of \mbox{\tcode{*this}}
+with the corresponding element of \mbox{\tcode{u}}.}
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!tuple@\tcode{tuple}}%
+\begin{itemdecl}
+template <@\addedD{class... UTypes}@>
+ @\addedConcepts{requires Constructible<Types, UTypes>...}@
+ tuple(const tuple<@\addedD{UTypes...}@>& u);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{\mbox{\requires} Each type in \mbox{\tcode{Types}}
+shall be constructible from the corresponding type
+in \mbox{\tcode{UTypes}}.
+\mbox{\tcode{sizeof...(Types)}} \mbox{\tcode{==}}
+\mbox{\tcode{sizeof...(UTypes)}}.}
+
+\pnum\effects\ Constructs each element of \tcode{*this} with the corresponding
+element of \tcode{u}.
+
+\pnum
+\enternote\ \removedD{In an implementation where one template definition
+ serves for many different values for \mbox{\tcode{N}},}
+ \tcode{enable_if} can be used to
+ make the converting constructor and assignment operator exist only
+ in the cases where the source and target have the same number of
+ elements.\removedD{ Another way of achieving this is adding an extra integral
+ template parameter which defaults to \mbox{\tcode{N}} (more precisely, a
+ metafunction that computes \mbox{\tcode{N}}), and then defining the converting
+ copy constructor and assignment only for tuples where the extra
+ parameter in the source is \mbox{\tcode{N}}.} \exitnote\
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!tuple@\tcode{tuple}}%
+\begin{itemdecl}
+template <class... UTypes>
+ @\addedConcepts{requires Constructible<Types, UTypes\&\&>...}@
+ tuple(tuple<UTypes...>&& u);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{\mbox{\requires} Each type in \mbox{\tcode{Types}} shall be
+move-constructible from the corresponding type in \mbox{\tcode{UTypes}}.
+\mbox{\tcode{sizeof...(Types)}} \mbox{\tcode{==}}
+\mbox{\tcode{sizeof...(UTypes)}}.}
+
+\pnum
+\addedD{\mbox{\effects} Move-constructs each element of \mbox{\tcode{*this}}
+with the corresponding element of \mbox{\tcode{u}}.}
+
+\addedD{\mbox{\enternote} \mbox{\tcode{enable_if}} can be used to make the
+converting constructor and assignment operator exist only in the cases where
+the source and target have the same number of elements. \mbox{\exitnote}}
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!tuple@\tcode{tuple}}%
+\index{pair@\tcode{pair}}%
+\begin{itemdecl}
+template <class U1, class U2> tuple(const pair<U1, U2>& u);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\requires\ \changedD{\mbox{\tcode{T1}}}{The first type in \mbox{\tcode{Types}}}
+shall be constructible from \tcode{U1} and
+\changedD{\mbox{\tcode{T2}}}{the second type in \mbox{\tcode{Types}}}
+shall be constructible from \tcode{U2}.
+\changedD{\mbox{\tcode{N == 2}}}{\mbox{\tcode{sizeof...(Types) == 2}}}.
+
+\pnum
+\effects\ Constructs the first element with \tcode{u.first} and the
+second element with \tcode{u.second}.
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!tuple@\tcode{tuple}}%
+\index{pair@\tcode{pair}}%
+\begin{itemdecl}
+@\addedD{template <class U1, class U2> tuple(pair<U1, U2>\&\& u);}@
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedD{\mbox{\requires} The first type in \mbox{\tcode{Types}} shall be
+move constructible from \mbox{\tcode{U1}} and the second type in
+\mbox{\tcode{Types}} shall be move-constructible from \mbox{\tcode{U2}}.
+\mbox{\tcode{sizeof...(Types) == 2}}.}
+
+\pnum
+\addedD{\mbox{\effects} Constructs the first element with
+\mbox{\tcode{move(u.first)}} and the
+second element with \mbox{\tcode{move(u.second)}}.}
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!operator=@\tcode{operator=}}%
+\index{operator=@\tcode{operator=}!tuple@\tcode{tuple}}%
+\begin{itemdecl}
+@\addedConcepts{requires CopyAssignable<Types>...}@ tuple& operator=(const tuple& u);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{\mbox{\requires} Each type in \mbox{\tcode{Types}}
+shall be assignable.}
+
+\pnum
+\effects\ Assigns each element of \tcode{u} to the corresponding
+element of \tcode{*this}.
+
+\pnum
+\returns\ \tcode{*this}
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!operator=@\tcode{operator=}}%
+\index{operator=@\tcode{operator=}!tuple@\tcode{tuple}}%
+\begin{itemdecl}
+@\addedConcepts{requires MoveAssignable<Types>...}@ @\addedD{tuple\& operator=(tuple\&\& u);}@
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{\mbox{\requires} Each type in \mbox{\tcode{Types}} shall be
+move-assignable.}
+
+\pnum
+\addedD{\mbox{\effects} Move-assigns each element of \mbox{\tcode{u}} to
+the corresponding element of \mbox{\tcode{*this}}.}
+
+\pnum
+\addedD{\mbox{\returns} \mbox{\tcode{*this}}.}
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!operator=@\tcode{operator=}}%
+\index{operator=@\tcode{operator=}!tuple@\tcode{tuple}}%
+\begin{itemdecl}
+template <@\addedD{class... UTypes}@>
+ @\addedConcepts{requires CopyAssignable<Types, UTypes>...}@
+ tuple& operator=(const tuple<@\addedD{UTypes...}@>& u);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{\mbox{\requires} Each type in \mbox{\tcode{Types}}
+shall be assignable from the corresponding type
+in \mbox{\tcode{UTypes}}}.
+
+\pnum
+\effects\ Assigns each element of \tcode{u} to the corresponding element
+of \tcode{*this}.
+
+\pnum
+\returns\ \tcode{*this}
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!operator=@\tcode{operator=}}%
+\index{operator=@\tcode{operator=}!tuple@\tcode{tuple}}%
+\begin{itemdecl}
+@\addedD{template <class... UTypes>}@
+ @\addedConcepts{requires MoveAssignable<Types, UTypes>...}@
+ @\addedD{tuple\& operator=(tuple<UTypes...>\&\& u);}@
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{\mbox{\requires} Each type in \mbox{\tcode{Types}} shall be
+move-assignable from the corresponding type in \mbox{\tcode{UTypes}}.
+\mbox{\tcode{sizeof...(Types)}} \mbox{\tcode{==}}
+\mbox{\tcode{sizeof...(UTypes)}}.}
+
+\pnum
+\addedD{\mbox{\effects} Move-assigns each element of \mbox{\tcode{u}}
+to the corresponding element of \mbox{\tcode{*this}}.}
+
+\pnum
+\addedD{\mbox{\returns} \mbox{\tcode{*this}}.}
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!operator=@\tcode{operator=}}%
+\index{operator=@\tcode{operator=}!tuple@\tcode{tuple}}%
+\index{pair@\tcode{pair}}%
+\begin{itemdecl}
+template <class U1, class U2> tuple& operator=(const pair<U1, U2>& u);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\requires\ \changedD{\mbox{\tcode{T1}}}{The first type in
+\mbox{\tcode{Types}}} shall be move assignable from \tcode{U1} and
+\changedD{\mbox{\tcode{T2}}}{the second type in \mbox{\tcode{Types}}}
+shall be move assignable from \tcode{U2}.
+\changedD{\mbox{\tcode{N == 2}}}{\mbox{\tcode{sizeof...(Types) == 2}}}.
+
+\pnum
+\effects\ Assigns \tcode{u.first} to the first element of \tcode{*this}
+and \tcode{u.second} to the second element of \tcode{*this}.
+
+\pnum
+\returns\ \tcode{*this}
+
+\pnum
+\enternote\ There are rare conditions where the
+ converting copy constructor is a better match than the element-wise
+ construction, even though the user might intend differently. An
+ example of this is if one is constructing a one-element tuple where
+ the element type is another tuple type \tcode{T} and if the parameter
+ passed to the constructor is not of type \tcode{T}, but rather a tuple
+ type that is convertible to \tcode{T}. The effect of the converting copy
+ construction is most likely the same as the effect of the
+ element-wise construction would have been. However, it it possible
+ to compare the ``nesting depths'' of the source and target tuples and
+ decide to select the element-wise constructor if the source nesting
+ depth is smaller than the target nesting-depth. This can be
+ accomplished using an \tcode{enable_if} template or other tools for
+ constrained templates.
+\exitnote\
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!operator=@\tcode{operator=}}%
+\index{operator=@\tcode{operator=}!tuple@\tcode{tuple}}%
+\index{pair@\tcode{pair}}%
+\begin{itemdecl}
+@\addedD{template <class U1, class U2> tuple\& operator=(pair<U1, U2>\&\& u);}@
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedD{\mbox{\requires} The first type in \mbox{\tcode{Types}} shall be
+assignable from \mbox{\tcode{U1}} and the second type in \mbox{\tcode{Types}}
+shall be assignable from \mbox{\tcode{U2}}. \mbox{\tcode{sizeof...(Types) == 2}}.}
+
+\pnum
+\addedD{\mbox{\effects} Assigns \mbox{\tcode{move(u.first)}} to the first
+element of \mbox{\tcode{*this}} and \mbox{\tcode{move(u.second)}} to the
+second element of \mbox{\tcode{*this}}.}
+
+\pnum
+\addedD{\mbox{\returns} \mbox{\tcode{*this}}.}
+\end{itemdescr}
+
+\rSec3[tuple.creation]{Tuple creation functions}
+
+\index{make_tuple@\tcode{make_tuple}}%
+\index{tuple@\tcode{tuple}!make_tuple@\tcode{make_tuple}}%
+\begin{itemdecl}
+template<@\changedConcepts{class}{MoveConstructible}@... Types>
+ tuple<VTypes...> make_tuple(Types&&... t);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\changedD{where \mbox{\tcode{Vi}} is \mbox{\tcode{X\&}} if
+the cv-unqualified type \mbox{\tcode{Ti}} is
+\mbox{\tcode{reference\_wrapper<X>}}, otherwise \mbox{\tcode{Vi}} is \mbox{\tcode{Ti}}.}
+{where each \mbox{\tcode{Vi}} in \mbox{\tcode{VTypes}} is \mbox{\tcode{X\&}}
+if, for the corresponding type \mbox{\tcode{Ti}} in \mbox{\tcode{Types}},
+\mbox{\tcode{remove_cv<remove_reference<Ti>::type>::type}} equals
+\mbox{\tcode{reference_wrapper<X>}}, otherwise \mbox{\tcode{Vi}} is
+\mbox{\tcode{decay<Ti>::type}}.}
+
+\pnum
+\removedD{The \mbox{\tcode{make\_tuple}} function template shall be implemented for
+each different number of arguments from 0 to the maximum number of
+allowed tuple elements.}
+
+\pnum
+\returns\ \changedD{\mbox{\tcode{tuple<V1, V2, ..., VN>(t1, t2, ..., tn)}}}
+{\mbox{\tcode{tuple<VTypes...>(forward<Types>(t)...)}}.}
+
+\pnum
+\enterexample\
+
+\begin{codeblock}
+int i; float j;
+make_tuple(1, ref(i), cref(j))
+\end{codeblock}
+
+creates a tuple of type
+
+\begin{codeblock}
+tuple<int, int&, const float&>
+\end{codeblock}
+
+\exitexample\
+
+\end{itemdescr}
+
+\index{tie@\tcode{tie}}%
+\index{tuple@\tcode{tuple}!tie@\tcode{tie}}%
+\begin{itemdecl}
+template<@\changedConcepts{class}{ObjectType}@... Types>
+ tuple<@\addedD{Types\&...}@> tie(@\addedD{Types\&... t}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedD{The \mbox{\tcode{tie}} function template shall be implemented for each
+different number of arguments from 0 to the maximum number of allowed
+tuple elements.}
+
+\pnum
+\returns\ \tcode{tuple<\addedD{Types\&}>(\addedD{t...})}. When an
+argument \changedD{ti}{in \mbox{\tcode{t}}} is \tcode{ignore}, assigning
+any value to the corresponding tuple element has no effect.
+
+\pnum
+\enterexample\
+\tcode{tie} functions allow one to create tuples that unpack
+tuples into variables. \tcode{ignore} can be used for elements that
+are not needed:
+\begin{codeblock}
+int i; std::string s;
+tie(i, ignore, s) = make_tuple(42, 3.14, "C++");
+// \tcode{i == 42}, \tcode{s == "C++"}
+\end{codeblock}
+\exitexample\
+\end{itemdescr}
+
+\rSec3[tuple.helper]{Tuple helper classes}
+\setcounter{Paras}{3}
+\index{tuple_element@\tcode{tuple_element}}%
+\begin{itemdecl}
+@\addedD{template <int I, class... Types>}@
+@\addedConcepts{requires True<0 <= I \&\& I < sizeof...(Types)>}@
+@\addedD{class tuple_element<I, tuple<Types...> > \{}@
+@\addedD{public:}@
+ @\addedD{typedef TI type;}@
+@\addedD{\};}@
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{\mbox{\requires} \mbox{\addedD{\mbox{\tcode{0 <= I}} and \mbox{\tcode{I < sizeof...(Types)}}.}}
+The program is ill-formed if \mbox{\tcode{I}} is out of bounds.}
+
+\pnum
+\changedD{\mbox{\tcode{Value}}: The}{\mbox{\ctype} \mbox{\tcode{TI}} is the}
+type of the \tcode{I}th element of \changedD{\mbox{\tcode{T}}}{\mbox{\tcode{Types}}},
+where indexing is zero-based.
+\end{itemdescr}
+
+
+\rSec3[tuple.elem]{Element access}
+
+\index{tuple@\tcode{tuple}!get@\tcode{get}}%
+\index{get@\tcode{get}!tuple@\tcode{tuple}}%
+\begin{itemdecl}
+template <int I, @\changedConcepts{class}{ObjectType}@... Types>
+ @\addedConcepts{requires True<0 <= I \&\& I < sizeof...(Types)>}@
+ @\addedD{typename tuple_element<I, tuple<Types...> >::type\& get(tuple<Types...>\& t);}@
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{\mbox{\requires} \mbox{\addedD{\mbox{\tcode{0 <= I}} and \mbox{\tcode{I < sizeof...(Types)}}.}}
+The program is ill-formed if \mbox{\tcode{I}} is out of bounds.}
+
+\pnum
+\removedD{\mbox{\returntype} \mbox{\tcode{RJ}}, where \mbox{\tcode{J=I+1}}.
+If \mbox{\tcode{TJ}} is a
+reference type, then \mbox{\tcode{RJ}}
+is \mbox{\tcode{TJ}}, otherwise \mbox{\tcode{RJ}} is \mbox{\tcode{TJ\&}}.}
+
+\pnum
+\returns\ A reference to the \tcode{I}th element of \tcode{t}, where
+indexing is zero-based.
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!get@\tcode{get}}%
+\index{get@\tcode{get}!tuple@\tcode{tuple}}%
+\begin{itemdecl}
+template <int I, @\changedConcepts{class}{ObjectType}@... Types>
+ @\addedConcepts{requires True<0 <= I \&\& I < sizeof...(Types)>}@
+ @\addedD{typename tuple_element<I, tuple<Types...> >::type const\& get(const tuple<Types...>\& t);}@
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{\mbox{\requires} \mbox{\addedD{\mbox{\tcode{0 <= I}} and \mbox{\tcode{I < sizeof...(Types)}}.}}
+The program is ill-formed if \mbox{\tcode{I}} is out of bounds.}
+
+\pnum
+\removedD{\mbox{\returntype} \mbox{\tcode{PJ}}, where \mbox{\tcode{J=I+1}}.
+If \mbox{\tcode{TJ}} is a
+reference type, then \mbox{\tcode{PJ}}
+is \mbox{\tcode{TJ}}, otherwise \mbox{\tcode{PJ}} is \mbox{\tcode{const TJ\&}}.}
+
+\pnum
+\returns\ A const reference to the \tcode{I}th element of \tcode{t}, where
+indexing is zero-based.
+
+\pnum
+\enternote\ Constness is shallow. If \changedD{\mbox{\tcode{TJ}}}{a \mbox{\tcode{T}}
+in \mbox{\tcode{Types}}} is some
+reference type \tcode{X\&}, the return type is \tcode{X\&}, not \tcode{const X\&}.
+However, if the element type is non-reference type \tcode{T}, the return
+type is \tcode{const T\&}.
+This is consistent with how constness is defined to work
+for member variables of reference type. \exitnote]
+
+\pnum
+\enternote\ The reason \tcode{get} is a
+nonmember function is that if this functionality had been
+provided as a member function, code where the type
+depended on a template parameter would have required using
+the \tcode{template} keyword. \exitnote\
+\end{itemdescr}
+
+\rSec3[tuple.rel]{Relational operators}
+
+\index{tuple@\tcode{tuple}!operator==@\tcode{operator==}}%
+\index{operator==@\tcode{operator==}!tuple@\tcode{tuple}}%
+\begin{itemdecl}
+template<@\addedD{class... TTypes, class... UTypes}@>
+ @\addedConcepts{requires EqualityComparable<TTypes, UTypes>...}@
+ bool operator==(const tuple<@\addedD{TTypes...}@>& t, const tuple<@\addedD{UTypes...}@>& u);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{\mbox{\requires} For all \mbox{\tcode{i}},
+where \mbox{\tcode{0 <= i}} and
+\mbox{\tcode{i < sizeof...(Types)}}, \mbox{\tcode{get<i>(t) == get<i>(u)}} is a valid expression
+returning a type that is convertible to \mbox{\tcode{bool}}.
+\mbox{\tcode{sizeof...(TTypes)}} \mbox{\tcode{==}}
+\mbox{\tcode{sizeof...(UTypes)}}.}
+
+\pnum
+\returns\ \tcode{true} iff \tcode{get<i>(t) == get<i>(u)} for all \tcode{i}.
+For any two zero-length tuples \tcode{e} and \tcode{f}, \tcode{e == f} returns \tcode{true}.
+
+\pnum
+\effects\ The elementary comparisons are performed in order from the
+zeroth index upwards. No comparisons or element accesses are
+performed after the first equality comparison that evaluates to
+\tcode{false}.
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!operator<@\tcode{operator<}}%
+\index{operator<@\tcode{operator<}!tuple@\tcode{tuple}}%
+\begin{itemdecl}
+template<@\addedD{class... TTypes, class... UTypes}@>
+ @\addedConcepts{requires LessThanComparable<TTypes, UTypes>...}@
+ bool operator<(const tuple<@\addedD{TTypes...}@>& t, const tuple<@\addedD{UTypes...}@>& u);
+\end{itemdecl}
+
+\begin{itemdescr}
+\removedConcepts{\mbox{\requires} For all \mbox{\tcode{i}},
+where \mbox{\tcode{0 <= i}} and
+\mbox{\tcode{i < sizeof...(Types)}}, \mbox{\tcode{get<i>(t) == get<i>(u)}} is a valid expression
+returning a type that is convertible to \mbox{\tcode{bool}}.
+\mbox{\tcode{sizeof...(TTypes)}} \mbox{\tcode{==}}
+\mbox{\tcode{sizeof...(UTypes)}}.}
+
+\pnum\returns\ The result of a lexicographical comparison
+between \tcode{t} and \tcode{u}. The result is defined
+as: \tcode{(bool)(get<0>(t) < get<0>(u)) ||
+(!(bool)(get<0>(u) < get<0>(t)) \&\& t$_{\mathrm{tail}}$ <
+u$_{\mathrm{tail}}$)}, where \tcode{r$_{\mathrm{tail}}$} for some
+tuple \tcode{r} is a tuple containing all but the first element
+of \tcode{r}. For any two zero-length tuples \tcode{e}
+and \tcode{f}, \tcode{e < f} returns \tcode{false}.
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!operator"!=@\tcode{operator"!=}}%
+\index{operator"!=@\tcode{operator"!=}!tuple@\tcode{tuple}}%
+\begin{itemdecl}
+template<@\addedD{class... TTypes, class... UTypes}@>
+ @\addedConcepts{requires EqualityComparable<TTypes, UTypes>...}@
+ bool operator!=(const tuple<@\addedD{TTypes...}@>& t, const tuple<@\addedD{UTypes...}@>& u);
+\end{itemdecl}
+\begin{itemdescr}
+\pnum\returns\ \tcode{!(t == u)}.
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!operator>@\tcode{operator>}}%
+\index{operator>@\tcode{operator>}!tuple@\tcode{tuple}}%
+\begin{itemdecl}
+template<@\addedD{class... TTypes, class... UTypes}@>
+ @\addedConcepts{requires LessThanComparable<UTypes, TTypes>...}@
+ bool operator>(const tuple<@\addedD{TTypes...}@>& t, const tuple<@\addedD{UTypes...}@>& u);
+\end{itemdecl}
+\begin{itemdescr}
+\pnum\returns\ \tcode{u < t}.
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!operator<=@\tcode{operator<=}}%
+\index{operator<=@\tcode{operator<=}!tuple@\tcode{tuple}}%
+\begin{itemdecl}
+template<@\addedD{class... TTypes, class... UTypes}@>
+ @\addedConcepts{requires LessThanComparable<UTypes, TTypes>...}@
+ bool operator<=(const tuple<@\addedD{TTypes...}@>& t, const tuple<@\addedD{UTypes...}@>& u);
+\end{itemdecl}
+\begin{itemdescr}
+\pnum\returns\ \tcode{!(u < t)}
+\end{itemdescr}
+
+\index{tuple@\tcode{tuple}!operator>=@\tcode{operator>=}}%
+\index{operator>=@\tcode{operator>=}!tuple@\tcode{tuple}}%
+\begin{itemdecl}
+template<@\addedD{class... TTypes, class... UTypes}@>
+ @\addedConcepts{requires LessThanComparable<TTypes, UTypes>...}@
+ bool operator>=(const tuple<@\addedD{TTypes...}@>& t, const tuple<@\addedD{UTypes...}@>& u);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum\returns\ \tcode{!(t < u)}
+\end{itemdescr}
+
+\pnum \enternote\ The above definitions for comparison operators
+do not require \tcode{t$_{\mathrm{tail}}$}
+(or \tcode{u$_{\mathrm{tail}}$}) to be constructed. It may not
+even be possible, as \tcode{t} and \tcode{u} are not required to be copy
+constructible. Also, all comparison operators are short circuited;
+they do not perform element accesses beyond what is required to determine the
+result of the comparison. \exitnote\
+
+\setcounter{section}{4}
+\rSec1[function.objects]{Function objects}
+
+\pnum
+Function objects are objects with an \tcode{operator()} defined.
+In the places where one would expect to pass a pointer to a function to an
+algorithmic template (clause \ref{algorithms}), the interface is specified to accept an object with an
+\tcode{operator()}
+defined.
+This not only makes algorithmic templates work with pointers to functions, but
+also enables them to work with arbitrary function objects.
+
+\pnum
+\synopsis{Header \tcode{<functional>} synopsis}
+\index{functional@\tcode{<functional>}}%
+
+\begin{codeblock}
+namespace std {
+ // \ref{base}, base:
+ template <class Arg, class Result> struct unary_function;
+ template <class Arg1, class Arg2, class Result> struct binary_function;
+
+ // \marktr{}\ref{func.ret} result_of:
+ template <class@\removedD{ FunctionCallType}@> class result_of; // \addedD{undefined}
+ @\addedD{template <class F, class... Args> class result_of<F(ArgTypes...)>;}@
+
+ // \marktr{}\ref{refwrap}, reference_wrapper:
+ template <@\changedConcepts{class}{ObjectType}@ T> class reference_wrapper;
+
+ template <@\changedConcepts{class}{ObjectType}@ T> reference_wrapper<T> ref(T&);
+ template <@\changedConcepts{class}{ObjectType}@ T> reference_wrapper<const T> cref(const T&);
+
+ template <@\changedConcepts{class}{ObjectType}@ T> reference_wrapper<T> ref(reference_wrapper<T>);
+ template <@\changedConcepts{class}{ObjectType}@ T> reference_wrapper<const T> cref(reference_wrapper<T>);
+
+ // \ref{arithmetic.operations}, arithmetic operations:
+ template <class T> struct plus;
+ template <class T> struct minus;
+ template <class T> struct multiplies;
+ template <class T> struct divides;
+ template <class T> struct modulus;
+ template <class T> struct negate;
+
+ // \ref{comparisons}, comparisons:
+ template <class T> struct equal_to;
+ template <class T> struct not_equal_to;
+ template <class T> struct greater;
+ template <class T> struct less;
+ template <class T> struct greater_equal;
+ template <class T> struct less_equal;
+
+ // \ref{logical.operations}, logical operations:
+ template <class T> struct logical_and;
+ template <class T> struct logical_or;
+ template <class T> struct logical_not;
+
+ // \ref{negators}, negators:
+ template <class Predicate> class unary_negate;
+ template <class Predicate>
+ unary_negate<Predicate> not1(const Predicate&);
+ template <class Predicate> class binary_negate;
+ template <class Predicate>
+ binary_negate<Predicate> not2(const Predicate&);
+
+ // \ref{bind}, bind:
+ template<class T> struct is_bind_expression;
+ template<class T> struct is_placeholder;
+
+ template<@\changedConcepts{class}{CopyConstructible}@ Fn, @\changedConcepts{class}{CopyConstructible}@... Types>
+ @\unspec@ bind(Fn, @\addedD{Types...}@);
+ template<@\changedConcepts{class}{MoveConstructible}@ R, @\changedConcepts{class}{CopyConstructible}@ Fn, @\changedConcepts{class}{CopyConstructible}@... Types>
+ @\unspec@ bind(Fn, @\addedD{Types...}@);
+
+ namespace placeholders {
+ // M is the implementation-defined number of placeholders
+ extern @\unspec@ _1;
+ extern @\unspec@ _2;
+ .
+ .
+ .
+ extern @\unspec@ _M;
+ }
+
+ // \ref{depr.lib.binders}, binders (deprecated):
+ template <class Fn> class binder1st;
+ template <class Fn, class T>
+ binder1st<Fn> bind1st(const Fn&, const T&);
+ template <class Fn> class binder2nd;
+ template <class Fn, class T>
+ binder2nd<Fn> bind2nd(const Fn&, const T&);
+
+ // \ref{function.pointer.adaptors}, adaptors:
+ template <@\changedConcepts{class}{MoveConstructible}@ Arg, @\changedConcepts{class}{MoveConstructible}@ Result>
+ class pointer_to_unary_function;
+ template <@\changedConcepts{class}{MoveConstructible}@ Arg, @\changedConcepts{class}{MoveConstructible}@ Result>
+ pointer_to_unary_function<Arg,Result> ptr_fun(Result (*)(Arg));
+ template <@\changedConcepts{class}{MoveConstructible}@ Arg1, @\changedConcepts{class}{MoveConstructible}@ Arg2, @\changedConcepts{class}{MoveConstructible}@ Result>
+ class pointer_to_binary_function;
+ template <@\changedConcepts{class}{MoveConstructible}@ Arg1, @\changedConcepts{class}{MoveConstructible}@ Arg2, @\changedConcepts{class}{MoveConstructible}@ Result>
+ pointer_to_binary_function<Arg1,Arg2,Result>
+ ptr_fun(Result (*)(Arg1,Arg2));
+
+ // \ref{member.pointer.adaptors}, adaptors:
+ template<@\changedConcepts{class}{MoveConstructible}@ S, class T> class mem_fun_t;
+ template<@\changedConcepts{class}{MoveConstructible}@ S, class T, @\changedConcepts{class}{MoveConstructible}@ A> class mem_fun1_t;
+ template<@\changedConcepts{class}{MoveConstructible}@ S, class T>
+ mem_fun_t<S,T> mem_fun(S (T::*f)());
+ template<@\changedConcepts{class}{MoveConstructible}@ S, class T, @\changedConcepts{class}{MoveConstructible}@ A>
+ mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A));
+ template<@\changedConcepts{class}{MoveConstructible}@ S, class T> class mem_fun_ref_t;
+ template<@\changedConcepts{class}{MoveConstructible}@ S, class T, @\changedConcepts{class}{MoveConstructible}@ A> class mem_fun1_ref_t;
+ template<@\changedConcepts{class}{MoveConstructible}@ S, class T>
+ mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)());
+ template<@\changedConcepts{class}{MoveConstructible}@ S, class T, @\changedConcepts{class}{MoveConstructible}@ A>
+ mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A));
+
+ template <@\changedConcepts{class}{MoveConstructible}@ S, class T> class const_mem_fun_t;
+ template <@\changedConcepts{class}{MoveConstructible}@ S, class T, @\changedConcepts{class}{MoveConstructible}@ A> class const_mem_fun1_t;
+ template <@\changedConcepts{class}{MoveConstructible}@ S, class T>
+ const_mem_fun_t<S,T> mem_fun(S (T::*f)() const);
+ template <@\changedConcepts{class}{MoveConstructible}@ S, class T, @\changedConcepts{class}{MoveConstructible}@ A>
+ const_mem_fun1_t<S,T,A> mem_fun(S (T::*f)(A) const);
+ template <@\changedConcepts{class}{MoveConstructible}@ S, class T> class const_mem_fun_ref_t;
+ template <@\changedConcepts{class}{MoveConstructible}@ S, class T, @\changedConcepts{class}{MoveConstructible}@ A> class const_mem_fun1_ref_t;
+ template <@\changedConcepts{class}{MoveConstructible}@ S, class T>
+ const_mem_fun_ref_t<S,T> mem_fun_ref(S (T::*f)() const);
+ template <@\changedConcepts{class}{MoveConstructible}@ S, class T, @\changedConcepts{class}{MoveConstructible}@ A>
+ const_mem_fun1_ref_t<S,T,A> mem_fun_ref(S (T::*f)(A) const);
+
+ // \marktr{}\ref{func.memfn}, member function adaptors:
+ template<@\changedConcepts{class}{ObjectType}@ R, class T> @\textit{unspecified}@ mem_fn(R T::*);
+ @\addedConcepts{template<MoveConstructible R, class T, MoveConstructible... Args>}@
+ @\addedConcepts{\textit{unspecified} mem_fn(R (T::*)(Args...) pm);}@
+ @\addedConcepts{template<MoveConstructible R, class T, MoveConstructible... Args>}@
+ @\addedConcepts{\textit{unspecified} mem_fn(R (T::* const)(Args...) pm);}@
+ @\addedConcepts{template<MoveConstructible R, class T, MoveConstructible... Args>}@
+ @\addedConcepts{\textit{unspecified} mem_fn(R (T::* volatile)(Args...) pm);}@
+ @\addedConcepts{template<MoveConstructible R, class T, MoveConstructible... Args>}@
+ @\addedConcepts{\textit{unspecified} mem_fn(R (T::* const volatile)(Args...) pm);}@
+
+ // \marktr{}\ref{func.wrap} polymorphic function wrappers:
+ class bad_function_call;
+
+ template<class@\removedD{ Function}@> class function; // \addedD{undefined}
+ @\addedD{template<\changedConcepts{class}{MoveConstructible} R, \changedConcepts{class}{MoveConstructible}... ArgTypes>}@
+ class function<R(ArgTypes...)>;
+
+ template<@\addedD{\changedConcepts{class}{MoveConstructible} R, \changedConcepts{class}{MoveConstructible}... ArgTypes}@>
+ void swap(function<@\addedD{R(ArgTypes...)}@>&, function<@\addedD{R(ArgTypes...)}@>&);
+
+ template<@\addedD{class R1, class R2, class... ArgTypes1, class... ArgTypes2}@>
+ void operator==(const function<@\addedD{R1(ArgTypes1...)}@>&, const function<@\addedD{R2(ArgTypes2...)}@>&);
+ template<@\addedD{class R1, class R2, class... ArgTypes1, class... ArgTypes2}@>
+ void operator!=(const function<@\addedD{R1(ArgTypes1...)}@>&, const function<@\addedD{R2(ArgTypes2...)}@>&);
+
+ template<@\addedD{\changedConcepts{class}{MoveConstructible} R, \changedConcepts{class}{MoveConstructible}... ArgTypes}@>
+ bool operator==(const function<@\addedD{R(ArgTypes...)}@>&, @\unspecnull@);
+ template<@\addedD{\changedConcepts{class}{MoveConstructible} R, \changedConcepts{class}{MoveConstructible}... ArgTypes}@>
+ bool operator==(@\unspecnull@, const function<@\addedD{R(ArgTypes...)}@>&);
+ template<@\addedD{\changedConcepts{class}{MoveConstructible} R, \changedConcepts{class}{MoveConstructible}... ArgTypes}@>
+ bool operator!=(const function<@\addedD{R(ArgTypes...)}@>&, @\unspecnull@);
+ template<@\addedD{\changedConcepts{class}{MoveConstructible} R, \changedConcepts{class}{MoveConstructible}... ArgTypes}@>
+ bool operator!=(@\unspecnull@, const function<@\addedD{R(ArgTypes...)}@>&);
+
+ // \marktr{}\ref{unord.hash}, hash function base template:
+ template <class T> struct hash;
+
+ // Hash function specializations
+ template <> struct hash<bool>;
+ template <> struct hash<char>;
+ template <> struct hash<signed char>;
+ template <> struct hash<unsigned char>;
+ @\addedD{template <> struct hash<char16_t>;}@
+ @\addedD{template <> struct hash<char32_t>;}@
+ template <> struct hash<wchar_t>;
+ template <> struct hash<short>;
+ template <> struct hash<unsigned short>;
+ template <> struct hash<int>;
+ template <> struct hash<unsigned int>;
+ template <> struct hash<long>;
+ @\addedC{template <> struct hash<long long>;}@
+ template <> struct hash<unsigned long>;
+ @\addedC{template <> struct hash<unsigned long long>;}@
+
+ template <> struct hash<float>;
+ template <> struct hash<double>;
+ template <> struct hash<long double>;
+
+ template<class T> struct hash<T*>;
+
+ template <> struct hash<std::string>;
+ @\addedD{template <> struct hash<std::u16string>;}@
+ @\addedD{template <> struct hash<std::u32string>;}@
+ template <> struct hash<std::wstring>;
+}
+\end{codeblock}
+
+\setcounter{subsection}{4}
+\rSec2[refwrap]{\marktr{}Class template \tcode{reference_wrapper}}
+
+\index{reference_wrapper@\tcode{reference_wrapper}}
+\index{function objects!reference_wrapper@\tcode{reference_wrapper}}
+\index{unary function}
+\index{binary function}
+\begin{codeblock}
+template <@\changedConcepts{class}{ObjectType}@ T> class reference_wrapper
+ : public unary_function<T1, R> // see below
+ : public binary_function<T1, T2, R> // see below
+{
+public :
+ // types
+ typedef T type;
+ typedef @\textit{see below}@ result_type; // Not always defined
+
+ // construct/copy/destroy
+ explicit reference_wrapper(T&);
+ reference_wrapper(const reference_wrapper<T>& x);
+
+ // assignment
+ reference_wrapper& operator=(const reference_wrapper<T>& x);
+
+ // access
+ operator T& () const;
+ T& get() const;
+
+ // tcode{}
+ template <@\changedD{class T1, class T2, ..., class TN}{class... ArgTypes}@>
+ @\addedConcepts{requires Callable<T, ArgTypes\&\&...>}@
+ @\changedConcepts{typename result_of<T(ArgTypes...)>::type}{Callable<T, ArgTypes\&\&...>::result_type}@
+ operator() (ArgTypes&&...) const;
+};
+\end{codeblock}
+
+\setcounter{subsubsection}{3}
+\rSec3[refwrap.invoke]{\tcode{reference_wrapper} invocation}
+\index{reference_wrapper@\tcode{reference_wrapper}!operator()@\tcode{operator()}}%
+\index{operator()@\tcode{operator()}!reference_wrapper@\tcode{reference_wrapper}}%
+\begin{itemdecl}
+template <@\changedD{class T1, class T2, ..., class TN}{class... ArgTypes}@>
+ @\addedConcepts{requires Callable<T, ArgTypes\&\&...>}@
+ @\changedConcepts{typename result_of<T(ArgTypes...)>::type}{Callable<T, ArgTypes\&\&...>::result_type}@
+ operator()(@\changedD{T1\& a1, T2\& a1, ..., TN\& aN}{ArgTypes\&\&... args}@) const;
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum\returns\ \tcode{\textit{INVOKE}(get(), \changedD{a1, a2, ..., aN}{forward<ArgTypes>(args)...})}.
+(\ref{func.require})
+
+\pnum\note\ \tcode{operator()} is described for exposition only.
+Implementations are not required to provide an actual
+\tcode{reference_wrapper::operator()}. Implementations are
+permitted to support \tcode{reference_wrapper} function invocation
+through multiple overloaded operators or through other means.
+
+\end{itemdescr}
+
+\rSec3[refwrap.helpers]{reference_wrapper helper functions}
+\index{reference_wrapper@\tcode{reference_wrapper}!ref@\tcode{ref}}%
+\index{ref@\tcode{ref}!reference_wrapper@\tcode{reference_wrapper}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{ObjectType}@ T> reference_wrapper<T> ref(T& t);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum\returns\ \tcode{reference_wrapper<T>(t)}
+
+\pnum\throws\ nothing.
+\end{itemdescr}
+
+\index{reference_wrapper@\tcode{reference_wrapper}!ref@\tcode{ref}}%
+\index{ref@\tcode{ref}!reference_wrapper@\tcode{reference_wrapper}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{ObjectType}@ T> reference_wrapper<T> ref(reference_wrapper<T>t);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum\returns\ \tcode{ref(t.get())}
+
+\pnum\throws\ nothing.
+\end{itemdescr}
+
+\index{reference_wrapper@\tcode{reference_wrapper}!cref@\tcode{cref}}%
+\index{cref@\tcode{cref}!reference_wrapper@\tcode{reference_wrapper}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{ObjectType}@ T> reference_wrapper<const T> cref(const T& t);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum\returns\ \tcode{reference_wrapper <const T>(t)}
+
+\pnum\throws\ nothing.
+\end{itemdescr}
+
+\index{reference_wrapper@\tcode{reference_wrapper}!cref@\tcode{cref}}%
+\index{cref@\tcode{cref}!reference_wrapper@\tcode{reference_wrapper}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{ObjectType}@ T> reference_wrapper<const T> cref(reference_wrapper<T> t);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum\returns\ \tcode{cref(t.get());}
+
+\pnum\throws\ nothing.
+\end{itemdescr}
+
+\rSec2[arithmetic.operations]{Arithmetic operations}
+
+\pnum
+The library provides basic function object classes for all of the arithmetic
+operators in the language (\ref{expr.mul}, \ref{expr.add}).
+
+\index{plus@\tcode{plus}}%
+\begin{itemdecl}
+template <class T> struct plus : binary_function<T,T,T> {
+ @\addedConcepts{requires Addable<T> \&\& Convertible<T::result_type, T>}@
+ T operator()(const T& @\farg{x}@, const T& @\farg{y}@) const;
+};
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\tcode{operator()}
+returns
+\tcode{\farg{x}\ + \farg{y}}.
+\end{itemdescr}
+
+\index{minus@\tcode{minus}}%
+\begin{itemdecl}
+template <class T> struct minus : binary_function<T,T,T> {
+ @\addedConcepts{requires Subtractable<T> \&\& Convertible<T::result_type, T>}@
+ T operator()(const T& @\farg{x}@, const T& @\farg{y}@) const;
+};
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\tcode{operator()}
+returns
+\tcode{\farg{x}\ - \farg{y}}.
+\end{itemdescr}
+
+\index{multiplies@\tcode{multiplies}}%
+\begin{itemdecl}
+template <class T> struct multiplies : binary_function<T,T,T> {
+ @\addedConcepts{requires Multiplicable<T> \&\& Convertible<T::result_type, T>}@
+ T operator()(const T& @\farg{x}@, const T& @\farg{y}@) const;
+};
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\tcode{operator()}
+returns
+\tcode{\farg{x}\ * \farg{y}}.
+\end{itemdescr}
+
+\index{divides@\tcode{divides}}%
+\begin{itemdecl}
+template <class T> struct divides : binary_function<T,T,T> {
+ @\addedConcepts{requires Divisible<T> \&\& Convertible<T::result_type, T>}@
+ T operator()(const T& @\farg{x}@, const T& @\farg{y}@) const;
+};
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\tcode{operator()}
+returns
+\tcode{\farg{x}\ / \farg{y}}.
+\end{itemdescr}
+
+\index{modulus@\tcode{modulus}}%
+\begin{itemdecl}
+template <class T> struct modulus : binary_function<T,T,T> {
+ @\addedConcepts{requires Remainder<T> \&\& Convertible<T::result_type, T>}@
+ T operator()(const T& @\farg{x}@, const T& @\farg{y}@) const;
+};
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\tcode{operator()} returns \tcode{\farg{x}\ \% \farg{y}}.
+\end{itemdescr}
+
+\index{negate@\tcode{negate}}%
+\begin{itemdecl}
+template <class T> struct negate : unary_function<T,T> {
+ @\addedConcepts{requires Negatable<T> \&\& Convertible<T::result_type, T>}@
+ T operator()(const T& @\farg{x}@) const;
+};
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\tcode{operator()} returns \tcode{-\farg{x}}.
+\end{itemdescr}
+
+\rSec2[comparisons]{Comparisons}
+
+\pnum
+The library provides basic function object classes for all of the comparison
+operators in the language (\ref{expr.rel}, \ref{expr.eq}).
+
+\index{equal_to@\tcode{equal_to}}%
+\begin{itemdecl}
+template <class T> struct equal_to : binary_function<T,T,bool> {
+ @\addedConcepts{requires EqualityComparable<T>}@
+ bool operator()(const T& @\farg{x}@, const T& @\farg{y}@) const;
+};
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\tcode{operator()} returns \tcode{\farg{x}\ == \farg{y}}.
+\end{itemdescr}
+
+\index{not_equal_to@\tcode{not_equal_to}}%
+\begin{itemdecl}
+template <class T> struct not_equal_to : binary_function<T,T,bool> {
+ @\addedConcepts{requires EqualityComparable<T>}@
+ bool operator()(const T& @\farg{x}@, const T& @\farg{y}@) const;
+};
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\tcode{operator()} returns \tcode{\farg{x}\ != \farg{y}}.
+\end{itemdescr}
+
+\index{greater@\tcode{greater}}%
+\begin{itemdecl}
+template <class T> struct greater : binary_function<T,T,bool> {
+ @\addedConcepts{requires LessThanComparable<T>}@
+ bool operator()(const T& @\farg{x}@, const T& @\farg{y}@) const;
+};
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\tcode{operator()} returns \tcode{\farg{x}\ > \farg{y}}.
+\end{itemdescr}
+
+\index{less@\tcode{less}}%
+\begin{itemdecl}
+template <class T> struct less : binary_function<T,T,bool> {
+ @\addedConcepts{requires LessThanComparable<T>}@
+ bool operator()(const T& @\farg{x}@, const T& @\farg{y}@) const;
+};
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\tcode{operator()} returns \tcode{\farg{x}\ < \farg{y}}.
+\end{itemdescr}
+
+\index{greater_equal@\tcode{greater_equal}}%
+\begin{itemdecl}
+template <class T> struct greater_equal : binary_function<T,T,bool> {
+ @\addedConcepts{requires LessThanComparable<T>}@
+ bool operator()(const T& @\farg{x}@, const T& @\farg{y}@) const;
+};
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\tcode{operator()} returns \tcode{\farg{x}\ >= \farg{y}}.
+\end{itemdescr}
+
+\index{less_equal@\tcode{less_equal}}%
+\begin{itemdecl}
+template <class T> struct less_equal : binary_function<T,T,bool> {
+ @\addedConcepts{requires LessThanComparable<T>}@
+ bool operator()(const T& @\farg{x}@, const T& @\farg{y}@) const;
+};
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\tcode{operator()} returns \tcode{\farg{x}\ <= \farg{y}}.
+\end{itemdescr}
+
+\pnum
+For templates \tcode{greater}, \tcode{less}, \tcode{greater_equal}, and
+\tcode{less_equal}, the specializations for any pointer type yield a total order,
+even if the built-in operators \tcode{<}, \tcode{>}, \tcode{<=}, \tcode{>=}
+do not.
+
+\rSec2[logical.operations]{Logical operations}
+
+\pnum
+The library provides basic function object classes for all of the logical
+operators in the language (\ref{expr.log.and}, \ref{expr.log.or}, \ref{expr.unary.op}).
+
+\index{logical_and@\tcode{logical_and}}%
+\begin{itemdecl}
+template <class T> struct logical_and : binary_function<T,T,bool> {
+ @\addedConcepts{requires LogicalAnd<T>}@
+ bool operator()(const T& @\farg{x}@, const T& @\farg{y}@) const;
+};
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\tcode{operator()} returns \tcode{\farg{x}\ \&\& \farg{y}}.
+\end{itemdescr}
+
+\index{logical_or@\tcode{logical_or}}%
+\begin{itemdecl}
+template <class T> struct logical_or : binary_function<T,T,bool> {
+ @\addedConcepts{requires LogicalOr<T>}@
+ bool operator()(const T& @\farg{x}@, const T& @\farg{y}@) const;
+};
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\tcode{operator()} returns \tcode{\farg{x}\ || \farg{y}}.
+\end{itemdescr}
+
+\index{logical_not@\tcode{logical_not}}%
+\begin{itemdecl}
+template <class T> struct logical_not : unary_function<T,bool> {
+ @\addedConcepts{requires LogicalNot<T>}@
+ bool operator()(const T& @\farg{x}@) const;
+};
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\tcode{operator()} returns \tcode{!\farg{x}}.
+\end{itemdescr}
+
+\setcounter{subsection}{9}
+\rSec2[bind]{\marktr{}Template function \tcode{bind}}
+
+\pnum
+The template function \tcode{bind} returns an object that binds a
+function object passed as an argument to additional arguments.
+
+\pnum
+\removedConcepts{Binders \mbox{\tcode{bind1st}} and \mbox{\tcode{bind2nd}} take a function object
+\mbox{\tcode{fn}} of two arguments and a value \mbox{\tcode{x}} and return
+a function object of one argument constructed out of \mbox{\tcode{\changedB{f}{fn}}}
+with the first or second argument correspondingly bound to \mbox{\tcode{x}}.}
+
+\rSec3[func.bind]{\marktr{}Function object binders}
+
+\index{function objects!binders|(}%
+
+\setcounter{paragraph}{2}
+\rSec4[func.bind.bind]{Function template \tcode{bind}}
+\index{bind@\tcode{bind}|(}
+
+\begin{itemdecl}
+template<@\changedConcepts{class}{CopyConstructible}@ F, @\changedD{class T1, class T2, ...., class TN}{\changedConcepts{class}{CopyConstructible}... BoundArgs}@>
+ @\unspec@ bind(F f, @\changedD{T1 t1, T2 t2, ..., TN tN}{BoundArgs... bound_args}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum\requires\ \removedConcepts{\mbox{\tcode{F}} and \mbox{\addedD{each}} \mbox{\tcode{Ti}}
+\mbox{\addedD{in \mbox{\tcode{BoundArgs}}}} shall be
+CopyConstructible.} \tcode{\textit{INVOKE} (f, w1, w2, ...,
+wN)}~(\ref{func.require}) shall be a valid expression for some
+values \textit{w1, w2, ..., wN}\addedD{, where
+\mbox{\tcode{N == sizeof...(bound_args)}}}.
+
+\pnum\returns\ A forwarding call wrapper \tcode{g} with a weak result
+type~(\ref{func.require}). The effect of \tcode{g(u1, u2, ..., uM)} shall
+be \tcode{\textit{INVOKE}(f, v1, v2, ..., vN, \changedConcepts{result_of}{Callable}<F \textit{cv}\changedConcepts{ (}{,}V1, V2, ..., VN\removedConcepts{)}>::\addedConcepts{result_}type)}, where \tcode{\textit{cv}} represents the
+\textit{cv}-qualifiers of \tcode{g} and the values and types of the bound
+arguments \tcode{v1, v2, ..., vN} are determined as specified below.
+\end{itemdescr}
+
+\begin{itemdecl}
+template<@\changedConcepts{class}{MoveConstructible}@ R, @\changedConcepts{class}{CopyConstructible}@ F, @\changedD{class T1, class T2, ...., class TN}{\changedConcepts{class}{CopyConstructible}... BoundArgs}@>
+ @\unspec@ bind(F f, @\changedD{T1 t1, T2 t2, ..., TN tN}{BoundArgs... bound_args}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum\requires\ \removedConcepts{\mbox{\tcode{F}} and \mbox{\addedD{each}} \mbox{\tcode{Ti}}
+\mbox{\addedD{in \mbox{\tcode{BoundArgs}}}} shall be CopyConstructible.}
+\tcode{\textit{INVOKE}(f, w1, w2, ..., wN)} shall be a valid
+expression for some
+values \textit{w1, w2, ..., wN}\addedD{, where
+\mbox{\tcode{N == sizeof...(bound_args)}}}.
+
+\pnum\returns\ A forwarding call wrapper \tcode{g} with a nested type
+\tcode{result_type} defined as a synonym for \tcode{R}. The effect of
+\tcode{g(u1, u2, ..., uM)} shall be \tcode{\textit{INVOKE}(f, v1, v2,
+..., vN, R)}, where the values and types of the bound
+arguments \tcode{v1, v2, ..., vN} are determined as specified below.
+\end{itemdescr}
+
+\rSec2[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:
+
+\index{pointer_to_unary_function@\tcode{pointer_to_unary_function}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{MoveConstructible}@ Arg, @\changedConcepts{class}{MoveConstructible}@ Result>
+class pointer_to_unary_function : public unary_function<Arg, Result> {
+public:
+ explicit pointer_to_unary_function(Result (*@\farg{f}@)(Arg));
+ Result operator()(Arg @\farg{x}@) const;
+};
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\tcode{operator()} returns \tcode{\farg{f}(\farg{x})}.
+\end{itemdescr}
+
+\index{ptr_fun@\tcode{ptr_fun}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{MoveConstructible}@ Arg, @\changedConcepts{class}{MoveConstructible}@ Result>
+ pointer_to_unary_function<Arg, Result> ptr_fun(Result (*@\farg{f}@)(Arg));
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{pointer_to_unary_function<Arg, Result>(\farg{f})}.
+\end{itemdescr}
+
+\index{pointer_to_binary_function@\tcode{pointer_to_binary_function}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{MoveConstructible}@ Arg1, @\changedConcepts{class}{MoveConstructible}@ Arg2, @\changedConcepts{class}{MoveConstructible}@ Result>
+class pointer_to_binary_function :
+ public binary_function<Arg1,Arg2,Result> {
+public:
+ explicit pointer_to_binary_function(Result (*@\farg{f}@)(Arg1, Arg2));
+ Result operator()(Arg1 @\farg{x}@, Arg2 @\farg{y}@) const;
+};
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\tcode{operator()} returns \tcode{\farg{f}(\farg{x},\farg{y})}.
+\end{itemdescr}
+
+\index{ptr_fun@\tcode{ptr_fun}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{MoveConstructible}@ Arg1, @\changedConcepts{class}{MoveConstructible}@ Arg2, @\changedConcepts{class}{MoveConstructible}@ Result>
+ pointer_to_binary_function<Arg1,Arg2,Result>
+ ptr_fun(Result (*@\farg{f}@)(Arg1, Arg2));
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{pointer_to_binary_function<Arg1,Arg2,Result>(\farg{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}
+
+\rSec2[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{function.pointer.adaptors}.
+
+\index{mem_fun_t@\tcode{mem_fun_t}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{MoveConstructible}@ 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}
+
+\index{mem_fun1_t@\tcode{mem_fun1_t}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{MoveConstructible}@ S, class T, @\changedConcepts{class}{MoveConstructible}@ 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}
+
+\index{mem_fun@\tcode{mem_fun}}%
+\begin{itemdecl}
+template<@\changedConcepts{class}{MoveConstructible}@ S, class T> mem_fun_t<S,T>
+ mem_fun(S (T::*f)());
+template<@\changedConcepts{class}{MoveConstructible}@ S, class T, @\changedConcepts{class}{MoveConstructible}@ 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}
+
+\index{mem_fun_ref_t@\tcode{mem_fun_ref_t}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{MoveConstructible}@ 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}
+
+\index{mem_fun1_ref_t@\tcode{mem_fun1_ref_t}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{MoveConstructible}@ S, class T, @\changedConcepts{class}{MoveConstructible}@ 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}
+
+\index{mem_fun_ref@\tcode{mem_fun_ref}}%
+\begin{itemdecl}
+template<@\changedConcepts{class}{MoveConstructible}@ S, class T> mem_fun_ref_t<S,T>
+ mem_fun_ref(S (T::*f)());
+template<@\changedConcepts{class}{MoveConstructible}@ S, class T, @\changedConcepts{class}{MoveConstructible}@ 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}
+
+\index{const_mem_fun_t@\tcode{const_mem_fun_t}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{MoveConstructible}@ 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}
+
+\index{const_mem_fun1_t@\tcode{const_mem_fun1_t}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{MoveConstructible}@ S, class T, @\changedConcepts{class}{MoveConstructible}@ 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}
+
+\index{mem_fun@\tcode{mem_fun}}%
+\begin{itemdecl}
+template<c@\changedConcepts{class}{MoveConstructible}@ S, class T> const_mem_fun_t<S,T>
+ mem_fun(S (T::*f)() const);
+template<@\changedConcepts{class}{MoveConstructible}@ S, class T, @\changedConcepts{class}{MoveConstructible}@ 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}
+
+\index{const_mem_fun_ref_t@\tcode{const_mem_fun_ref_t}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{MoveConstructible}@ 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}
+
+\index{const_mem_fun1_ref_t@\tcode{const_mem_fun1_ref_t}}%
+\begin{itemdecl}
+template <@\changedConcepts{class}{MoveConstructible}@ S, class T, @\changedConcepts{class}{MoveConstructible}@ 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}
+
+\index{mem_fun_ref@\tcode{mem_fun_ref}}%
+\begin{itemdecl}
+template<@\changedConcepts{class}{MoveConstructible}@ S, class T> const_mem_fun_ref_t<S,T>
+ mem_fun_ref(S (T::*f)() const);
+template<@\changedConcepts{class}{MoveConstructible}@ S, class T, @\changedConcepts{class}{MoveConstructible}@ 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}
+
+\rSec2[func.memfn]{\marktr{}Function template \tcode{mem_fn}}
+\index{function objects!mem_fn@\tcode{mem_fn}|(}
+
+\index{mem_fn@\tcode{mem_fn}}%
+\begin{itemdecl}
+template<@\changedConcepts{class}{ObjectType}@ R, class T> @\textit{unspecified}@ mem_fn(R T::* pm);
+@\addedConcepts{template<MoveConstructible R, class T, MoveConstructible... Args>}@
+ @\addedConcepts{\textit{unspecified} mem_fn(R (T::*)(Args...) pm);}@
+@\addedConcepts{template<MoveConstructible R, class T, MoveConstructible... Args>}@
+ @\addedConcepts{\textit{unspecified} mem_fn(R (T::* const)(Args...) pm);}@
+@\addedConcepts{template<MoveConstructible R, class T, MoveConstructible... Args>}@
+ @\addedConcepts{\textit{unspecified} mem_fn(R (T::* volatile)(Args...) pm);}@
+@\addedConcepts{template<MoveConstructible R, class T, MoveConstructible... Args>}@
+ @\addedConcepts{\textit{unspecified} mem_fn(R (T::* const volatile)(Args...) pm);}@
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum\returns\ A simple call wrapper~([\ref{func.def}]) \tcode{fn}
+such that the expression \tcode{fn(t, a2, ..., aN)} is equivalent
+to \tcode{\textit{INVOKE}(pm, t, a2, ..., aN)}~([\ref{func.require}]).
+\tcode{fn} shall have a nested type \tcode{result_type} that is a synonym
+for the return type of \tcode{pm} when \tcode{pm} is a pointer to
+member function.
+
+\pnum\index{unary function}%
+The simple call wrapper shall be derived
+from \tcode{std::unary_function<\textit{cv} T*, \textit{Ret}>} when \tcode{pm} is
+a pointer to member function with cv-qualifier \textit{cv} and taking no
+arguments, where \textit{Ret} is \tcode{pm}'s return type.
+
+\pnum\index{binary function}%
+The simple call wrapper shall be derived from
+\tcode{std::binary_function<\textit{cv} T*, T1, \textit{Ret}>} when \tcode{pm} is
+a pointer to member function with cv-qualifier \textit{cv} and taking
+one argument of type \tcode{T1}, where \textit{Ret} is \tcode{pm}'s return type.
+
+\pnum\throws\ nothing.
+
+\pnum\removedConcepts{\mbox{\notes} Implementations may implement \mbox{\tcode{mem_fn}} as a set of
+overloaded function templates.}
+\end{itemdescr}
+\index{function objects!mem_fn@\tcode{mem_fn}|)}
+
+\rSec2[func.wrap]{\marktr{}Polymorphic function wrappers}
+\index{function objects!wrapper|(}%
+
+\setcounter{subsubsection}{1}
+\rSec3[func.wrap.func]{Class template \tcode{function}}
+\index{function@\tcode{function}}
+
+\begin{codeblock}
+namespace std {
+ template<class@\removedD{ Function}@> class function; // \addedD{undefined}
+
+ @\addedD{template<\changedConcepts{class}{MoveConstructible} R, \changedConcepts{class}{MoveConstructible}... ArgTypes>}@
+ class function@\addedD{<R(ArgTypes...)>}@
+ : public unary_function<T1, R> // iff \addedD{\mbox{\tcode{sizeof...(ArgTypes) == 1}} and \mbox{\tcode{ArgTypes}} contains \mbox{\tcode{T1}}}
+ : public binary_function<T1, T2, R> // iff \addedD{\mbox{\tcode{sizeof...(ArgTypes) == 2}} and \mbox{\tcode{ArgTypes}} contains \mbox{\tcode{T1}} and \mbox{\tcode{T2}}}
+ {
+ public:
+ typedef R result_type;
+
+ // \ref{func.wrap.func.con}, construct/copy/destroy:
+ explicit function();
+ function(@\unspecnull@);
+ function(const function&);
+ @\addedD{function(function\&\&);}@
+ template<class F>
+ @\addedConcepts{requires CopyConstructible<F> \&\& Callable<F, ArgTypes...> \&\&}@
+ @\addedConcepts{Convertible<Callable<F, ArgTypes...>::result_type, R>}@
+ function(F);
+ template<class F>
+ @\addedConcepts{requires CopyConstructible<F> \&\& Callable<F, ArgTypes...> \&\&}@
+ @\addedConcepts{Convertible<Callable<F, ArgTypes...>::result_type, R>}@
+ function(F&&);
+
+ function& operator=(const function&);
+ @\addedD{function\& operator=(function\&\&);}@
+ function& operator=(@\unspecnull@);
+ template<class F>
+ @\addedConcepts{requires CopyConstructible<F> \&\& Callable<F, ArgTypes..> \&\&}@
+ @\addedConcepts{Convertible<Callable<F, ArgTypes...>::result_type}@
+ function& operator=(F);
+ template<class F>
+ @\addedConcepts{requires CopyConstructible<F> \&\& Callable<F, ArgTypes...> \&\&}@
+ @\addedConcepts{Convertible<Callable<F, ArgTypes...>::result_type, R>}@
+ function& operator=(F&&);
+ template<class F>
+ @\addedConcepts{requires CopyConstructible<F> \&\& Callable<F, ArgTypes...> \&\&}@
+ @\addedConcepts{Convertible<Callable<F, ArgTypes...>::result_type, R>}@
+ function& operator=(reference_wrapper<F>);
+
+ ~function();
+
+ // \ref{func.wrap.func.mod}, function modifiers:
+ void swap(function&);
+
+ // \ref{func.wrap.func.cap}, function capacity:
+ operator @\unspecbool@() const;
+
+ // \ref{func.wrap.func.inv}, function invocation:
+ R operator()(@\changedD{T1, T2, ..., TN}{ArgTypes...}@) const;
+
+ // \ref{func.wrap.func.targ}, function target access:
+ const std::type_info& target_type() const;
+ template <typename T>
+ @\addedConcepts{requires Callable<F, ArgTypes...> \&\& Convertible<Callable<F, ArgTypes...>::result_type, R>}@
+ T* target();
+ template <typename T>
+ @\addedConcepts{requires Callable<F, ArgTypes...> \&\& Convertible<Callable<F, ArgTypes...>::result_type, R>}@
+ const T* target() const;
+
+ private:
+ // \ref{func.wrap.func.undef}, undefined operators:
+ template<@\addedD{class R2, class... ArgTypes2}@> bool operator==(const function<@\addedD{R2(ArgTypes2...)}@>&);
+ template<@\addedD{class R2, class... ArgTypes2}@> bool operator!=(const function<@\addedD{R2(ArgTypes2...)}@>&);
+ };
+
+ // \ref{func.wrap.func.nullptr}, Null pointer comparisons:
+ template <@\changedD{class Function}{\changedConcepts{class}{MoveConstructible} R, \changedConcepts{class}{MoveConstructible}... ArgTypes}@>
+ bool operator==(const function<@\changedD{Function}{R(ArgTypes...)}@>&, @\unspecnull@);
+
+ template <@\changedD{class Function}{\changedConcepts{class}{MoveConstructible} R, \changedConcepts{class}{MoveConstructible}... ArgTypes}@>
+ bool operator==(@\unspecnull@, const function<@\changedD{Function}{R(ArgTypes...)}@>&);
+
+ template <@\changedD{class Function}{\changedConcepts{class}{MoveConstructible} R, \changedConcepts{class}{MoveConstructible}... ArgTypes}@>
+ bool operator!=(const function<@\changedD{Function}{R(ArgTypes...)}@>&, @\unspecnull@);
+
+ template <@\changedD{class Function}{\changedConcepts{class}{MoveConstructible} R, \changedConcepts{class}{MoveConstructible}... ArgTypes}@>
+ bool operator!=(@\unspecnull@, const function<@\changedD{Function}{R(ArgTypes...)}@>&);
+
+ // \ref{func.wrap.func.alg}, specialized algorithms:
+ template <@\changedD{class Function}{\changedConcepts{class}{MoveConstructible} R, \changedConcepts{class}{MoveConstructible}... ArgTypes}@>
+ void swap(function<@\changedD{Function}{R(ArgTypes...)}@>&, function<@\changedD{Function}{R(ArgTypes...)}@>&);
+} // namespace std
+\end{codeblock}
+
+\rSec4[func.wrap.func.con]{\tcode{function} construct/copy/destroy}
+\index{function@\tcode{function}!function@\tcode{function}}
+\setcounter{Paras}{7}
+\begin{itemdecl}
+template<class F>
+ @\addedConcepts{requires CopyConstructible<F> \&\& Callable<F, ArgTypes..> \&\&}@
+ @\addedConcepts{Convertible<Callable<F, ArgTypes...>::result_type}@
+ function(F f);
+template<class F>
+ @\addedConcepts{requires CopyConstructible<F> \&\& Callable<F, ArgTypes..> \&\&}@
+ @\addedConcepts{Convertible<Callable<F, ArgTypes...>::result_type}@
+ function(F&& f);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum\removedConcepts{\mbox{\requires} \mbox{\tcode{f}} shall be callable for argument types
+\mbox{\changedD{\mbox{\tcode{T1}}, \mbox{\tcode{T2}}, ..., \mbox{\tcode{T\textit{N}}}}
+{\mbox{\tcode{ArgTypes}}}} and return type \mbox{\tcode{R}}.}
+
+\pnum\postconditions\ \tcode{!*this} if any of the following hold:
+\begin{itemize}
+\item{\tcode{f} is a NULL function pointer.}
+\item{\tcode{f} is a NULL member function pointer.}
+\item{\tcode{F} is an instance of the \tcode{function} class template, and
+ \tcode{!f}}
+\end{itemize}
+
+\pnum
+Otherwise, \tcode{*this} targets a copy of \tcode{f}
+\addedD{or \mbox{\tcode{move(f)}}} if \tcode{f} is
+not a pointer to member function, and targets a copy
+of \tcode{mem_fn(f)} if \tcode{f} is a pointer to member function.
+
+\pnum\throws\ shall not throw exceptions when \tcode{f} is a function pointer
+or a \tcode{reference_wrapper<T>} for some \tcode{T}. Otherwise,
+may throw \tcode{bad_alloc} or any exception thrown by \tcode{F}'s copy
+\addedD{or move} constructor.
+\end{itemdescr}
+
+\setcounter{Paras}{18}
+\index{function@\tcode{function}!operator=@\tcode{operator=}}%
+\index{operator=@\tcode{operator=}!function@\tcode{function}}%
+\begin{itemdecl}
+template<class F>
+ @\addedConcepts{requires CopyConstructible<F> \&\& Callable<F, ArgTypes..> \&\&}@
+ @\addedConcepts{Convertible<Callable<F, ArgTypes...>::result_type}@
+ operator=(F f);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum\effects\ \tcode{function(f).swap(*this);}
+
+\pnum\returns\ \tcode{*this}
+\end{itemdescr}
+
+\index{function@\tcode{function}!operator=@\tcode{operator=}}%
+\index{operator=@\tcode{operator=}!function@\tcode{function}}%
+\begin{itemdecl}
+template<class F>
+ @\addedConcepts{requires CopyConstructible<F> \&\& Callable<F, ArgTypes..> \&\&}@
+ @\addedConcepts{Convertible<Callable<F, ArgTypes...>::result_type}@
+ function& operator=(F&& f);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedD{\mbox{\effects} Replaces the target of \mbox{\tcode{*this}}
+with \mbox{\tcode{f}}, leaving \mbox{\tcode{f}} in a
+valid but unspecified state. \mbox{\enternote} A valid implementation is
+\mbox{\tcode{function(f).swap(*this)}}.}
+
+\pnum
+\addedD{\mbox{\returns} \mbox{\tcode{*this}}.}
+\end{itemdescr}
+
+\index{function@\tcode{function}!operator=@\tcode{operator=}}%
+\index{operator=@\tcode{operator=}!function@\tcode{function}}%
+\begin{itemdecl}
+template<class F>
+ @\addedConcepts{requires CopyConstructible<F> \&\& Callable<F, ArgTypes...> \&\&}@
+ @\addedConcepts{Convertible<Callable<F, ArgTypes...>::result_type, R>}@
+ function& operator=(reference_wrapper<F> f);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum\effects\ \tcode{function(f).swap(*this);}
+
+\pnum\returns\ \tcode{*this}
+
+\pnum\throws\ nothing.
+\end{itemdescr}
+
+\setcounter{paragraph}{4}
+\rSec4[func.wrap.func.targ]{function target access}
+
+\index{function@\tcode{function}!target_type@\tcode{target_type}}%
+\index{target_type@\tcode{target_type}!function@\tcode{function}}%
+\begin{itemdecl}
+const std::type_info& target_type() const;
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum\returns\ If \tcode{*this} has a target of type \tcode{T},
+ \tcode{typeid(T)}; otherwise, \tcode{typeid(void)}.
+
+\pnum\throws\ nothing.
+\end{itemdescr}
+
+\index{function@\tcode{function}!target@\tcode{target}}%
+\index{target@\tcode{target}!function@\tcode{function}}%
+\begin{itemdecl}
+template<typename T>
+ @\addedConcepts{requires Callable<F, ArgTypes...> \&\& Convertible<Callable<F, ArgTypes...>::result_type, R>}@
+ T* target();
+template<typename T>
+ @\addedConcepts{requires Callable<F, ArgTypes...> \&\& Convertible<Callable<F, ArgTypes...>::result_type, R>}@
+ const T* target() const;
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedConcepts{\mbox{\requires} \mbox{\tcode{T}} is a function object type that is
+Callable~(\mbox{\ref{func.wrap.func}}) for parameter types
+\mbox{\tcode{ArgTypes}}
+and return type \mbox{\tcode{R}}.}
+
+\pnum\returns\ If \tcode{type() == typeid(T)}, a pointer to the
+ stored function target; otherwise a null pointer.
+
+\pnum\throws\ nothing.
+\end{itemdescr}
+
+\setcounter{paragraph}{6}
+\rSec4[func.wrap.func.nullptr]{null pointer comparison operators}
+
+\begin{itemdecl}
+template <@\changedD{class Function}{\changedConcepts{class}{MoveConstructible} R, \changedConcepts{class}{MoveConstructible}... ArgTypes}@>
+ bool operator==(const function<@\changedD{Function}{R(ArgTypes...)}@>& f, @\unspecnull@);
+
+template <@\changedD{class Function}{\changedConcepts{class}{MoveConstructible} R, \changedConcepts{class}{MoveConstructible}... ArgTypes}@>
+ bool operator==(@\unspecnull@, const function<@\changedD{Function}{R(ArgTypes...)}@>& f);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum\returns\ \tcode{!f}.
+
+\pnum\throws\ nothing.
+\end{itemdescr}
+
+\begin{itemdecl}
+template <@\changedD{class Function}{\changedConcepts{class}{MoveConstructible} R, \changedConcepts{class}{MoveConstructible}... ArgTypes}@>
+ bool operator!=(const function<@\changedD{Function}{R(ArgTypes...)}@>& f, @\unspecnull@);
+
+template <@\changedD{class Function}{\changedConcepts{class}{MoveConstructible} R, \changedConcepts{class}{MoveConstructible}... ArgTypes}@>
+ bool operator!=(@\unspecnull@, const function<@\changedD{Function}{R(ArgTypes...)}@>& f);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum\returns\ \tcode{ (bool) f}.
+
+\pnum\throws\ nothing.
+\end{itemdescr}
+
+\rSec4[func.wrap.func.alg]{specialized algorithms}
+
+\index{function@\tcode{function}!swap@\tcode{swap}}%
+\index{swap@\tcode{swap}!function@\tcode{function}}%
+\begin{itemdecl}
+template<@\changedD{class Function}{\changedConcepts{class}{MoveConstructible} R, \changedConcepts{class}{MoveConstructible}... ArgTypes}@>
+ void swap(function<@\changedD{Function}{R(ArgTypes...)}@>& f1, function<@\changedD{Function}{R(ArgTypes...)}@>& f2);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum\effects\ \tcode{f1.swap(f2);}
+\end{itemdescr}
+\index{function objects!wrapper|)}%
+
+\rSec1[memory]{Memory}
+
+\pnum
+\synopsis{Header \tcode{<memory>}\ synopsis}
+
+\index{memory@\tcode{<memory>}}%
+\begin{codeblock}
+namespace std {
+ // \ref{default.allocator}, the default allocator:
+ template <class T> class allocator; @\addedConcepts{// undefined}@
+ template <> class allocator<void>;
+ @\addedConcepts{template <class T> requires ObjectType<T> \&\& Destructible<T>}@
+ @\addedConcepts{class allocator<T>;}@
+ template <class T, class U>
+ bool operator==(const allocator<T>&, const allocator<U>&) throw();
+ template <class T, class U>
+ bool operator!=(const allocator<T>&, const allocator<U>&) throw();
+
+ @\addedConcepts{concept_map AllocatorGenerator<allocator<void> > \{ \}}@
+ @\addedConcepts{template <class T> requires ObjectType<T> \&\& Destructible<T>}@
+ @\addedConcepts{concept_map Allocator<allocator<T> > \{ \}}@
+
+ // \ref{storage.iterator}, raw storage iterator:
+ template <class OutputIterator, class T> class raw_storage_iterator;
+
+ // \ref{temporary.buffer}, temporary buffers:
+ template <class T>
+ pair<T*,ptrdiff_t> get_temporary_buffer(ptrdiff_t @\farg{n}@);
+ template <class T>
+ void return_temporary_buffer(T* @\farg{p}@);
+
+ // \ref{specialized.algorithms}, specialized algorithms:
+ template <class InputIterator, class ForwardIterator>
+ ForwardIterator
+ uninitialized_copy(InputIterator @\farg{first}@, InputIterator @\farg{last}@,
+ ForwardIterator @\farg{result}@);
+ template <class ForwardIterator, class T>
+ void uninitialized_fill(ForwardIterator @\farg{first}@, ForwardIterator @\farg{last}@,
+ const T& @\farg{x}@);
+ template <class ForwardIterator, class Size, class T>
+ void uninitialized_fill_n(ForwardIterator @\farg{first}@, Size @\farg{n}@, const T& @\farg{x}@);
+ @\removedD{// \mbox{\ref{auto.ptr}}, pointers:}@
+ @\removedD{template <class X> class auto_ptr;}@
+ @\removedD{template <> class auto_ptr<void>;}@
+
+ // \addedD{\mbox{\ref{unique.ptr}} Class unique_ptr:}
+ @\addedD{template <class X> class unique_ptr;}@
+ @\addedD{template <class X> class default_delete;}@
+
+ // \ref{util.smartptr.weakptr}, Class bad_weak_ptr:
+ class bad_weak_ptr;
+
+ // \ref{util.smartptr.shared}, Class template shared_ptr:
+ template<class T> class shared_ptr;
+
+ // \ref{util.smartptr.shared.cmp}, shared_ptr comparisons:
+ template<class T, class U>
+ bool operator==(shared_ptr<T> const& a, shared_ptr<U> const& b);
+ template<class T, class U>
+ bool operator!=(shared_ptr<T> const& a, shared_ptr<U> const& b);
+ template<class T, class U>
+ bool operator<(shared_ptr<T> const& a, shared_ptr<U> const& b);
+
+ // \ref{util.smartptr.shared.spec}, shared_ptr specialized algorithms:
+ template<class T> void swap(shared_ptr<T>& a, shared_ptr<T>& b);
+
+ // \ref{util.smartptr.shared.cast}, shared_ptr casts:
+ template<class T, class U>
+ shared_ptr<T> static_pointer_cast(shared_ptr<U> const& r);
+ template<class T, class U>
+ shared_ptr<T> dynamic_pointer_cast(shared_ptr<U> const& r);
+ template<class T, class U>
+ shared_ptr<T> const_pointer_cast(shared_ptr<U> const& r);
+
+ // \ref{util.smartptr.shared.io}, shared_ptr I/O:
+ template<class E, class T, class Y>
+ basic_ostream<E, T>& operator<< (basic_ostream<E, T>& os, shared_ptr<Y> const& p);
+
+ // \ref{util.smartptr.getdeleter}, shared_ptr get_deleter:
+ template<class D, class T> D* get_deleter(shared_ptr<T> const& p);
+
+ // \ref{util.smartptr.weak}, Class template weak_ptr:
+ template<class T> class weak_ptr;
+
+ // \ref{util.smartptr.weak.cmp}, weak_ptr comparison:
+ template<class T, class U> bool operator<(weak_ptr<T> const& a, weak_ptr<U> const& b);
+
+ // \ref{util.smartptr.weak.spec}, weak_ptr specialized algorithms:
+ template<class T> void swap(weak_ptr<T>& a, weak_ptr<T>& b);
+
+ // \ref{util.smartptr.enab}, Class enable_shared_from_this:
+ template<class T> class enable_shared_from_this;
+}
+\end{codeblock}
+
+\rSec2[default.allocator]{The default allocator}
+
+\index{allocator@\tcode{allocator}}%
+\begin{codeblock}
+namespace std {
+ template <class T> class allocator; @\addedConcepts{// undefined}@
+\end{codeblock}
+\begin{codeblock}
+ // specialize for \tcode{void}:
+ template <> class allocator<void> {
+ public:
+ typedef void* pointer;
+ typedef const void* const_pointer;
+ // reference-to-\tcode{void}\ members are impossible.
+ typedef void value_type;
+ template <class U> struct rebind { typedef allocator<U> other; };
+ };
+
+ template <class T>
+ @\addedConcepts{requires ObjectType<T> \&\& Destructible<T>}@
+ class allocator@\addedConcepts{<T>}@ {
+ public:
+ typedef size_t size_type;
+ typedef ptrdiff_t difference_type;
+ typedef T* pointer;
+ typedef const T* const_pointer;
+ typedef T& reference;
+ typedef const T& const_reference;
+ typedef T value_type;
+ template <class U> struct rebind { typedef allocator<U> other; };
+
+ allocator() throw();
+ allocator(const allocator&) throw();
+ template <class U> allocator(const allocator<U>&) throw();
+ ~allocator() throw();
+
+ pointer address(reference @\farg{x}@) const;
+ const_pointer address(const_reference @\farg{x}@) const;
+
+ pointer allocate(
+ size_type, allocator<void>::const_pointer @\farg{hint}@ = 0);
+ void deallocate(pointer @\farg{p}@, size_type @\farg{n}@);
+ size_type max_size() const throw();
+
+ @\addedConcepts{requires CopyConstructible<T>}@ void construct(pointer p, const T& val);
+ template <class U> @\addedConcepts{requires Constructible<T, U\&\&>}@ void construct(pointer p, U&& val);
+ void destroy(pointer p);
+ };
+}
+\end{codeblock}
+
+\pnum
+\addedConcepts{Class template \mbox{\tcode{allocator}} meets the
+ requirements of the \mbox{\tcode{AllocatorGenerator}} class when it
+ is instantiated with a \mbox{\tcode{Destructible}} object type or
+ with \mbox{\tcode{void}}. When instantiated with an object type,
+ \mbox{\tcode{allocator}} meets the requirements of the
+ \mbox{\tcode{Allocator}} concept.}
+\color{addclr}
+\begin{itemdecl}
+ @\addedConcepts{concept_map AllocatorGenerator<allocator<void> > \{ \}}@
+ @\addedConcepts{template <class T> requires ObjectType<T> \&\& Destructible<T>}@
+ @\addedConcepts{concept_map Allocator<allocator<T> > \{ \}}@
+\end{itemdecl}
+\color{black}
+
+\rSec3[allocator.members]{\tcode{allocator}\ members}
+
+\begin{itemdecl}
+pointer address(reference @\farg{x}@) const;
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{\&\farg{x}}.
+\end{itemdescr}
+
+\begin{itemdecl}
+const_pointer address(const_reference @\farg{x}@) const;
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{\&\farg{x}}.
+\end{itemdescr}
+
+\begin{itemdecl}
+pointer allocate(size_type @\farg{n}@, allocator<void>::const_pointer @\farg{hint}@=0);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\notes\
+Uses
+\tcode{::operator new(std::size_t)}
+(\ref{new.delete}).
+
+\pnum
+\removedD{\mbox{\requires}
+\mbox{\farg{hint}} either 0 or previously obtained from member \mbox{\tcode{allocate}}
+and not yet passed to member \mbox{\tcode{deallocate}}. The value \mbox{\farg{hint}} may
+be used by an implementation to help improve performance}%
+\remfootnoteD{
+In a container member function, the address of an adjacent element
+is often a good choice to pass for this argument.
+}\addedD{\mbox{\enternote} In a container member function, the address of an adjacent
+element is often a good choice to pass for this argument. \mbox{\exitnote}}
+
+\pnum
+\returns\
+a pointer to the initial element of an array of storage of size \farg{n}\
+\tcode{* sizeof(T)}, aligned appropriately for objects of type \tcode{T}.
+
+\pnum
+\note\
+the storage is obtained by calling \tcode{::operator new(std::size_t)}, but
+it is unspecified when or how often this function is called. The use of
+\farg{hint}\ is unspecified, but intended as an aid to locality if an
+implementation so desires.
+
+\pnum
+\throws\
+\tcode{bad_alloc} if the storage cannot be obtained.
+\end{itemdescr}
+
+\begin{itemdecl}
+void deallocate(pointer @\farg{p}@, size_type @\farg{n}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\requires\
+\farg{p}\ shall be a pointer value obtained from \tcode{allocate()}.
+\farg{n}\ shall equal the value passed as the first argument
+to the invocation of allocate which returned \farg{p}.
+
+\pnum
+\effects\
+Deallocates the storage referenced by \farg{p}\ .
+
+\pnum
+\notes\
+Uses
+\tcode{::operator delete(void*)}
+(\ref{new.delete}), but it is unspecified when this function is called.
+\end{itemdescr}
+
+\begin{itemdecl}
+size_type max_size() const throw();
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+the largest value \textit{N}\ for which the call \tcode{allocate(\farg{N},0)}
+might succeed.
+\end{itemdescr}
+
+\begin{itemdecl}
+@\addedConcepts{requires CopyConstructible<T>}@ void construct(pointer @\farg{p}@, const_reference @\farg{val}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+\tcode{::new((void *)\farg{p}) T(\farg{val})}
+\end{itemdescr}
+
+\begin{itemdecl}
+template <class @\farg{U}@> @\addedConcepts{requires Constructible<T, U\&\&>}@ void construct(pointer @\farg{p}@, @\farg{U}@&& @\farg{val}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedD{\mbox{\effects}
+\mbox{\tcode{::new((void *)\farg{p}) T(std::forward<\farg{U}>(\farg{val}))}}}
+\end{itemdescr}
+
+\begin{itemdecl}
+void destroy(pointer @\farg{p}@);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\effects\
+\tcode{\farg{p}->$\sim$T()}
+\end{itemdescr}
+
+\rSec3[allocator.globals]{\tcode{allocator}\ globals}
+
+\begin{itemdecl}
+template <class T1, class T2>
+ bool operator==(const allocator<T1>&, const allocator<T2>&) throw();
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{true}.
+\end{itemdescr}
+
+\begin{itemdecl}
+template <class T1, class T2>
+ bool operator!=(const allocator<T1>&, const allocator<T2>&) throw();
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\returns\
+\tcode{false}.
+\end{itemdescr}
+
+\editorial{The author of this document ran out of time to complete
+ it. Sorry!}
+
+\section*{Acknowledgments}
+Thanks to Walter Brown and Daniel Kr\"ugler for providing corrections
+and noting omissions to this document.
+
+\bibliographystyle{plain}
+\bibliography{../local}
+
+\end{document}
\ No newline at end of file

Added: sandbox/committee/concepts/stdlib/macros.tex
==============================================================================
--- (empty file)
+++ sandbox/committee/concepts/stdlib/macros.tex 2008-03-03 15:03:07 EST (Mon, 03 Mar 2008)
@@ -0,0 +1,1129 @@
+% Definitions and redefinitions of special commands
+
+\usepackage{babel} % needed for iso dates
+\usepackage{savesym} % suppress duplicate macro definitions
+\usepackage{fancyhdr} % more flexible headers and footers
+\usepackage{listings} % code listings
+\usepackage{longtable} % auto-breaking tables
+\usepackage{remreset} % remove counters from reset list
+\usepackage{booktabs} % fancy tables
+\usepackage{relsize} % provide relative font size changes
+\usepackage[htt]{hyphenat} % hyphenate hyphenated words: conflicts with underscore
+\savesymbol{BreakableUnderscore} % suppress BreakableUnderscore defined in hyphenat
+ % (conflicts with underscore)
+\usepackage{underscore} % remove special status of '_' in ordinary text
+\usepackage{verbatim} % improved verbatim environment
+\usepackage{parskip} % handle non-indented paragraphs "properly"
+\usepackage{array} % new column definitions for tables
+\usepackage[iso]{isodate} % use iso format for dates
+\usepackage{soul} % strikeouts and underlines for difference markups
+\usepackage{color} % define colors for strikeouts and underlines
+
+\usepackage[T1]{fontenc}
+\usepackage{ae}
+\usepackage{mathptmx}
+\usepackage[scaled=.90]{helvet}
+
+%%--------------------------------------------------
+%% Sectioning macros.
+% Each section has a depth, an automatically generated section
+% number, a name, and a short tag. The depth is an integer in
+% the range [0,5]. (If it proves necessary, it wouldn't take much
+% programming to raise the limit from 5 to something larger.)
+
+
+% The basic sectioning command. Example:
+% \Sec1[intro.scope]{Scope}
+% defines a first-level section whose name is "Scope" and whose short
+% tag is intro.scope. The square brackets are mandatory.
+\def\Sec#1[#2]#3{{%
+\ifcase#1\let\s=\chapter
+ \or\let\s=\section
+ \or\let\s=\subsection
+ \or\let\s=\subsubsection
+ \or\let\s=\paragraph
+ \or\let\s=\subparagraph
+ \fi%
+\s[#3]{#3\hfill[#2]}\relax\label{#2}}}
+
+% A convenience feature (mostly for the convenience of the Project
+% Editor, to make it easy to move around large blocks of text):
+% the \rSec macro is just like the \Sec macro, except that depths
+% relative to a global variable, SectionDepthBase. So, for example,
+% if SectionDepthBase is 1,
+% \rSec1[temp.arg.type]{Template type arguments}
+% is equivalent to
+% \Sec2[temp.arg.type]{Template type arguments}
+
+\newcounter{SectionDepthBase}
+\newcounter{scratch}
+
+\def\rSec#1[#2]#3{{%
+\setcounter{scratch}{#1}
+\addtocounter{scratch}{\value{SectionDepthBase}}
+\Sec{\arabic{scratch}}[#2]{#3}}}
+
+% Change the way section headings are formatted.
+%\renewcommand{\chaptername}{}
+\renewcommand{\appendixname}{Annex}
+
+\makeatletter
+\def\@makechapterhead#1{%
+ \hrule\vspace*{1.5\p@}\hrule
+ \vspace*{16\p@}%
+ {\parindent \z@ \raggedright \normalfont
+ \ifnum \c_at_secnumdepth >\m_at_ne
+ \huge\bfseries \@chapapp\space \thechapter\space\space\space\space
+ \fi
+ \interlinepenalty\@M
+ \huge \bfseries #1\par\nobreak
+ \vspace*{16\p@}%
+ \hrule\vspace*{1.5\p@}\hrule
+ \vspace*{48\p@}
+ }}
+
+\renewcommand\section{\@startsection{section}{1}{0pt}%
+ {-3.5ex plus -1ex minus -.2ex}%
+ {.3ex plus .2ex}%
+ {\normalfont\normalsize\bfseries}}
+\renewcommand\section{\@startsection{section}{1}{0pt}%
+ {2.5ex}% plus 1ex minus .2ex}%
+ {.3ex}% plus .1ex minus .2 ex}%
+ {\normalfont\normalsize\bfseries}}
+
+\renewcommand\subsection{\@startsection{subsection}{2}{0pt}%
+ {-3.25ex plus -1ex minus -.2ex}%
+ {.3ex plus .2ex}%
+ {\normalfont\normalsize\bfseries}}
+
+\renewcommand\subsubsection{\@startsection{subsubsection}{3}{0pt}%
+ {-3.25ex plus -1ex minus -.2ex}%
+ {.3ex plus .2ex}%
+ {\normalfont\normalsize\bfseries}}
+
+\renewcommand\paragraph{\@startsection{paragraph}{4}{0pt}%
+ {-3.25ex plus -1ex minus -.2ex}%
+ {.3ex \@plus .2ex}%
+ {\normalfont\normalsize\bfseries}}
+
+\renewcommand\subparagraph{\@startsection{subparagraph}{5}{0pt}%
+ {-3.25ex plus -1ex minus -.2ex}%
+ {.3ex plus .2ex}%
+ {\normalfont\normalsize\bfseries}}
+\makeatother
+
+%%--------------------------------------------------
+% Heading style for Annexes
+\newcommand{\Annex}[3]{\chapter[#2]{\\(#3)\\#2\hfill[#1]}\relax\label{#1}}
+\newcommand{\infannex}[2]{\Annex{#1}{#2}{informative}}
+\newcommand{\normannex}[2]{\Annex{#1}{#2}{normative}}
+
+\newcommand{\synopsis}[1]{\textbf{#1}}
+
+%%--------------------------------------------------
+% General code style
+\newcommand{\CodeStyle}{\ttfamily}
+\newcommand{\CodeStylex}[1]{\texttt{#1}}
+
+% Code and definitions embedded in text.
+\newcommand{\tcode}[1]{\CodeStylex{#1}}
+\newcommand{\techterm}[1]{\textit{#1}}
+
+%%--------------------------------------------------
+%% allow line break if needed for justification
+\newcommand{\brk}{\discretionary{}{}{}}
+% especially for scope qualifier
+\newcommand{\colcol}{\brk::\brk}
+
+%%--------------------------------------------------
+%% Macros for funky text
+\newcommand{\Rplus}{\protect\nolinebreak\hspace{-.07em}\protect\raisebox{.25ex}{\small\textbf{+}}}
+\newcommand{\Cpp}{C\Rplus\Rplus}
+\newcommand{\opt}{$_\mathit{opt}$}
+\newcommand{\shl}{<{<}}
+\newcommand{\shr}{>{>}}
+\newcommand{\dcr}{-{-}}
+
+%% Notes and examples
+\newcommand{\EnterBlock}[1]{[\,\textit{#1:}}
+\newcommand{\ExitBlock}[1]{\textit{\ ---\,end #1}\,]}
+\newcommand{\enternote}{\EnterBlock{Note}}
+\newcommand{\exitnote}{\ExitBlock{note}}
+\newcommand{\enterexample}{\EnterBlock{Example}}
+\newcommand{\exitexample}{\ExitBlock{example}}
+
+%% Library function descriptions
+\newcommand{\Fundescx}[1]{\textit{#1}}
+\newcommand{\Fundesc}[1]{\Fundescx{#1:}}
+\newcommand{\required}{\Fundesc{Required behavior}}
+\newcommand{\requires}{\Fundesc{Requires}}
+\newcommand{\effects}{\Fundesc{Effects}}
+\newcommand{\postconditions}{\Fundesc{Postconditions}}
+\newcommand{\postcondition}{\Fundesc{Postcondition}}
+\newcommand{\preconditions}{\Fundesc{Preconditions}}
+\newcommand{\precondition}{\Fundesc{Precondition}}
+\newcommand{\returns}{\Fundesc{Returns}}
+\newcommand{\throws}{\Fundesc{Throws}}
+\newcommand{\default}{\Fundesc{Default behavior}}
+\newcommand{\complexity}{\Fundesc{Complexity}}
+\newcommand{\note}{\Fundesc{Remark}}
+\newcommand{\notes}{\Fundesc{Remarks}}
+\newcommand{\implimits}{\Fundesc{Implementation limits}}
+\newcommand{\replaceable}{\Fundesc{Replaceable}}
+\newcommand{\exceptionsafety}{\Fundesc{Exception safety}}
+\newcommand{\returntype}{\Fundesc{Return type}}
+\newcommand{\cvalue}{\Fundesc{Value}}
+\newcommand{\ctype}{\Fundesc{Type}}
+
+%% Cross reference
+\newcommand{\xref}{\textsc{See also:}}
+
+%% NTBS, etc.
+\newcommand{\NTS}[1]{\textsc{#1}}
+\newcommand{\ntbs}{\NTS{ntbs}}
+\newcommand{\ntmbs}{\NTS{ntmbs}}
+\newcommand{\ntwcs}{\NTS{ntwcs}}
+
+%% Function argument
+\newcommand{\farg}[1]{\texttt{\textit{#1}}}
+
+%% Code annotations
+\newcommand{\EXPO}[1]{\textbf{#1}}
+\newcommand{\expos}{\EXPO{exposition only}}
+\newcommand{\exposr}{\hfill\expos}
+\newcommand{\exposrc}{\hfill// \expos}
+\newcommand{\impdef}{\EXPO{implementation-defined}}
+\newcommand{\notdef}{\EXPO{not defined}}
+
+%% Double underscore
+\newcommand{\unun}{\_\,\_}
+\newcommand{\xname}[1]{\unun\,#1}
+\newcommand{\mname}[1]{\tcode{\unun\,#1\,\unun}}
+
+%% Ranges
+\newcommand{\Range}[4]{\tcode{#1\brk{}#3,\brk{}#4\brk{}#2}}
+\newcommand{\crange}[2]{\Range{[}{]}{#1}{#2}}
+\newcommand{\orange}[2]{\Range{(}{)}{#1}{#2}}
+\newcommand{\range}[2]{\Range{[}{)}{#1}{#2}}
+
+%% Unspecified et al
+\newcommand{\UNSP}[1]{\textit{#1}}
+\newcommand{\unspec}{\UNSP{unspecified}}
+\newcommand{\unspecbool}{\UNSP{unspecified-bool-type}}
+\newcommand{\unspecnull}{\UNSP{unspecified-null-pointer-type}}
+\newcommand{\seebelow}{\UNSP{see below}}
+%% Change descriptions
+\newcommand{\diffdef}[1]{\hfill\break\textbf{#1:}}
+\newcommand{\change}{\diffdef{Change}}
+\newcommand{\rationale}{\diffdef{Rationale}}
+\newcommand{\effect}{\diffdef{Effect on original feature}}
+\newcommand{\difficulty}{\diffdef{Difficulty of converting}}
+\newcommand{\howwide}{\diffdef{How widely used}}
+
+%% Difference markups
+\definecolor{addclr}{rgb}{0,.4,.4}
+\definecolor{remclr}{rgb}{1,0,0}
+\newcommand{\added}[1]{\textcolor{addclr}{\ul{#1}}}
+\newcommand{\removed}[1]{\textcolor{remclr}{\st{#1}}}
+\newcommand{\changed}[2]{\removed{#1}\added{#2}}
+
+%% October, 2005 changes
+\newcommand{\addedA}[1]{#1}
+\newcommand{\removedA}[1]{}
+\newcommand{\changedA}[2]{#2}
+
+%% April, 2006 changes
+\newcommand{\addedB}[1]{#1}
+\newcommand{\removedB}[1]{}
+\newcommand{\changedB}[2]{#2}
+\newcommand{\marktr}{}
+\makeatletter
+\newcommand\ptr{\noindent\llap{{\footnotesize{TR1:}}\hspace{\@totalleftmargin}\quad}}
+\makeatother
+\newcommand{\addedC}[1]{#1}
+\newcommand{\removedC}[1]{}
+\newcommand{\changedC}[2]{#2}
+\newcommand{\additemC}[1]{\item #1}
+\newcommand{\addedD}[1]{#1}
+\newcommand{\removedD}[1]{}
+\newcommand{\changedD}[2]{#2}
+\newcommand{\remfootnoteD}[1]{}
+
+%% Miscellaneous
+\newcommand{\uniquens}{\textrm{\textit{\textbf{unique}}}}
+\newcommand{\stage}[1]{\item{\textbf{Stage #1:}}}
+
+%%--------------------------------------------------
+%% Adjust markers
+\renewcommand{\thetable}{\arabic{table}}
+\renewcommand{\thefigure}{\arabic{figure}}
+\renewcommand{\thefootnote}{\arabic{footnote})}
+
+%% Change list item markers from box to dash
+\renewcommand{\labelitemi}{---}
+\renewcommand{\labelitemii}{---}
+\renewcommand{\labelitemiii}{---}
+\renewcommand{\labelitemiv}{---}
+
+%%--------------------------------------------------
+%% Environments for code listings.
+
+% We use the 'listings' package, with some small customizations. The
+% most interesting customization: all TeX commands are available
+% within comments. Comments are set in italics, keywords and strings
+% don't get special treatment.
+
+\lstset{language=C++,
+ basicstyle=\CodeStyle\small,
+ keywordstyle=,
+ stringstyle=,
+ xleftmargin=1em,
+ showstringspaces=false,
+ commentstyle=\itshape\rmfamily,
+ columns=flexible,
+ keepspaces=true,
+ texcl=true}
+
+% Our usual abbreviation for 'listings'. Comments are in
+% italics. Arbitrary TeX commands can be used if they're
+% surrounded by @ signs.
+\lstnewenvironment{codeblock}
+{
+ \lstset{escapechar=@}
+ \renewcommand{\tcode}[1]{\textup{\CodeStyle##1}}
+ \renewcommand{\techterm}[1]{\textit{##1}}
+}
+{
+}
+
+% Permit use of '@' inside codeblock blocks (don't ask)
+\makeatletter
+\newcommand{\atsign}{@}
+\makeatother
+
+%%--------------------------------------------------
+%% Paragraph numbering
+\newcounter{Paras}
+\makeatletter
+\@addtoreset{Paras}{chapter}
+\@addtoreset{Paras}{section}
+\@addtoreset{Paras}{subsection}
+\@addtoreset{Paras}{subsubsection}
+\@addtoreset{Paras}{paragraph}
+\@addtoreset{Paras}{subparagraph}
+\def\pnum{\addtocounter{Paras}{1}\noindent\llap{{\footnotesize\arabic{Paras}}\hspace{\@totalleftmargin}\quad}}
+\makeatother
+
+% For compatibility only. We no longer need this environment.
+\newenvironment{paras}{}{}
+
+%%--------------------------------------------------
+%% Indented text
+\newenvironment{indented}
+{\list{}{}\item\relax}
+{\endlist}
+
+%%--------------------------------------------------
+%% Library item descriptions
+\lstnewenvironment{itemdecl}
+{
+ \lstset{escapechar=@,
+ xleftmargin=0em,
+ aboveskip=2ex,
+ belowskip=0ex % leave this alone: it keeps these things out of the
+ % footnote area
+ }
+}
+{
+}
+
+\newenvironment{itemdescr}
+{
+ \begin{indented}}
+{
+ \end{indented}
+}
+
+
+%%--------------------------------------------------
+%% Bnf environments
+\newlength{\BnfIndent}
+\setlength{\BnfIndent}{\leftmargini}
+\newlength{\BnfInc}
+\setlength{\BnfInc}{\BnfIndent}
+\newlength{\BnfRest}
+\setlength{\BnfRest}{2\BnfIndent}
+\newcommand{\BnfNontermshape}{\rmfamily\itshape\small}
+\newcommand{\BnfTermshape}{\ttfamily\upshape\small}
+\newcommand{\nonterminal}[1]{{\BnfNontermshape #1}}
+
+\newenvironment{bnfbase}
+ {
+ \newcommand{\terminal}[1]{{\BnfTermshape ##1}}
+ \newcommand{\descr}[1]{\normalfont{##1}}
+ \newcommand{\bnfindentfirst}{\BnfIndent}
+ \newcommand{\bnfindentinc}{\BnfInc}
+ \newcommand{\bnfindentrest}{\BnfRest}
+ \begin{minipage}{.9\hsize}
+ \newcommand{\br}{\hfill\\}
+ }
+ {
+ \end{minipage}
+ }
+
+\newenvironment{BnfTabBase}[1]
+{
+ \begin{bnfbase}
+ #1
+ \begin{indented}
+ \begin{tabbing}
+ \hspace*{\bnfindentfirst}\=\hspace{\bnfindentinc}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\hspace{.6in}\=\kill%
+}
+{
+ \end{tabbing}
+ \end{indented}
+ \end{bnfbase}
+}
+
+\newenvironment{bnfkeywordtab}
+{
+ \begin{BnfTabBase}{\BnfTermshape}
+}
+{
+ \end{BnfTabBase}
+}
+
+\newenvironment{bnftab}
+{
+ \begin{BnfTabBase}{\BnfNontermshape}
+}
+{
+ \end{BnfTabBase}
+}
+
+\newenvironment{simplebnf}
+{
+ \begin{bnfbase}
+ \BnfNontermshape
+ \begin{indented}
+}
+{
+ \end{indented}
+ \end{bnfbase}
+}
+
+\newenvironment{bnf}
+{
+ \begin{bnfbase}
+ \list{}
+ {
+ \setlength{\leftmargin}{\bnfindentrest}
+ \setlength{\listparindent}{-\bnfindentinc}
+ \setlength{\itemindent}{\listparindent}
+ }
+ \BnfNontermshape
+ \item\relax
+}
+{
+ \endlist
+ \end{bnfbase}
+}
+
+% non-copied versions of bnf environments
+\newenvironment{ncbnftab}
+{
+ \begin{bnftab}
+}
+{
+ \end{bnftab}
+}
+
+\newenvironment{ncsimplebnf}
+{
+ \begin{simplebnf}
+}
+{
+ \end{simplebnf}
+}
+
+\newenvironment{ncbnf}
+{
+ \begin{bnf}
+}
+{
+ \end{bnf}
+}
+
+%%--------------------------------------------------
+%% Drawing environment
+%
+% usage: \begin{drawing}{UNITLENGTH}{WIDTH}{HEIGHT}{CAPTION}
+\newenvironment{drawing}[4]
+{
+\begin{figure}[h]
+\setlength{\unitlength}{#1}
+\begin{center}
+\begin{picture}(#2,#3)\thicklines
+}
+{
+\end{picture}
+\end{center}
+%\caption{Directed acyclic graph}
+\end{figure}
+}
+
+%%--------------------------------------------------
+%% Table environments
+
+% Base definitions for tables
+\newenvironment{TableBase}
+{
+ \renewcommand{\tcode}[1]{{\CodeStyle##1}}
+ \newcommand{\topline}{\hline}
+ \newcommand{\capsep}{\hline\hline}
+ \newcommand{\rowsep}{\hline}
+ \newcommand{\bottomline}{\hline}
+
+%% vertical alignment
+ \newcommand{\rb}[1]{\raisebox{1.5ex}[0pt]{##1}} % move argument up half a row
+
+%% header helpers
+ \newcommand{\hdstyle}[1]{\textbf{##1}} % set header style
+ \newcommand{\Head}[3]{\multicolumn{##1}{##2}{\hdstyle{##3}}} % add title spanning multiple columns
+ \newcommand{\lhdrx}[2]{\Head{##1}{|c}{##2}} % set header for left column spanning #1 columns
+ \newcommand{\chdrx}[2]{\Head{##1}{c}{##2}} % set header for center column spanning #1 columns
+ \newcommand{\rhdrx}[2]{\Head{##1}{c|}{##2}} % set header for right column spanning #1 columns
+ \newcommand{\ohdrx}[2]{\Head{##1}{|c|}{##2}} % set header for only column spanning #1 columns
+ \newcommand{\lhdr}[1]{\lhdrx{1}{##1}} % set header for single left column
+ \newcommand{\chdr}[1]{\chdrx{1}{##1}} % set header for single center column
+ \newcommand{\rhdr}[1]{\rhdrx{1}{##1}} % set header for single right column
+ \newcommand{\ohdr}[1]{\ohdrx{1}{##1}}
+ \newcommand{\br}{\hfill\break} % force newline within table entry
+
+%% column styles
+ \newcolumntype{x}[1]{>{\raggedright\let\\=\tabularnewline}p{##1}} % word-wrapped ragged-right
+ % column, width specified by #1
+ \newcolumntype{m}[1]{>{\CodeStyle}l{##1}} % variable width column, all entries in CodeStyle
+}
+{
+}
+
+% General Usage: TITLE is the title of the table, XREF is the
+% cross-reference for the table. LAYOUT is a sequence of column
+% type specifiers (e.g. cp{1.0}c), without '|' for the left edge
+% or right edge.
+
+% usage: \begin{floattablebase}{TITLE}{XREF}{COLUMNS}{PLACEMENT}
+% produces floating table, location determined within limits
+% by LaTeX.
+\newenvironment{floattablebase}[4]
+{
+ \begin{TableBase}
+ \begin{table}[#4]
+ \caption{\label{#2}#1}
+ \begin{center}
+ \begin{tabular}{|#3|}
+}
+{
+ \bottomline
+ \end{tabular}
+ \end{center}
+ \end{table}
+ \end{TableBase}
+}
+
+% usage: \begin{floattable}{TITLE}{XREF}{COLUMNS}
+% produces floating table, location determined within limits
+% by LaTeX.
+\newenvironment{floattable}[3]
+{
+ \begin{floattablebase}{#1}{#2}{#3}{htbp}
+}
+{
+ \end{floattablebase}
+}
+
+% usage: \begin{tokentable}{TITLE}{XREF}{HDR1}{HDR2}
+% produces six-column table used for lists of replacement tokens;
+% the columns are in pairs -- left-hand column has header HDR1,
+% right hand column has header HDR2; pairs of columns are separated
+% by vertical lines. Used in "trigraph sequences" table in standard.
+\newenvironment{tokentable}[4]
+{
+ \begin{floattablebase}{#1}{#2}{cc|cc|cc}{htbp}
+ \topline
+ \textit{#3} & \textit{#4} &
+ \textit{#3} & \textit{#4} &
+ \textit{#3} & \textit{#4} \\ \capsep
+}
+{
+ \end{floattablebase}
+}
+
+% usage: \begin{libsumtabase}{TITLE}{XREF}{HDR1}{HDR2}
+% produces two-column table with column headers HDR1 and HDR2.
+% Used in "Library Categories" table in standard, and used as
+% base for other library summary tables.
+\newenvironment{libsumtabbase}[4]
+{
+ \begin{floattable}{#1}{#2}{ll}
+ \topline
+ \lhdr{#3} & \hdstyle{#4} \\ \capsep
+}
+{
+ \end{floattable}
+}
+
+% usage: \begin{libsumtab}{TITLE}{XREF}
+% produces two-column table with column headers "Subclause" and "Header(s)".
+% Used in "C++ Headers for Freestanding Implementations" table in standard.
+\newenvironment{libsumtab}[2]
+{
+ \begin{libsumtabbase}{#1}{#2}{Subclause}{Header(s)}
+}
+{
+ \end{libsumtabbase}
+}
+
+% usage: \begin{LibSynTab}{CAPTION}{TITLE}{XREF}{COUNT}{LAYOUT}
+% produces table with COUNT columns. Used as base for
+% C library description tables
+\newcounter{LibSynTabCols}
+\newcounter{LibSynTabWd}
+\newenvironment{LibSynTabBase}[5]
+{
+ \setcounter{LibSynTabCols}{#4}
+ \setcounter{LibSynTabWd}{#4}
+ \addtocounter{LibSynTabWd}{-1}
+ \newcommand{\centry}[1]{\textbf{##1}:}
+ \newcommand{\macro}{\centry{Macro}}
+ \newcommand{\macros}{\centry{Macros}}
+ \newcommand{\function}{\centry{Function}}
+ \newcommand{\functions}{\centry{Functions}}
+ \newcommand{\templates}{\centry{Templates}}
+ \newcommand{\type}{\centry{Type}}
+ \newcommand{\types}{\centry{Types}}
+ \newcommand{\values}{\centry{Values}}
+ \newcommand{\struct}{\centry{Struct}}
+ \newcommand{\cspan}[1]{\multicolumn{\value{LibSynTabCols}}{|l|}{##1}}
+ \begin{floattable}{#1 \tcode{<#2>}\ synopsis}{#3}
+ {#5}
+ \topline
+ \lhdr{Type} & \rhdrx{\value{LibSynTabWd}}{Name(s)} \\ \capsep
+}
+{
+ \end{floattable}
+}
+
+% usage: \begin{LibSynTab}{TITLE}{XREF}{COUNT}{LAYOUT}
+% produces table with COUNT columns. Used as base for description tables
+% for C library
+\newenvironment{LibSynTab}[4]
+{
+ \begin{LibSynTabBase}{Header}{#1}{#2}{#3}{#4}
+}
+{
+ \end{LibSynTabBase}
+}
+
+% usage: \begin{LibSynTabAdd}{TITLE}{XREF}{COUNT}{LAYOUT}
+% produces table with COUNT columns. Used as base for description tables
+% for additions to C library
+\newenvironment{LibSynTabAdd}[4]
+{
+ \begin{LibSynTabBase}{Additions to header}{#1}{#2}{#3}{#4}
+}
+{
+ \end{LibSynTabBase}
+}
+
+% usage: \begin{libsyntabN}{TITLE}{XREF}
+% \begin{libsyntabaddN}{TITLE}{XREF}
+% produces a table with N columns for C library description tables
+\newenvironment{libsyntab2}[2]
+{
+ \begin{LibSynTab}{#1}{#2}{2}{ll}
+}
+{
+ \end{LibSynTab}
+}
+
+\newenvironment{libsyntab3}[2]
+{
+ \begin{LibSynTab}{#1}{#2}{3}{lll}
+}
+{
+ \end{LibSynTab}
+}
+
+\newenvironment{libsyntab4}[2]
+{
+ \begin{LibSynTab}{#1}{#2}{4}{llll}
+}
+{
+ \end{LibSynTab}
+}
+
+\newenvironment{libsyntab5}[2]
+{
+ \begin{LibSynTab}{#1}{#2}{5}{lllll}
+}
+{
+ \end{LibSynTab}
+}
+
+\newenvironment{libsyntab6}[2]
+{
+ \begin{LibSynTab}{#1}{#2}{6}{llllll}
+}
+{
+ \end{LibSynTab}
+}
+
+\newenvironment{libsyntabadd2}[2]
+{
+ \begin{LibSynTabAdd}{#1}{#2}{2}{ll}
+}
+{
+ \end{LibSynTabAdd}
+}
+
+\newenvironment{libsyntabadd3}[2]
+{
+ \begin{LibSynTabAdd}{#1}{#2}{3}{lll}
+}
+{
+ \end{LibSynTabAdd}
+}
+
+\newenvironment{libsyntabadd4}[2]
+{
+ \begin{LibSynTabAdd}{#1}{#2}{4}{llll}
+}
+{
+ \end{LibSynTabAdd}
+}
+
+\newenvironment{libsyntabadd5}[2]
+{
+ \begin{LibSynTabAdd}{#1}{#2}{5}{lllll}
+}
+{
+ \end{LibSynTabAdd}
+}
+
+\newenvironment{libsyntabadd6}[2]
+{
+ \begin{LibSynTabAdd}{#1}{#2}{6}{llllll}
+}
+{
+ \end{LibSynTabAdd}
+}
+
+% usage: \begin{LongTable}{TITLE}{XREF}{LAYOUT}
+% produces table that handles page breaks sensibly.
+\newenvironment{LongTable}[3]
+{
+ \begin{TableBase}
+ \begin{longtable}
+ {|#3|}\caption{#1}\label{#2}
+}
+{
+ \bottomline
+ \end{longtable}
+ \end{TableBase}
+}
+
+% usage: \begin{twocol}{TITLE}{XREF}
+% produces a two-column breakable table. Used in
+% "simple-type-specifiers and the types they specify" in the standard.
+\newenvironment{twocol}[2]
+{
+ \begin{LongTable}
+ {#1}{#2}
+ {ll}
+}
+{
+ \end{LongTable}
+}
+
+% usage: \begin{libreqtabN}{TITLE}{XREF}
+% produces an N-column brekable table. Used in
+% most of the library clauses for requirements tables.
+% Example at "Position type requirements" in the standard.
+
+\newenvironment{libreqtab1}[2]
+{
+ \begin{LongTable}
+ {#1}{#2}
+ {x{.55\hsize}}
+}
+{
+ \end{LongTable}
+}
+
+\newenvironment{libreqtab2}[2]
+{
+ \begin{LongTable}
+ {#1}{#2}
+ {lx{.55\hsize}}
+}
+{
+ \end{LongTable}
+}
+
+\newenvironment{libreqtab2a}[2]
+{
+ \begin{LongTable}
+ {#1}{#2}
+ {x{.30\hsize}x{.68\hsize}}
+}
+{
+ \end{LongTable}
+}
+
+\newenvironment{libreqtab3}[2]
+{
+ \begin{LongTable}
+ {#1}{#2}
+ {x{.28\hsize}x{.18\hsize}x{.43\hsize}}
+}
+{
+ \end{LongTable}
+}
+
+\newenvironment{libreqtab3a}[2]
+{
+ \begin{LongTable}
+ {#1}{#2}
+ {x{.28\hsize}x{.33\hsize}x{.29\hsize}}
+}
+{
+ \end{LongTable}
+}
+
+\newenvironment{libreqtab3b}[2]
+{
+ \begin{LongTable}
+ {#1}{#2}
+ {x{.40\hsize}x{.25\hsize}x{.25\hsize}}
+}
+{
+ \end{LongTable}
+}
+
+\newenvironment{libreqtab3c}[2]
+{
+ \begin{LongTable}
+ {#1}{#2}
+ {x{.30\hsize}x{.25\hsize}x{.35\hsize}}
+}
+{
+ \end{LongTable}
+}
+
+\newenvironment{libreqtab3d}[2]
+{
+ \begin{LongTable}
+ {#1}{#2}
+ {x{.32\hsize}x{.27\hsize}x{.36\hsize}}
+}
+{
+ \end{LongTable}
+}
+
+\newenvironment{libreqtab3e}[2]
+{
+ \begin{LongTable}
+ {#1}{#2}
+ {x{.38\hsize}x{.27\hsize}x{.25\hsize}}
+}
+{
+ \end{LongTable}
+}
+
+\newenvironment{libreqtab3f}[2]
+{
+ \begin{LongTable}
+ {#1}{#2}
+ {x{.40\hsize}x{.22\hsize}x{.31\hsize}}
+}
+{
+ \end{LongTable}
+}
+
+\newenvironment{libreqtab4}[2]
+{
+ \begin{LongTable}
+ {#1}{#2}
+}
+{
+ \end{LongTable}
+}
+
+\newenvironment{libreqtab4a}[2]
+{
+ \begin{LongTable}
+ {#1}{#2}
+ {x{.14\hsize}x{.30\hsize}x{.30\hsize}x{.14\hsize}}
+}
+{
+ \end{LongTable}
+}
+
+\newenvironment{libreqtab4b}[2]
+{
+ \begin{LongTable}
+ {#1}{#2}
+ {x{.13\hsize}x{.15\hsize}x{.29\hsize}x{.27\hsize}}
+}
+{
+ \end{LongTable}
+}
+
+\newenvironment{libreqtab4c}[2]
+{
+ \begin{LongTable}
+ {#1}{#2}
+ {x{.16\hsize}x{.21\hsize}x{.21\hsize}x{.30\hsize}}
+}
+{
+ \end{LongTable}
+}
+
+\newenvironment{libreqtab4d}[2]
+{
+ \begin{LongTable}
+ {#1}{#2}
+ {x{.22\hsize}x{.22\hsize}x{.30\hsize}x{.15\hsize}}
+}
+{
+ \end{LongTable}
+}
+
+\newenvironment{libreqtab5}[2]
+{
+ \begin{LongTable}
+ {#1}{#2}
+ {x{.14\hsize}x{.14\hsize}x{.20\hsize}x{.20\hsize}x{.14\hsize}}
+}
+{
+ \end{LongTable}
+}
+
+% usage: \begin{libtab2}{TITLE}{XREF}{LAYOUT}{HDR1}{HDR2}
+% produces two-column table with column headers HDR1 and HDR2.
+% Used in "seekoff positioning" in the standard.
+\newenvironment{libtab2}[5]
+{
+ \begin{floattable}
+ {#1}{#2}{#3}
+ \topline
+ \lhdr{#4} & \rhdr{#5} \\ \capsep
+}
+{
+ \end{floattable}
+}
+
+% usage: \begin{longlibtab2}{TITLE}{XREF}{LAYOUT}{HDR1}{HDR2}
+% produces two-column table with column headers HDR1 and HDR2.
+\newenvironment{longlibtab2}[5]
+{
+ \begin{LongTable}{#1}{#2}{#3}
+ \\ \topline
+ \lhdr{#4} & \rhdr{#5} \\ \capsep
+}
+{
+ \end{LongTable}
+}
+
+% usage: \begin{LibEffTab}{TITLE}{XREF}{HDR2}{WD2}
+% produces a two-column table with left column header "Element"
+% and right column header HDR2, right column word-wrapped with
+% width specified by WD2.
+\newenvironment{LibEffTab}[4]
+{
+ \begin{libtab2}{#1}{#2}{lp{#4}}{Element}{#3}
+}
+{
+ \end{libtab2}
+}
+
+% Same as LibEffTab except that it uses a long table.
+\newenvironment{longLibEffTab}[4]
+{
+ \begin{longlibtab2}{#1}{#2}{lp{#4}}{Element}{#3}
+}
+{
+ \end{longlibtab2}
+}
+
+% usage: \begin{libefftab}{TITLE}{XREF}
+% produces a two-column effects table with right column
+% header "Effect(s) if set", width 4.5 in. Used in "fmtflags effects"
+% table in standard.
+\newenvironment{libefftab}[2]
+{
+ \begin{LibEffTab}{#1}{#2}{Effect(s) if set}{4.5in}
+}
+{
+ \end{LibEffTab}
+}
+
+% Same as libefftab except that it uses a long table.
+\newenvironment{longlibefftab}[2]
+{
+ \begin{longLibEffTab}{#1}{#2}{Effect(s) if set}{4.5in}
+}
+{
+ \end{longLibEffTab}
+}
+
+% usage: \begin{libefftabmean}{TITLE}{XREF}
+% produces a two-column effects table with right column
+% header "Meaning", width 4.5 in. Used in "seekdir effects"
+% table in standard.
+\newenvironment{libefftabmean}[2]
+{
+ \begin{LibEffTab}{#1}{#2}{Meaning}{4.5in}
+}
+{
+ \end{LibEffTab}
+}
+
+% Same as libefftabmean except that it uses a long table.
+\newenvironment{longlibefftabmean}[2]
+{
+ \begin{longLibEffTab}{#1}{#2}{Meaning}{4.5in}
+}
+{
+ \end{longLibEffTab}
+}
+
+% usage: \begin{libefftabvalue}{TITLE}{XREF}
+% produces a two-column effects table with right column
+% header "Value", width 3 in. Used in "basic_ios::init() effects"
+% table in standard.
+\newenvironment{libefftabvalue}[2]
+{
+ \begin{LibEffTab}{#1}{#2}{Value}{3in}
+}
+{
+ \end{LibEffTab}
+}
+
+% Same as libefftabvalue except that it uses a long table and a
+% slightly wider column.
+\newenvironment{longlibefftabvalue}[2]
+{
+ \begin{longLibEffTab}{#1}{#2}{Value}{3.5in}
+}
+{
+ \end{longLibEffTab}
+}
+
+% usage: \begin{liberrtab}{TITLE}{XREF} produces a two-column table
+% with left column header ``Value'' and right header "Error
+% condition", width 4.5 in. Used in regex clause in the TR.
+
+\newenvironment{liberrtab}[2]
+{
+ \begin{libtab2}{#1}{#2}{lp{4.5in}}{Value}{Error condition}
+}
+{
+ \end{libtab2}
+}
+
+% Like liberrtab except that it uses a long table.
+\newenvironment{longliberrtab}[2]
+{
+ \begin{longlibtab2}{#1}{#2}{lp{4.5in}}{Value}{Error condition}
+}
+{
+ \end{longlibtab2}
+}
+
+% enumerate with lowercase letters
+\newenvironment{enumeratea}
+{
+ \renewcommand{\labelenumi}{\alph{enumi})}
+ \begin{enumerate}
+}
+{
+ \end{enumerate}
+}
+
+% enumerate with arabic numbers
+\newenvironment{enumeraten}
+{
+ \renewcommand{\labelenumi}{\arabic{enumi})}
+ \begin{enumerate}
+}
+{
+ \end{enumerate}
+}
+
+%%--------------------------------------------------
+%% Definitions section
+% usage: \definition{name}{xref}
+\newcommand{\definition}[2]{\rSec2[#2]{#1}}
+% for ISO format, use:
+%\newcommand{\definition}[2]
+% {\hfill\\\vspace{.25ex plus .5ex minus .2ex}\\
+% \addtocounter{subsection}{1}%
+% \textbf{\thesubsection\hfill\relax[#2]}\\
+% \textbf{#1}\label{#2}\\
+% }
+%----------------------------------------------------
+% Doug's macros
+
+% For editorial comments.
+\definecolor{editbackground}{rgb}{.8,.8,.8}
+\newcommand{\einline}[1]{\colorbox{editbackground}{#1}}
+\newcommand{\editorial}[1]{\colorbox{editbackground}{\begin{minipage}{\linewidth}#1\end{minipage}}}
+% For editorial comments as footnotes.
+\newcommand{\efootnote}[1]{\footnote{\editorial{#1}}}
+% For editorial "remove this!" comments
+\newcommand{\eremove}[1]{\textcolor{remclr}{[[\textbf{#1}]]}}
+% Macros that note precisely what we're adding, removing, or changing
+% within a paragraph.
+\newcommand{\addedConcepts}[1]{\added{#1}}
+\newcommand{\removedConcepts}[1]{\removed{#1}}
+\newcommand{\changedConcepts}[2]{\changed{#1}{#2}}
+
+%% Concepts revision 4 changes
+\definecolor{ccadd}{rgb}{0,.6,0}
+\newcommand{\addedCC}[1]{\textcolor{ccadd}{\ul{#1}}}
+\newcommand{\removedCC}[1]{\textcolor{remclr}{\st{#1}}}
+\newcommand{\changedCC}[2]{\removedCC{#1}\addedCC{#2}}
+\newcommand{\remitemCC}[1]{\remitem{#1}}
+\newcommand{\additemCC}[1]{\item\addedCC{#1}}
+
+% Changes for Bellevue pre-meeting mailing
+\definecolor{green}{rgb}{0,.6,0}
+\newcommand{\addedZ}[1]{\textcolor{green}{\ul{#1}}}
+\newcommand{\removedZ}[1]{\textcolor{remclr}{\st{#1}}}
+\newcommand{\changedZ}[2]{\removedZ{#1}\addedZ{#2}}
+\newcommand{\remitemZ}[1]{\remitem{#1}}
+\newcommand{\additemZ}[1]{\item\addedZ{#1}}
+
+% Text common to all of the library proposals
+\newcommand{\libintrotext}[1]{This document proposes changes to #1 of
+ the \Cpp{} Standard Library in order to make full use of
+ concepts~\cite{GregorStroustrup07:concepts_wording_rev_1}. Many of
+ the changes in this document have been verified to work with
+ ConceptGCC and its modified Standard Library implementation. We make
+ every attempt to provide complete backward compatibility with the
+ pre-concept Standard Library, and note each place where we have
+ knowingly changed semantics.
+
+This document is formatted in the same manner as the working draft of
+the \Cpp{} standard (N2284). Future versions of this document will
+track the working draft and the concepts proposal as they
+evolve. Wherever the numbering of a (sub)section matches a section of
+the working paper, the text in this document should be considered
+replacement text, unless editorial comments state otherwise. All
+editorial comments will \einline{have a gray background}. Changes to
+the replacement text are categorized and typeset as
+\addedConcepts{additions}, \removedConcepts{removals}, or
+\changedConcepts{changes}{modifications}.}
\ No newline at end of file

Added: sandbox/committee/concepts/stdlib/refbib.sty
==============================================================================
--- (empty file)
+++ sandbox/committee/concepts/stdlib/refbib.sty 2008-03-03 15:03:07 EST (Mon, 03 Mar 2008)
@@ -0,0 +1,20 @@
+% This style file is a gross hack required to keep the bibliography
+% from starting a new page.
+\renewenvironment{thebibliography}[1]
+ {\section*{\bibname}%
+ \list{\@biblabel{\@arabic\c_at_enumiv}}%
+ {\settowidth\labelwidth{\@biblabel{#1}}%
+ \leftmargin\labelwidth
+ \advance\leftmargin\labelsep
+ \@openbib_at_code
+ \usecounter{enumiv}%
+ \let\p_at_enumiv\@empty
+ \renewcommand\theenumiv{\@arabic\c_at_enumiv}}%
+ \sloppy
+ \clubpenalty4000
+ \@clubpenalty \clubpenalty
+ \widowpenalty4000%
+ \sfcode`\.\@m}
+ {\def\@noitemerr
+ {\@latex_at_warning{Empty `thebibliography' environment}}%
+ \endlist}


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk