Boost logo

Boost-Commit :

From: dgregor_at_[hidden]
Date: 2008-05-07 17:52:23


Author: dgregor
Date: 2008-05-07 17:52:22 EDT (Wed, 07 May 2008)
New Revision: 45202
URL: http://svn.boost.org/trac/boost/changeset/45202

Log:
Lots of work on valarray, but it's not nearly done
Text files modified:
   sandbox/committee/concepts/stdlib/clib-numerics.tex | 2242 +++++++++++++++++++++------------------
   1 files changed, 1195 insertions(+), 1047 deletions(-)

Modified: sandbox/committee/concepts/stdlib/clib-numerics.tex
==============================================================================
--- sandbox/committee/concepts/stdlib/clib-numerics.tex (original)
+++ sandbox/committee/concepts/stdlib/clib-numerics.tex 2008-05-07 17:52:22 EDT (Wed, 07 May 2008)
@@ -31,7 +31,7 @@
 \begin{center}
 \huge
 Concepts for the C++0x Standard Library: Numerics\\
-(Revision 1)
+(Revision 2)
 
 \vspace{0.5in}
 
@@ -44,8 +44,8 @@
 \end{center}
 
 \vspace{1in}
-\par\noindent Document number: N2574=08-0084\vspace{-6pt}
-\par\noindent Revises document number: N2041=06-0111\vspace{-6pt}
+\par\noindent Document number: NNNNN=08-XXXX\vspace{-6pt}
+\par\noindent Revises document number: N2574=08-0084\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}
@@ -53,10 +53,9 @@
 \section*{Introduction}
 \libintrotext{Chapter 26}
 
-\paragraph*{Changes from N2041}
+\paragraph*{Changes from N2574}
 \begin{itemize}
-\item Update to the latest concepts syntax and the appropriate names
- of the core concepts.
+\item TODO
 \end{itemize}
 
 \end{titlepage}
@@ -85,332 +84,6 @@
 \rSec0[lib.numerics]{Numerics library}
 \begin{paras}
 
-\setcounter{section}{5}
-
-\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, HasPlus<auto, Iter::reference> T>
- requires CopyAssignable<T, T::result_type>
- T accumulate(Iter @\farg{first}@, Iter @\farg{last}@, T @\farg{init}@);
- template <InputIterator Iter, class T, Callable<auto, T, Iter::reference> BinaryOperation>
- requires CopyAssignable<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>
- requires HasMultiply<Iter1::reference, Iter2::reference> &&
- HasPlus<T, HasMultiply<Iter1::reference, Iter2::reference>::result_type> &&
- CopyAssignable<
- T,
- HasPlus<T,
- HasMultiply<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, Callable<auto, Iter1::reference, Iter2::reference> BinaryOperation2>
- requires Callable<BinaryOperation1, T, BinaryOperation2::result_type> &&
- CopyAssignable<T, BinaryOperation1::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<auto, InIter::value_type> OutIter>
- requires HasPlus<InIter::value_type> &&
- CopyAssignable<InIter::value_type, HasPlus<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<auto, InIter::value_type> OutIter,
- Callable<auto, InIter::value_type, InIter::value_type> BinaryOperation>
- requires CopyAssignable<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<auto, InIter::value_type> OutIter>
- requires HasMinus<InIter::value_type, InIter::value_type> &&
- CopyAssignable<OutIter, HasMinus<InIter::value_type, InIter::value_type>::result_type> &&
- CopyConstructible<InIter::value_type> && CopyAssignable<InIter::value_type>
- OutIter adjacent_difference(InIter @\farg{first}@, InIter @\farg{last}@,
- OutIter @\farg{result}@);
- template <InputIterator InIter, OutputIterator<auto, InIter::value_type> OutIter,
- Callable<auto, InIter::value_type, InIter::value_type> BinaryOperation>
- requires CopyAssignable<OutIter::reference, BinaryOperation::result_type> &&
- CopyConstructible<InIter::value_type> && CopyAssignable<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, HasPlus<auto, Iter::reference> T>
- requires CopyAssignable<T, T::result_type>
- T accumulate(Iter @\farg{first}@, Iter @\farg{last}@, T @\farg{init}@);
-template <InputIterator Iter, class T, Callable<auto, T, Iter::reference> BinaryOperation>
- requires CopyAssignable<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>
- requires HasMultiply<Iter1::reference, Iter2::reference> &&
- HasPlus<T, HasMultiply<Iter1::reference, Iter2::reference>::result_type> &&
- CopyAssignable<
- T,
- HasPlus<T,
- HasMultiply<Iter1::reference, Iter2::reference>::result_type>::result_type>
- @\textcolor{addclr}{}@T inner_product(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
- Iter2 @\farg{first2}@, T @\farg{init}@);
-template <InputIterator Iter1, InputIterator Iter2, class T,
- class BinaryOperation1, Callable<auto, Iter1::reference, Iter2::reference> BinaryOperation2>
- requires Callable<BinaryOperation1, T, BinaryOperation2::result_type> &&
- CopyAssignable<T, BinaryOperation1::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<auto, InIter::value_type> OutIter>
- requires HasPlus<InIter::value_type> &&
- CopyAssignable<InIter::value_type, HasPlus<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<auto, InIter::value_type> OutIter,
- Callable<auto, InIter::value_type, InIter::value_type> BinaryOperation>
- requires CopyAssignable<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<auto, InIter::value_type> OutIter>
- requires HasMinus<InIter::value_type, InIter::value_type> &&
- CopyAssignable<OutIter, HasMinus<InIter::value_type, InIter::value_type>::result_type> &&
- CopyConstructible<InIter::value_type> && CopyAssignable<InIter::value_type>
- OutIter adjacent_difference(InIter @\farg{first}@, InIter @\farg{last}@,
- OutIter @\farg{result}@);
-template <InputIterator InIter, OutputIterator<auto, InIter::value_type> OutIter,
- Callable<auto, InIter::value_type, InIter::value_type> BinaryOperation>
- requires CopyAssignable<OutIter::reference, BinaryOperation::result_type> &&
- CopyConstructible<InIter::value_type> && CopyAssignable<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 ranges 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}
-
 \setcounter{section}{4}
 \rSec1[numarray]{Numeric arrays}
 
@@ -418,17 +91,33 @@
 \index{valarray@\tcode{<valarray>}}%
 \begin{codeblock}
 namespace std {
- template<@\changedCC{class}{Regular}@ T> class valarray; // An array of type \tcode{T}
+ template<class T>
+ @\addedCC{requires Semiregular<T> \&\& DefaultConstructible<T>}@
+ class valarray; // An array of type \tcode{T}
   class slice; // a BLAS-like slice out of an array
- template<@\changedCC{class}{Regular}@ T> class slice_array;
+ template<class T>
+ @\addedCC{requires Semiregular<T> \&\& DefaultConstructible<T>}@
+ class slice_array;
   class gslice; // a generalized slice out of an array
- template<@\changedCC{class}{Regular}@ T> class gslice_array;
- template<@\changedCC{class}{Regular}@ T> class mask_array; // a masked array
- template<@\changedCC{class}{Regular}@ T> class indirect_array; // an indirected array
-
- @\addedD{template<@\changedCC{class}{Regular}@ T> void swap(valarray<T>\&, valarray<T>\&);}@
- @\addedD{template<@\changedCC{class}{Regular}@ T> void swap(valarray<T>\&\&, valarray<T>\&);}@
- @\addedD{template<@\changedCC{class}{Regular}@ T> void swap(valarray<T>\&, valarray<T>\&\&);}@
+ template<class T>
+ @\addedCC{requires Semiregular<T> \&\& DefaultConstructible<T>}@
+ class gslice_array;
+ template<class T>
+ @\addedCC{requires Semiregular<T> \&\& DefaultConstructible<T>}@
+ class mask_array; // a masked array
+ template<class T>
+ @\addedCC{requires Semiregular<T> \&\& DefaultConstructible<T>}@
+ class indirect_array; // an indirected array
+
+ template<class T>
+ @\addedCC{requires Semiregular<T> \&\& DefaultConstructible<T>}@
+ void swap(valarray<T>&, valarray<T>&);
+ template<class T>
+ @\addedCC{requires Semiregular<T> \&\& DefaultConstructible<T>}@
+ void swap(valarray<T>&&, valarray<T>&);
+ template<class T>
+ @\addedCC{requires Semiregular<T> \&\& DefaultConstructible<T>}@
+ void swap(valarray<T>&, valarray<T>&&);
 
   template<class T>
     @\addedCC{requires HasMultiply<T> \&\& Convertible<T::result_type, T>}@
@@ -531,50 +220,80 @@
     valarray<T> operator>>(const T&, const valarray<T>&);
 
   template<class T>
- @\addedCC{requires HasLogicalAnd<T> \&\& Convertible<T::result_type, T>}@
+ @\addedCC{requires HasLogicalAnd<T>}@
     valarray<bool> operator&&(const valarray<T>&, const valarray<T>&);
   template<class T>
- @\addedCC{requires HasLogicalAnd<T> \&\& Convertible<T::result_type, T>}@
+ @\addedCC{requires HasLogicalAnd<T>}@
     valarray<bool> operator&&(const valarray<T>&, const T&);
   template<class T>
- @\addedCC{requires HasLogicalAnd<T> \&\& Convertible<T::result_type, T>}@
+ @\addedCC{requires HasLogicalAnd<T>}@
     valarray<bool> operator&&(const T&, const valarray<T>&);
 
   template<class T>
- @\addedCC{requires HasLogicalOr<T> \&\& Convertible<T::result_type, T>}@
+ @\addedCC{requires HasLogicalOr<T>}@
     valarray<bool> operator||(const valarray<T>&, const valarray<T>&);
   template<class T>
- @\addedCC{requires HasLogicalOr<T> \&\& Convertible<T::result_type, T>}@
+ @\addedCC{requires HasLogicalOr<T>}@
     valarray<bool> operator||(const valarray<T>&, const T&);
   template<class T>
- @\addedCC{requires HasLogicalOr<T> \&\& Convertible<T::result_type, T>}@
+ @\addedCC{requires HasLogicalOr<T>}@
     valarray<bool> operator||(const T&, const valarray<T>&);
 
   template<class T>
+ @\addedCC{requires EqualityComparable<T>}@
     valarray<bool> operator==(const valarray<T>&, const valarray<T>&);
- template<class T> valarray<bool> operator==(const valarray<T>&, const T&);
- template<class T> valarray<bool> operator==(const T&, const valarray<T>&);
+ template<class T>
+ @\addedCC{requires EqualityComparable<T>}@
+ valarray<bool> operator==(const valarray<T>&, const T&);
+ template<class T>
+ @\addedCC{requires EqualityComparable<T>}@
+ valarray<bool> operator==(const T&, const valarray<T>&);
   template<class T>
+ @\addedCC{requires EqualityComparable<T>}@
     valarray<bool> operator!=(const valarray<T>&, const valarray<T>&);
- template<class T> valarray<bool> operator!=(const valarray<T>&, const T&);
- template<class T> valarray<bool> operator!=(const T&, const valarray<T>&);
+ template<class T>
+ @\addedCC{requires EqualityComparable<T>}@
+ valarray<bool> operator!=(const valarray<T>&, const T&);
+ template<class T>
+ @\addedCC{requires EqualityComparable<T>}@
+ valarray<bool> operator!=(const T&, const valarray<T>&);
 
   template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
     valarray<bool> operator< (const valarray<T>&, const valarray<T>&);
- template<class T> valarray<bool> operator< (const valarray<T>&, const T&);
- template<class T> valarray<bool> operator< (const T&, const valarray<T>&);
+ template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator< (const valarray<T>&, const T&);
+ template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator< (const T&, const valarray<T>&);
   template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
     valarray<bool> operator> (const valarray<T>&, const valarray<T>&);
- template<class T> valarray<bool> operator> (const valarray<T>&, const T&);
- template<class T> valarray<bool> operator> (const T&, const valarray<T>&);
+ template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator> (const valarray<T>&, const T&);
+ template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator> (const T&, const valarray<T>&);
   template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
     valarray<bool> operator<=(const valarray<T>&, const valarray<T>&);
- template<class T> valarray<bool> operator<=(const valarray<T>&, const T&);
- template<class T> valarray<bool> operator<=(const T&, const valarray<T>&);
+ template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator<=(const valarray<T>&, const T&);
+ template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator<=(const T&, const valarray<T>&);
   template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
     valarray<bool> operator>=(const valarray<T>&, const valarray<T>&);
- template<class T> valarray<bool> operator>=(const valarray<T>&, const T&);
- template<class T> valarray<bool> operator>=(const T&, const valarray<T>&);
+ template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator>=(const valarray<T>&, const T&);
+ template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator>=(const T&, const valarray<T>&);
 
   template<class T> valarray<T> abs (const valarray<T>&);
   template<class T> valarray<T> acos (const valarray<T>&);
@@ -688,7 +407,8 @@
 \index{valarray@\tcode{valarray}}%
 \begin{codeblock}
 namespace std {
- template<class @\farg{T}@> class valarray {
+ template<class @\farg{T}@> @\addedCC{requires Semiregular<T> \&\& DefaultConstructible<T>}@
+ class valarray {
   public:
     typedef T value_type;
 
@@ -729,10 +449,13 @@
     indirect_array<T> operator[](const valarray<size_t>&);
 
     // \ref{valarray.unary} unary operators:
- valarray<T> operator+() const;
- valarray<T> operator-() const;
- valarray<T> operator~() const;
- valarray<bool> operator!() const;
+ @\addedCC{requires HasUnaryPlus<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator+() const;
+ @\addedCC{requires HasNegate<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator-() const;
+ @\addedCC{requires HasComplement<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator~() const;
+ @\addedCC{requires HasLogicalNot<T>}@ valarray<bool> operator!() const;
 
     // \ref{valarray.cassign} computed assignment:
     valarray<T>& operator*= (const T&);
@@ -1135,19 +858,22 @@
 \index{operator\~{}@\tcode{operator\~{}}!\tcode{valarray}}%
 \index{operator"!@\tcode{operator"!}!\tcode{valarray}}%
 \begin{itemdecl}
-valarray<T> operator+() const;
-valarray<T> operator-() const;
-valarray<T> operator~() const;
-valarray<bool> operator!() const;
+@\addedCC{requires HasUnaryPlus<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator+() const;
+@\addedCC{requires HasNegate<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator-() const;
+@\addedCC{requires HasComplement<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator~() const;
+@\addedCC{requires HasLogicalNot<T>}@ valarray<bool> operator!() const;
 \end{itemdecl}
 
 \begin{itemdescr}
 \pnum
-Each of these operators may only be instantiated for a type \farg{T}\
+\removedCC{Each of these operators may only be instantiated for a type \mbox{\farg{T}}\
 to which the indicated operator can be applied and for which the indicated
-operator returns a value which is of type \farg{T}\ (\farg{bool}\ for
-\farg{operator!}) or which may be unambiguously converted to type
-\farg{T}\ (\farg{bool} for \farg{operator!}).
+operator returns a value which is of type \mbox{\farg{T}}\ (\mbox{\farg{bool}}\ for
+\mbox{\farg{operator!}}) or which may be unambiguously converted to type
+\mbox{\farg{T}}\ (\mbox{\farg{bool}} for \mbox{\farg{operator!}}).}
 
 \pnum
 Each of these operators returns an array whose length is equal to the length
@@ -1418,34 +1144,44 @@
 \index{operator\&\&@\tcode{operator\&\&}!valarray@\tcode{valarray}}%
 \index{operator||@\tcode{operator||}!valarray@\tcode{valarray}}%
 \begin{itemdecl}
-template<class T> valarray<T> operator*
- (const valarray<T>&, const valarray<T>&);
-template<class T> valarray<T> operator/
- (const valarray<T>&, const valarray<T>&);
-template<class T> valarray<T> operator%
- (const valarray<T>&, const valarray<T>&);
-template<class T> valarray<T> operator+
- (const valarray<T>&, const valarray<T>&);
-template<class T> valarray<T> operator-
- (const valarray<T>&, const valarray<T>&);
-template<class T> valarray<T> operator^
- (const valarray<T>&, const valarray<T>&);
-template<class T> valarray<T> operator&
- (const valarray<T>&, const valarray<T>&);
-template<class T> valarray<T> operator|
- (const valarray<T>&, const valarray<T>&);
-template<class T> valarray<T> operator<<
- (const valarray<T>&, const valarray<T>&);
-template<class T> valarray<T> operator>>
- (const valarray<T>&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasMultiply<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator*(const valarray<T>&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasDivide<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator/(const valarray<T>&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasModulus<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator%(const valarray<T>&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasPlus<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator+(const valarray<T>&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasMinus<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator-(const valarray<T>&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasBitXor<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator^(const valarray<T>&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasBitAnd<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator&(const valarray<T>&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasBitOr<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator|(const valarray<T>&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasLeftShift<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator<<(const valarray<T>&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasRightShift<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator>>(const valarray<T>&, const valarray<T>&);
 \end{itemdecl}
 
 \begin{itemdescr}
 \pnum
-Each of these operators may only be instantiated for a type \farg{T}\
+\removedCC{Each of these operators may only be instantiated for a type \mbox{\farg{T}}\
 to which the indicated operator can be applied and for which the indicated
-operator returns a value which is of type \farg{T}\ or which
-can be unambiguously converted to type \farg{T}.
+operator returns a value which is of type \mbox{\farg{T}}\ or which
+can be unambiguously converted to type \mbox{\farg{T}}.}
 
 \pnum
 Each of these operators returns an array whose length is equal to the
@@ -1460,276 +1196,661 @@
 \end{itemdescr}
 
 \begin{itemdecl}
-template<class T> valarray<T> operator* (const valarray<T>&, const T&);
-template<class T> valarray<T> operator* (const T&, const valarray<T>&);
-template<class T> valarray<T> operator/ (const valarray<T>&, const T&);
-template<class T> valarray<T> operator/ (const T&, const valarray<T>&);
-template<class T> valarray<T> operator% (const valarray<T>&, const T&);
-template<class T> valarray<T> operator% (const T&, const valarray<T>&);
-template<class T> valarray<T> operator+ (const valarray<T>&, const T&);
-template<class T> valarray<T> operator+ (const T&, const valarray<T>&);
-template<class T> valarray<T> operator- (const valarray<T>&, const T&);
-template<class T> valarray<T> operator- (const T&, const valarray<T>&);
-template<class T> valarray<T> operator^ (const valarray<T>&, const T&);
-template<class T> valarray<T> operator^ (const T&, const valarray<T>&);
-template<class T> valarray<T> operator& (const valarray<T>&, const T&);
-template<class T> valarray<T> operator& (const T&, const valarray<T>&);
-template<class T> valarray<T> operator| (const valarray<T>&, const T&);
-template<class T> valarray<T> operator| (const T&, const valarray<T>&);
-template<class T> valarray<T> operator<<(const valarray<T>&, const T&);
-template<class T> valarray<T> operator<<(const T&, const valarray<T>&);
-template<class T> valarray<T> operator>>(const valarray<T>&, const T&);
-template<class T> valarray<T> operator>>(const T&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasMultiply<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator* (const valarray<T>&, const T&);
+template<class T>
+ @\addedCC{requires HasMultiply<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator* (const T&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasDivide<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator/ (const valarray<T>&, const T&);
+template<class T>
+ @\addedCC{requires HasDivide<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator/ (const T&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasModulus<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator% (const valarray<T>&, const T&);
+template<class T>
+ @\addedCC{requires HasModulus<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator% (const T&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasPlus<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator+ (const valarray<T>&, const T&);
+template<class T>
+ @\addedCC{requires HasPlus<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator+ (const T&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasMinus<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator- (const valarray<T>&, const T&);
+template<class T>
+ @\addedCC{requires HasMinus<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator- (const T&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasBitXor<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator^ (const valarray<T>&, const T&);
+template<class T>
+ @\addedCC{requires HasBitXor<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator^ (const T&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasBitAnd<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator& (const valarray<T>&, const T&);
+template<class T>
+ @\addedCC{requires HasBitAnd<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator& (const T&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasBitOr<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator| (const valarray<T>&, const T&);
+template<class T>
+ @\addedCC{requires HasBitOr<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator| (const T&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasLeftShift<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator<<(const valarray<T>&, const T&);
+template<class T>
+ @\addedCC{requires HasLeftShift<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator<<(const T&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasRightShift<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator>>(const valarray<T>&, const T&);
+template<class T>
+ @\addedCC{requires HasRightShift<T> \&\& Convertible<T::result_type, T>}@
+ valarray<T> operator>>(const T&, const valarray<T>&);
 \end{itemdecl}
 
 \begin{itemdescr}
 \pnum
-Each of these operators may only be instantiated for a type \farg{T}\
+\removedCC{Each of these operators may only be instantiated for a type \mbox{\farg{T}}\
+to which the indicated operator can be applied and for which
+the indicated operator returns a value which is of type \mbox{\farg{T}}\
+or which can be unambiguously converted to type \mbox{\farg{T}}.}
+
+\pnum
+Each of these operators returns an array whose length is equal to the
+length of the array argument.
+Each element of the returned array is
+initialized with the result of applying the indicated operator to the
+corresponding element of the array argument and the non-array argument.
+\end{itemdescr}
+
+\rSec3[valarray.comparison]{\tcode{valarray}\ logical operators}
+
+\index{operator==@\tcode{operator==}!valarray@\tcode{valarray}}%
+\index{operator"!=@\tcode{operator"!=}!valarray@\tcode{valarray}}%
+\index{operator<@\tcode{operator<}!valarray@\tcode{valarray}}%
+\index{operator>@\tcode{operator>}!valarray@\tcode{valarray}}%
+\index{operator<=@\tcode{operator<=}!valarray@\tcode{valarray}}%
+\index{operator>=@\tcode{operator>=}!valarray@\tcode{valarray}}%
+\index{operator\&\&@\tcode{operator\&\&}!valarray@\tcode{valarray}}%
+\index{operator||@\tcode{operator||}!valarray@\tcode{valarray}}%
+\begin{itemdecl}
+template<class T>
+ @\addedCC{requires EqualityComparable<T>}@
+ valarray<bool> operator==(const valarray<T>&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires EqualityComparable<T>}@
+ valarray<bool> operator!=(const valarray<T>&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator<(const valarray<T>&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator>(const valarray<T>&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator<=(const valarray<T>&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator>=(const valarray<T>&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasLogicalAnd<T>}@
+ valarray<bool> operator&&(const valarray<T>&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasLogicalOr<T>}@
+ valarray<bool> operator||(const valarray<T>&, const valarray<T>&);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedCC{Each of these operators may only be instantiated for a type \mbox{\farg{T}}\
+to which the indicated operator can be applied and for which
+the indicated operator returns a value which is of type \mbox{\farg{bool}}\
+or which can be unambiguously converted to type \mbox{\farg{bool}}.}
+
+\pnum
+Each of these operators returns a \farg{bool}\ array whose length
+is equal to the length of the array arguments.
+Each element of the returned
+array is initialized with the result of applying the indicated
+operator to the corresponding elements of the argument arrays.
+
+\pnum
+If the two array arguments do not have the same length,
+the behavior is undefined.%
+\index{undefined}
+\end{itemdescr}
+
+\begin{itemdecl}
+template<class T>
+ @\addedCC{requires EqualityComparable<T>}@
+ valarray<bool> operator==(const valarray<T>&, const T&);
+template<class T>
+ @\addedCC{requires EqualityComparable<T>}@
+ valarray<bool> operator==(const T&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires EqualityComparable<T>}@
+ valarray<bool> operator!=(const valarray<T>&, const T&);
+template<class T>
+ @\addedCC{requires EqualityComparable<T>}@
+ valarray<bool> operator!=(const T&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator< (const valarray<T>&, const T&);
+template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator< (const T&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator> (const valarray<T>&, const T&);
+template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator> (const T&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator<=(const valarray<T>&, const T&);
+template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator<=(const T&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator>=(const valarray<T>&, const T&);
+template<class T>
+ @\addedCC{requires LessThanComparable<T>}@
+ valarray<bool> operator>=(const T&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasLogicalAnd<T>}@
+ valarray<bool> operator&&(const valarray<T>&, const T&);
+template<class T>
+ @\addedCC{requires HasLogicalAnd<T>}@
+ valarray<bool> operator&&(const T&, const valarray<T>&);
+template<class T>
+ @\addedCC{requires HasLogicalOr<T>}@
+ valarray<bool> operator||(const valarray<T>&, const T&);
+template<class T>
+ @\addedCC{requires HasLogicalOr<T>}@
+ valarray<bool> operator||(const T&, const valarray<T>&);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\removedCC{Each of these operators may only be instantiated for a type \mbox{\farg{T}}\
 to which the indicated operator can be applied and for which
-the indicated operator returns a value which is of type \farg{T}\
+the indicated operator returns a value which is of type \mbox{\farg{bool}}\
+or which can be unambiguously converted to type \mbox{\farg{bool}}.}
+
+\pnum
+Each of these operators returns a \farg{bool}\ array whose
+length is equal to the length of the array argument.
+Each element
+of the returned array is initialized with the result of applying the
+indicated operator to the corresponding element of the array and the non-array argument.
+\end{itemdescr}
+
+\rSec3[valarray.transcend]{\tcode{valarray}\ transcendentals}
+
+\index{abs@\tcode{abs}}%
+\index{acos@\tcode{acos}}%
+\index{asin@\tcode{asin}}%
+\index{atan@\tcode{atan}}%
+\index{atan2@\tcode{atan2}}%
+\index{cos@\tcode{cos}}%
+\index{cosh@\tcode{cosh}}%
+\index{exp@\tcode{exp}}%
+\index{log@\tcode{log}}%
+\index{log10@\tcode{log10}}%
+\index{pow@\tcode{pow}}%
+\index{sin@\tcode{sin}}%
+\index{sinh@\tcode{sinh}}%
+\index{sqrt@\tcode{sqrt}}%
+\index{tan@\tcode{tan}}%
+\index{tanh@\tcode{tanh}}%
+\begin{itemdecl}
+template<class T> valarray<T> abs (const valarray<T>&);
+template<class T> valarray<T> acos (const valarray<T>&);
+template<class T> valarray<T> asin (const valarray<T>&);
+template<class T> valarray<T> atan (const valarray<T>&);
+template<class T> valarray<T> atan2
+ (const valarray<T>&, const valarray<T>&);
+template<class T> valarray<T> atan2(const valarray<T>&, const T&);
+template<class T> valarray<T> atan2(const T&, const valarray<T>&);
+template<class T> valarray<T> cos (const valarray<T>&);
+template<class T> valarray<T> cosh (const valarray<T>&);
+template<class T> valarray<T> exp (const valarray<T>&);
+template<class T> valarray<T> log (const valarray<T>&);
+template<class T> valarray<T> log10(const valarray<T>&);
+template<class T> valarray<T> pow
+ (const valarray<T>&, const valarray<T>&);
+template<class T> valarray<T> pow (const valarray<T>&, const T&);
+template<class T> valarray<T> pow (const T&, const valarray<T>&);
+template<class T> valarray<T> sin (const valarray<T>&);
+template<class T> valarray<T> sinh (const valarray<T>&);
+template<class T> valarray<T> sqrt (const valarray<T>&);
+template<class T> valarray<T> tan (const valarray<T>&);
+template<class T> valarray<T> tanh (const valarray<T>&);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+Each of these functions may only be instantiated for a type \farg{T}\
+to which a unique function with the indicated name can be applied (unqualified).
+This function shall return a value which is of type \farg{T}\
 or which can be unambiguously converted to type \farg{T}.
+\end{itemdescr}
+
+\rSec3[valarray.special]{\tcode{valarray}\ specialized algorithms}
+
+\begin{itemdecl}
+template <class T>
+ @\addedCC{requires Semiregular<T> \&\& DefaultConstructible<T>}@
+ void swap(valarray<T>& x, valarray<T>& y);
+template <class T>
+ @\addedCC{requires Semiregular<T> \&\& DefaultConstructible<T>}@
+ void swap(valarray<T>&& x, valarray<T>& y);
+template <class T>
+ @\addedCC{requires Semiregular<T> \&\& DefaultConstructible<T>}@
+ void swap(valarray<T>& x, valarray<T>&& y);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\addedD{\mbox{\effects} \mbox{\tcode{x.swap(y)}}.}
+\end{itemdescr}
+
+
+\rSec2[class.slice]{Class \tcode{slice}}
+
+\index{slice@\tcode{slice}}%
+\begin{codeblock}
+namespace std {
+ class slice {
+ public:
+ slice();
+ slice(size_t, size_t, size_t);
+
+ size_t start() const;
+ size_t size() const;
+ size_t stride() const;
+ };
+}
+\end{codeblock}
+
+\pnum
+The
+\tcode{slice}\
+class represents a BLAS-like slice from an array.
+Such a slice is specified by a starting index, a length, and a stride.%
+\footnote{
+BLAS stands for
+\textit{Basic Linear Algebra Subprograms.}\
+\Cpp\ programs may instantiate this class.
+See, for example,
+Dongarra, Du Croz, Duff, and Hammerling:
+\textit{A set of Level 3 Basic Linear Algebra Subprograms};
+Technical Report MCS-P1-0888,
+Argonne National Laboratory (USA),
+Mathematics and Computer Science Division,
+August, 1988.
+}
+
+\rSec3[cons.slice]{\tcode{slice}\ constructors}
+
+\index{slice@\tcode{slice}!\tcode{slice}}%
+\begin{itemdecl}
+slice();
+slice(size_t @\farg{start}@, size_t @\farg{length}@, size_t @\farg{stride}@);
+slice(const slice&);
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+\changedD{The default constructor for
+\mbox{\tcode{slice}}
+creates a
+\mbox{\tcode{slice}}
+which specifies no elements.}
+{The default constructor is equivalent to \mbox{\tcode{slice(0, 0, 0)}}.}
+A default constructor is provided only to permit the declaration of arrays of slices.
+The constructor with arguments for a slice takes a start, length, and stride
+parameter.
+
+\pnum
+\enterexample\
+\tcode{slice(3, 8, 2)}\
+constructs a slice which selects elements 3, 5, 7, ... 17 from an array.
+\exitexample\
+\end{itemdescr}
+
+\rSec3[slice.access]{\tcode{slice}\ access functions}
+\index{start@\tcode{start}!\tcode{slice}}%
+\index{size@\tcode{size}!\tcode{slice}}%
+\index{stride@\tcode{stride}!\tcode{slice}}%
+\begin{itemdecl}
+size_t start() const;
+size_t size() const;
+size_t stride() const;
+\end{itemdecl}
+
+\begin{itemdescr}
+\pnum
+These functions return the start, length, or stride specified by a
+\tcode{slice}\ object.
+\end{itemdescr}
+
+\rSec2[template.slice.array]{Class template \tcode{slice_array}}
+
+\index{slice_array@\tcode{slice_array}}%
+\begin{codeblock}
+namespace std {
+ template <class T> class slice_array {
+ public:
+ typedef T value_type;
+
+ void operator= (const valarray<T>&) const;
+ void operator*= (const valarray<T>&) const;
+ void operator/= (const valarray<T>&) const;
+ void operator%= (const valarray<T>&) const;
+ void operator+= (const valarray<T>&) const;
+ void operator-= (const valarray<T>&) const;
+ void operator^= (const valarray<T>&) const;
+ void operator&= (const valarray<T>&) const;
+ void operator|= (const valarray<T>&) const;
+ void operator<<=(const valarray<T>&) const;
+ void operator>>=(const valarray<T>&) const;
+
+ slice_array(const slice_array&);
+ ~slice_array();
+ slice_array& operator=(const slice_array&);
+ void operator=(const T&) const;
+ private:
+ slice_array();
+ };
+}
+\end{codeblock}
+
+\pnum
+The
+\tcode{slice_array}\
+template is a helper template used by the
+\tcode{slice}\
+subscript operator
+
+\begin{codeblock}
+slice_array<T> valarray<T>::operator[](slice);
+\end{codeblock}
+
+It has reference semantics to a subset of an array specified by a
+\tcode{slice}
+object.
 
 \pnum
-Each of these operators returns an array whose length is equal to the
-length of the array argument.
-Each element of the returned array is
-initialized with the result of applying the indicated operator to the
-corresponding element of the array argument and the non-array argument.
-\end{itemdescr}
+\enterexample\
+The expression
+\tcode{a[slice(1, 5, 3)] = b;}\
+has the effect of assigning the elements of
+\tcode{b}\
+to a slice of the elements in
+\tcode{a}.
+For the slice shown, the elements
+selected from
+\tcode{a}\
+are 1, 4, ..., 13.
+\exitexample\
 
-\rSec3[valarray.comparison]{\tcode{valarray}\ logical operators}
+\rSec3[cons.slice.arr]{\tcode{slice_array}\ constructors}
 
-\index{operator==@\tcode{operator==}!valarray@\tcode{valarray}}%
-\index{operator"!=@\tcode{operator"!=}!valarray@\tcode{valarray}}%
-\index{operator<@\tcode{operator<}!valarray@\tcode{valarray}}%
-\index{operator>@\tcode{operator>}!valarray@\tcode{valarray}}%
-\index{operator<=@\tcode{operator<=}!valarray@\tcode{valarray}}%
-\index{operator>=@\tcode{operator>=}!valarray@\tcode{valarray}}%
-\index{operator\&\&@\tcode{operator\&\&}!valarray@\tcode{valarray}}%
-\index{operator||@\tcode{operator||}!valarray@\tcode{valarray}}%
+\index{slice_array@\tcode{slice_array}!\tcode{slice_array}}%
 \begin{itemdecl}
-template<class T> valarray<bool> operator==
- (const valarray<T>&, const valarray<T>&);
-template<class T> valarray<bool> operator!=
- (const valarray<T>&, const valarray<T>&);
-template<class T> valarray<bool> operator<
- (const valarray<T>&, const valarray<T>&);
-template<class T> valarray<bool> operator>
- (const valarray<T>&, const valarray<T>&);
-template<class T> valarray<bool> operator<=
- (const valarray<T>&, const valarray<T>&);
-template<class T> valarray<bool> operator>=
- (const valarray<T>&, const valarray<T>&);
-template<class T> valarray<bool> operator&&
- (const valarray<T>&, const valarray<T>&);
-template<class T> valarray<bool> operator||
- (const valarray<T>&, const valarray<T>&);
+slice_array();
 \end{itemdecl}
 
 \begin{itemdescr}
 \pnum
-Each of these operators may only be instantiated for a type \farg{T}\
-to which the indicated operator can be applied and for which
-the indicated operator returns a value which is of type \farg{bool}\
-or which can be unambiguously converted to type \farg{bool}.
-
-\pnum
-Each of these operators returns a \farg{bool}\ array whose length
-is equal to the length of the array arguments.
-Each element of the returned
-array is initialized with the result of applying the indicated
-operator to the corresponding elements of the argument arrays.
-
-\pnum
-If the two array arguments do not have the same length,
-the behavior is undefined.%
-\index{undefined}
+This constructor is declared to be private.
+This constructor need not be defined.
 \end{itemdescr}
 
+\rSec3[slice.arr.assign]{\tcode{slice_array}\ assignment}
+
+\index{operator=@\tcode{operator=}!\tcode{slice_array}}%
 \begin{itemdecl}
-template<class T> valarray<bool> operator==(const valarray<T>&, const T&);
-template<class T> valarray<bool> operator==(const T&, const valarray<T>&);
-template<class T> valarray<bool> operator!=(const valarray<T>&, const T&);
-template<class T> valarray<bool> operator!=(const T&, const valarray<T>&);
-template<class T> valarray<bool> operator< (const valarray<T>&, const T&);
-template<class T> valarray<bool> operator< (const T&, const valarray<T>&);
-template<class T> valarray<bool> operator> (const valarray<T>&, const T&);
-template<class T> valarray<bool> operator> (const T&, const valarray<T>&);
-template<class T> valarray<bool> operator<=(const valarray<T>&, const T&);
-template<class T> valarray<bool> operator<=(const T&, const valarray<T>&);
-template<class T> valarray<bool> operator>=(const valarray<T>&, const T&);
-template<class T> valarray<bool> operator>=(const T&, const valarray<T>&);
-template<class T> valarray<bool> operator&&(const valarray<T>&, const T&);
-template<class T> valarray<bool> operator&&(const T&, const valarray<T>&);
-template<class T> valarray<bool> operator||(const valarray<T>&, const T&);
-template<class T> valarray<bool> operator||(const T&, const valarray<T>&);
+void operator=(const valarray<T>&) const;
+slice_array& operator=(const slice_array&);
 \end{itemdecl}
 
 \begin{itemdescr}
 \pnum
-Each of these operators may only be instantiated for a type \farg{T}\
-to which the indicated operator can be applied and for which
-the indicated operator returns a value which is of type \farg{bool}\
-or which can be unambiguously converted to type \farg{bool}.
-
-\pnum
-Each of these operators returns a \farg{bool}\ array whose
-length is equal to the length of the array argument.
-Each element
-of the returned array is initialized with the result of applying the
-indicated operator to the corresponding element of the array and the non-array argument.
+These assignment operators have reference semantics,
+assigning the values of the argument array elements to selected
+elements of the
+\tcode{valarray<T>}\
+object to which the
+\tcode{slice_array}\
+object refers.
 \end{itemdescr}
 
-\rSec3[valarray.transcend]{\tcode{valarray}\ transcendentals}
+\rSec3[slice.arr.comp.assign]{\tcode{slice_array}\ computed assignment}
 
-\index{abs@\tcode{abs}}%
-\index{acos@\tcode{acos}}%
-\index{asin@\tcode{asin}}%
-\index{atan@\tcode{atan}}%
-\index{atan2@\tcode{atan2}}%
-\index{cos@\tcode{cos}}%
-\index{cosh@\tcode{cosh}}%
-\index{exp@\tcode{exp}}%
-\index{log@\tcode{log}}%
-\index{log10@\tcode{log10}}%
-\index{pow@\tcode{pow}}%
-\index{sin@\tcode{sin}}%
-\index{sinh@\tcode{sinh}}%
-\index{sqrt@\tcode{sqrt}}%
-\index{tan@\tcode{tan}}%
-\index{tanh@\tcode{tanh}}%
+\index{operator*=@\tcode{operator*=}!\tcode{slice_array}}%
+\index{operator/=@\tcode{operator/=}!\tcode{slice_array}}%
+\index{operator\%=@\tcode{operator\%=}!\tcode{slice_array}}%
+\index{operator+=@\tcode{operator+=}!\tcode{slice_array}}%
+\index{operator-=@\tcode{operator-=}!\tcode{slice_array}}%
+\index{operator\^{}=@\tcode{operator\^{}=}!\tcode{slice_array}}%
+\index{operator\&=@\tcode{operator\&=}!\tcode{slice_array}}%
+\index{operator"|=@\tcode{operator"|=}!\tcode{slice_array}}%
+\index{operator<<=@\tcode{operator\shl=}!\tcode{slice_array}}%
+\index{operator>>=@\tcode{operator\shr=}!\tcode{slice_array}}%
 \begin{itemdecl}
-template<class T> valarray<T> abs (const valarray<T>&);
-template<class T> valarray<T> acos (const valarray<T>&);
-template<class T> valarray<T> asin (const valarray<T>&);
-template<class T> valarray<T> atan (const valarray<T>&);
-template<class T> valarray<T> atan2
- (const valarray<T>&, const valarray<T>&);
-template<class T> valarray<T> atan2(const valarray<T>&, const T&);
-template<class T> valarray<T> atan2(const T&, const valarray<T>&);
-template<class T> valarray<T> cos (const valarray<T>&);
-template<class T> valarray<T> cosh (const valarray<T>&);
-template<class T> valarray<T> exp (const valarray<T>&);
-template<class T> valarray<T> log (const valarray<T>&);
-template<class T> valarray<T> log10(const valarray<T>&);
-template<class T> valarray<T> pow
- (const valarray<T>&, const valarray<T>&);
-template<class T> valarray<T> pow (const valarray<T>&, const T&);
-template<class T> valarray<T> pow (const T&, const valarray<T>&);
-template<class T> valarray<T> sin (const valarray<T>&);
-template<class T> valarray<T> sinh (const valarray<T>&);
-template<class T> valarray<T> sqrt (const valarray<T>&);
-template<class T> valarray<T> tan (const valarray<T>&);
-template<class T> valarray<T> tanh (const valarray<T>&);
+void operator*= (const valarray<T>&) const;
+void operator/= (const valarray<T>&) const;
+void operator%= (const valarray<T>&) const;
+void operator+= (const valarray<T>&) const;
+void operator-= (const valarray<T>&) const;
+void operator^= (const valarray<T>&) const;
+void operator&= (const valarray<T>&) const;
+void operator|= (const valarray<T>&) const;
+void operator<<=(const valarray<T>&) const;
+void operator>>=(const valarray<T>&) const;
 \end{itemdecl}
 
 \begin{itemdescr}
 \pnum
-Each of these functions may only be instantiated for a type \farg{T}\
-to which a unique function with the indicated name can be applied (unqualified).
-This function shall return a value which is of type \farg{T}\
-or which can be unambiguously converted to type \farg{T}.
+These computed assignments have reference semantics, applying the
+indicated operation to the elements of the argument array
+and selected elements of the
+\tcode{valarray<T>}\
+object to which the
+\tcode{slice_array}\
+object refers.
 \end{itemdescr}
 
-\rSec3[valarray.special]{\tcode{valarray}\ specialized algorithms}
+\rSec3[slice.arr.fill]{\tcode{slice_array}\ fill function}
 
+\index{fill@\tcode{fill}!\tcode{slice_array}}%
 \begin{itemdecl}
-@\addedD{template <class T> void swap(valarray<T>\& x, valarray<T>\& y);}@
-@\addedD{template <class T> void swap(valarray<T>\&\& x, valarray<T>\& y);}@
-@\addedD{template <class T> void swap(valarray<T>\& x, valarray<T>\&\& y);}@
+void operator=(const T&) const;
 \end{itemdecl}
 
 \begin{itemdescr}
 \pnum
-\addedD{\mbox{\effects} \mbox{\tcode{x.swap(y)}}.}
+This function has reference semantics, assigning the value of its argument
+to the elements of the
+\tcode{valarray<T>}\
+object to which the
+\tcode{slice_array}\
+object refers.
 \end{itemdescr}
 
+\rSec2[class.gslice]{The \tcode{gslice}\ class}
 
-\rSec2[class.slice]{Class \tcode{slice}}
-
-\index{slice@\tcode{slice}}%
+\index{gslice@\tcode{gslice}!class}%
 \begin{codeblock}
 namespace std {
- class slice {
+ class gslice {
   public:
- slice();
- slice(size_t, size_t, size_t);
+ gslice();
+ gslice(size_t s, const valarray<size_t>& l, const valarray<size_t>& d);
 
- size_t start() const;
- size_t size() const;
- size_t stride() const;
+ size_t start() const;
+ valarray<size_t> size() const;
+ valarray<size_t> stride() const;
   };
 }
 \end{codeblock}
 
 \pnum
-The
-\tcode{slice}\
-class represents a BLAS-like slice from an array.
-Such a slice is specified by a starting index, a length, and a stride.%
-\footnote{
-BLAS stands for
-\textit{Basic Linear Algebra Subprograms.}\
-\Cpp\ programs may instantiate this class.
-See, for example,
-Dongarra, Du Croz, Duff, and Hammerling:
-\textit{A set of Level 3 Basic Linear Algebra Subprograms};
-Technical Report MCS-P1-0888,
-Argonne National Laboratory (USA),
-Mathematics and Computer Science Division,
-August, 1988.
-}
+This class represents a generalized slice out of an array.
+A
+\tcode{gslice}\
+is defined by a starting offset ($s$),
+a set of lengths ($l_j$),
+and a set of strides ($d_j$).
+The number of lengths shall equal the number of strides.
+
+\pnum
+A
+\tcode{gslice}\
+represents a mapping from a set of indices ($i_j$),
+equal in number to the number of strides, to a single index $k$.
+It is useful for building multidimensional array classes using
+the
+\tcode{valarray}\
+template, which is one-dimensional.
+The set of one-dimensional index values specified by a
+\tcode{gslice}\
+are $$k = s + \sum_ji_jd_j$$
+% \$k = s + sum from j \{ i sub j d sub j \}\$
+where the multidimensional indices $i_j$ range in value from
+0 to $l_{ij} - 1$.
+
+\pnum
+\enterexample\
+The
+\tcode{gslice}\
+specification
+\begin{codeblock}
+start = 3
+length = {2, 4, 3}
+stride = {19, 4, 1}
+
+\end{codeblock}
+yields the sequence of one-dimensional indices
+
+$$k = 3 + (0,1) \times 19 + (0,1,2,3) \times 4 + (0,1,2) \times 1$$
+
+which are ordered as shown in the following table:
+
+\begin{tabbing}
+\hspace{.5in}\=\hspace{.4in}\=\kill%
+\>$(i_0,\quad i_1,\quad i_2,\quad k)\quad =$\\
+\>\>$(0,\quad 0,\quad 0,\quad 3$), \\
+\>\>$(0,\quad 0,\quad 1,\quad 4$), \\
+\>\>$(0,\quad 0,\quad 2,\quad 5$), \\
+\>\>$(0,\quad 1,\quad 0,\quad 7$), \\
+\>\>$(0,\quad 1,\quad 1,\quad 8$), \\
+\>\>$(0,\quad 1,\quad 2,\quad 9$), \\
+\>\>$(0,\quad 2,\quad 0,\quad 11$), \\
+\>\>$(0,\quad 2,\quad 1,\quad 12$), \\
+\>\>$(0,\quad 2,\quad 2,\quad 13$), \\
+\>\>$(0,\quad 3,\quad 0,\quad 15$), \\
+\>\>$(0,\quad 3,\quad 1,\quad 16$), \\
+\>\>$(0,\quad 3,\quad 2,\quad 17$), \\
+\>\>$(1,\quad 0,\quad 0,\quad 22$), \\
+\>\>$(1,\quad 0,\quad 1,\quad 23$), \\
+\>\>$\ldots$ \\
+\>\>$(1,\quad 3,\quad 2,\quad 36$)
+\end{tabbing}
+
+That is, the highest-ordered index turns fastest.
+\exitexample\
+
+\pnum
+It is possible to have degenerate generalized slices in which an address
+is repeated.
+
+\pnum
+\enterexample\
+If the stride parameters in the previous
+example are changed to \{1, 1, 1\}, the first few elements of the
+resulting sequence of indices will be
+
+\begin{tabbing}
+\hspace{.9in}\=\kill%
+\>$(0,\quad 0,\quad 0,\quad 3$), \\
+\>$(0,\quad 0,\quad 1,\quad 4$), \\
+\>$(0,\quad 0,\quad 2,\quad 5$), \\
+\>$(0,\quad 1,\quad 0,\quad 4$), \\
+\>$(0,\quad 1,\quad 1,\quad 5$), \\
+\>$(0,\quad 1,\quad 2,\quad 6$), \\
+\>$\ldots$
+\end{tabbing}
+\exitexample\
+
+\pnum
+If a degenerate slice is used as the argument to the
+non-\tcode{const}
+version of
+\tcode{operator[](const gslice\&)},
+the resulting behavior is undefined.
+\index{undefined}%
 
-\rSec3[cons.slice]{\tcode{slice}\ constructors}
+\rSec3[gslice.cons]{\tcode{gslice}\ constructors}
 
-\index{slice@\tcode{slice}!\tcode{slice}}%
+\index{gslice@\tcode{gslice}!\tcode{gslice}}%
 \begin{itemdecl}
-slice();
-slice(size_t @\farg{start}@, size_t @\farg{length}@, size_t @\farg{stride}@);
-slice(const slice&);
+gslice();
+gslice(size_t @\farg{start}@, const valarray<size_t>& @\farg{lengths}@,
+ const valarray<size_t>& @\farg{strides}@);
+gslice(const gslice&);
 \end{itemdecl}
 
 \begin{itemdescr}
 \pnum
-\changedD{The default constructor for
-\mbox{\tcode{slice}}
-creates a
-\mbox{\tcode{slice}}
+\changedD{The default constructor creates a
+\mbox{\tcode{gslice}}
 which specifies no elements.}
-{The default constructor is equivalent to \mbox{\tcode{slice(0, 0, 0)}}.}
-A default constructor is provided only to permit the declaration of arrays of slices.
-The constructor with arguments for a slice takes a start, length, and stride
-parameter.
-
-\pnum
-\enterexample\
-\tcode{slice(3, 8, 2)}\
-constructs a slice which selects elements 3, 5, 7, ... 17 from an array.
-\exitexample\
+{The default constructor is equivalent to
+\mbox{\tcode{gslice(0, valarray<size_t>(), valarray<size_t>())}}.}
+The constructor with arguments builds a
+\tcode{gslice}\
+based on a specification of start, lengths, and strides, as explained
+in the previous section.
 \end{itemdescr}
 
-\rSec3[slice.access]{\tcode{slice}\ access functions}
-\index{start@\tcode{start}!\tcode{slice}}%
-\index{size@\tcode{size}!\tcode{slice}}%
-\index{stride@\tcode{stride}!\tcode{slice}}%
+\rSec3[gslice.access]{\tcode{gslice}\ access functions}
+
+\index{start@\tcode{start}!\tcode{gslice}}%
+\index{size@\tcode{size}!\tcode{gslice}}%
+\index{stride@\tcode{stride}!\tcode{gslice}}%
 \begin{itemdecl}
-size_t start() const;
-size_t size() const;
-size_t stride() const;
+size_t start() const;
+valarray<size_t> size() const;
+valarray<size_t> stride() const;
 \end{itemdecl}
 
 \begin{itemdescr}
 \pnum
-These functions return the start, length, or stride specified by a
-\tcode{slice}\ object.
+These access functions return the representation of the start, lengths, or
+strides specified for the
+\tcode{gslice}.
 \end{itemdescr}
 
-\rSec2[template.slice.array]{Class template \tcode{slice_array}}
+\rSec2[template.gslice.array]{Class template \tcode{gslice_array}}
 
-\index{slice_array@\tcode{slice_array}}%
+\index{gslice_array@\tcode{gslice_array}}%
 \begin{codeblock}
 namespace std {
- template <class T> class slice_array {
+ template <class T> class gslice_array {
   public:
     typedef T value_type;
 
@@ -1745,50 +1866,48 @@
     void operator<<=(const valarray<T>&) const;
     void operator>>=(const valarray<T>&) const;
 
- slice_array(const slice_array&);
- ~slice_array();
- slice_array& operator=(const slice_array&);
- void operator=(const T&) const;
+ gslice_array(const gslice_array&);
+ ~gslice_array();
+ gslice_array& operator=(const gslice_array&);
+ void operator=(const T&) const;
   private:
- slice_array();
+ gslice_array();
   };
 }
 \end{codeblock}
 
 \pnum
-The
-\tcode{slice_array}\
-template is a helper template used by the
+This template is a helper template used by the
 \tcode{slice}\
 subscript operator
 
-\begin{codeblock}
-slice_array<T> valarray<T>::operator[](slice);
-\end{codeblock}
+\index{gslice_array@\tcode{gslice_array}}%
+\index{valarray@\tcode{valarray}}%
+\begin{itemdecl}
+gslice_array<T> valarray<T>::operator[](const gslice&);
+\end{itemdecl}
 
+\begin{itemdescr}
+\pnum
 It has reference semantics to a subset of an array specified by a
-\tcode{slice}
+\tcode{gslice}\
 object.
 
 \pnum
-\enterexample\
-The expression
-\tcode{a[slice(1, 5, 3)] = b;}\
+Thus, the expression
+\tcode{a[gslice(1, length, stride)] = b}\
 has the effect of assigning the elements of
 \tcode{b}\
-to a slice of the elements in
+to a
+generalized slice of the elements in
 \tcode{a}.
-For the slice shown, the elements
-selected from
-\tcode{a}\
-are 1, 4, ..., 13.
-\exitexample\
+\end{itemdescr}
 
-\rSec3[cons.slice.arr]{\tcode{slice_array}\ constructors}
+\rSec3[gslice.array.cons]{\tcode{gslice_array}\ constructors}
 
-\index{slice_array@\tcode{slice_array}!\tcode{slice_array}}%
+\index{gslice_array@\tcode{gslice_array}!\tcode{gslice_array}}%
 \begin{itemdecl}
-slice_array();
+gslice_array();
 \end{itemdecl}
 
 \begin{itemdescr}
@@ -1797,37 +1916,36 @@
 This constructor need not be defined.
 \end{itemdescr}
 
-\rSec3[slice.arr.assign]{\tcode{slice_array}\ assignment}
+\rSec3[gslice.array.assign]{\tcode{gslice_array}\ assignment}
 
-\index{operator=@\tcode{operator=}!\tcode{slice_array}}%
+\index{operator=@\tcode{operator=}!\tcode{gslice_array}}%
 \begin{itemdecl}
-void operator=(const valarray<T>&) const;
-slice_array& operator=(const slice_array&);
+void operator=(const valarray<T>&) const;
+gslice_array& operator=(const gslice_array&);
 \end{itemdecl}
 
 \begin{itemdescr}
 \pnum
-These assignment operators have reference semantics,
-assigning the values of the argument array elements to selected
-elements of the
+These assignment operators have reference semantics, assigning the values
+of the argument array elements to selected elements of the
 \tcode{valarray<T>}\
 object to which the
-\tcode{slice_array}\
-object refers.
+\tcode{gslice_array}\
+refers.
 \end{itemdescr}
 
-\rSec3[slice.arr.comp.assign]{\tcode{slice_array}\ computed assignment}
+\rSec3[gslice.array.comp.assign]{\tcode{gslice_array}}
 
-\index{operator*=@\tcode{operator*=}!\tcode{slice_array}}%
-\index{operator/=@\tcode{operator/=}!\tcode{slice_array}}%
-\index{operator\%=@\tcode{operator\%=}!\tcode{slice_array}}%
-\index{operator+=@\tcode{operator+=}!\tcode{slice_array}}%
-\index{operator-=@\tcode{operator-=}!\tcode{slice_array}}%
-\index{operator\^{}=@\tcode{operator\^{}=}!\tcode{slice_array}}%
-\index{operator\&=@\tcode{operator\&=}!\tcode{slice_array}}%
-\index{operator"|=@\tcode{operator"|=}!\tcode{slice_array}}%
-\index{operator<<=@\tcode{operator\shl=}!\tcode{slice_array}}%
-\index{operator>>=@\tcode{operator\shr=}!\tcode{slice_array}}%
+\index{operator*=@\tcode{operator*=}!\tcode{gslice_array}}%
+\index{operator/=@\tcode{operator/=}!\tcode{gslice_array}}%
+\index{operator\%=@\tcode{operator\%=}!\tcode{gslice_array}}%
+\index{operator+=@\tcode{operator+=}!\tcode{gslice_array}}%
+\index{operator-=@\tcode{operator-=}!\tcode{gslice_array}}%
+\index{operator\^{}=@\tcode{operator\^{}=}!\tcode{gslice_array}}%
+\index{operator\&=@\tcode{operator\&=}!\tcode{gslice_array}}%
+\index{operator"|=@\tcode{operator"|=}!\tcode{gslice_array}}%
+\index{operator<<=@\tcode{operator\shl=}!\tcode{gslice_array}}%
+\index{operator>>=@\tcode{operator\shr=}!\tcode{gslice_array}}%
 \begin{itemdecl}
 void operator*= (const valarray<T>&) const;
 void operator/= (const valarray<T>&) const;
@@ -1844,17 +1962,17 @@
 \begin{itemdescr}
 \pnum
 These computed assignments have reference semantics, applying the
-indicated operation to the elements of the argument array
-and selected elements of the
+indicated operation to the elements of the argument array and selected
+elements of the
 \tcode{valarray<T>}\
 object to which the
-\tcode{slice_array}\
+\tcode{gslice_array}\
 object refers.
 \end{itemdescr}
 
-\rSec3[slice.arr.fill]{\tcode{slice_array}\ fill function}
+\rSec3[gslice.array.fill]{\tcode{gslice_array}\ fill function}
 
-\index{fill@\tcode{fill}!\tcode{slice_array}}%
+\index{fill@\tcode{fill}!\tcode{gslice_array}}%
 \begin{itemdecl}
 void operator=(const T&) const;
 \end{itemdecl}
@@ -1865,170 +1983,151 @@
 to the elements of the
 \tcode{valarray<T>}\
 object to which the
-\tcode{slice_array}\
+\tcode{gslice_array}\
 object refers.
 \end{itemdescr}
 
-\rSec2[class.gslice]{The \tcode{gslice}\ class}
+\rSec2[template.mask.array]{Class template \tcode{mask_array}}
 
-\index{gslice@\tcode{gslice}!class}%
+\index{mask_array@\tcode{mask_array}}%
 \begin{codeblock}
 namespace std {
- class gslice {
+ template <class T> class mask_array {
   public:
- gslice();
- gslice(size_t s, const valarray<size_t>& l, const valarray<size_t>& d);
-
- size_t start() const;
- valarray<size_t> size() const;
- valarray<size_t> stride() const;
- };
-}
-\end{codeblock}
-
-\pnum
-This class represents a generalized slice out of an array.
-A
-\tcode{gslice}\
-is defined by a starting offset ($s$),
-a set of lengths ($l_j$),
-and a set of strides ($d_j$).
-The number of lengths shall equal the number of strides.
-
-\pnum
-A
-\tcode{gslice}\
-represents a mapping from a set of indices ($i_j$),
-equal in number to the number of strides, to a single index $k$.
-It is useful for building multidimensional array classes using
-the
-\tcode{valarray}\
-template, which is one-dimensional.
-The set of one-dimensional index values specified by a
-\tcode{gslice}\
-are $$k = s + \sum_ji_jd_j$$
-% \$k = s + sum from j \{ i sub j d sub j \}\$
-where the multidimensional indices $i_j$ range in value from
-0 to $l_{ij} - 1$.
+ typedef T value_type;
 
-\pnum
-\enterexample\
-The
-\tcode{gslice}\
-specification
-\begin{codeblock}
-start = 3
-length = {2, 4, 3}
-stride = {19, 4, 1}
+ void operator= (const valarray<T>&) const;
+ void operator*= (const valarray<T>&) const;
+ void operator/= (const valarray<T>&) const;
+ void operator%= (const valarray<T>&) const;
+ void operator+= (const valarray<T>&) const;
+ void operator-= (const valarray<T>&) const;
+ void operator^= (const valarray<T>&) const;
+ void operator&= (const valarray<T>&) const;
+ void operator|= (const valarray<T>&) const;
+ void operator<<=(const valarray<T>&) const;
+ void operator>>=(const valarray<T>&) const;
 
+ mask_array(const mask_array&);
+ ~mask_array();
+ mask_array& operator=(const mask_array&);
+ void operator=(const T&) const;
+ private:
+ mask_array();
+ };
+}
 \end{codeblock}
-yields the sequence of one-dimensional indices
 
-$$k = 3 + (0,1) \times 19 + (0,1,2,3) \times 4 + (0,1,2) \times 1$$
+\pnum
+This template is a helper template used by the mask subscript operator:
 
-which are ordered as shown in the following table:
+\begin{itemdecl}
+mask_array<T> valarray<T>::operator[](const valarray<bool>&).
+\end{itemdecl}
 
-\begin{tabbing}
-\hspace{.5in}\=\hspace{.4in}\=\kill%
-\>$(i_0,\quad i_1,\quad i_2,\quad k)\quad =$\\
-\>\>$(0,\quad 0,\quad 0,\quad 3$), \\
-\>\>$(0,\quad 0,\quad 1,\quad 4$), \\
-\>\>$(0,\quad 0,\quad 2,\quad 5$), \\
-\>\>$(0,\quad 1,\quad 0,\quad 7$), \\
-\>\>$(0,\quad 1,\quad 1,\quad 8$), \\
-\>\>$(0,\quad 1,\quad 2,\quad 9$), \\
-\>\>$(0,\quad 2,\quad 0,\quad 11$), \\
-\>\>$(0,\quad 2,\quad 1,\quad 12$), \\
-\>\>$(0,\quad 2,\quad 2,\quad 13$), \\
-\>\>$(0,\quad 3,\quad 0,\quad 15$), \\
-\>\>$(0,\quad 3,\quad 1,\quad 16$), \\
-\>\>$(0,\quad 3,\quad 2,\quad 17$), \\
-\>\>$(1,\quad 0,\quad 0,\quad 22$), \\
-\>\>$(1,\quad 0,\quad 1,\quad 23$), \\
-\>\>$\ldots$ \\
-\>\>$(1,\quad 3,\quad 2,\quad 36$)
-\end{tabbing}
+\begin{itemdescr}
+\pnum
+It has reference semantics to a subset of an array specified by a boolean mask.
+Thus, the expression
+\tcode{a[mask] = b;}\
+has the effect of assigning the elements of
+\tcode{b}\
+to the masked
+elements in
+\tcode{a}\
+(those for which the corresponding element
+in
+\tcode{mask}\
+is
+\tcode{true}.)
+\end{itemdescr}
 
-That is, the highest-ordered index turns fastest.
-\exitexample\
+\rSec3[mask.array.cons]{\tcode{mask_array}\ constructors}
 
-\pnum
-It is possible to have degenerate generalized slices in which an address
-is repeated.
+\index{mask_array@\tcode{mask_array}!\tcode{mask_array}}%
+\begin{itemdecl}
+mask_array();
+\end{itemdecl}
 
+\begin{itemdescr}
 \pnum
-\enterexample\
-If the stride parameters in the previous
-example are changed to \{1, 1, 1\}, the first few elements of the
-resulting sequence of indices will be
+This constructor is declared to be private.
+This constructor need not be defined.
+\end{itemdescr}
 
-\begin{tabbing}
-\hspace{.9in}\=\kill%
-\>$(0,\quad 0,\quad 0,\quad 3$), \\
-\>$(0,\quad 0,\quad 1,\quad 4$), \\
-\>$(0,\quad 0,\quad 2,\quad 5$), \\
-\>$(0,\quad 1,\quad 0,\quad 4$), \\
-\>$(0,\quad 1,\quad 1,\quad 5$), \\
-\>$(0,\quad 1,\quad 2,\quad 6$), \\
-\>$\ldots$
-\end{tabbing}
-\exitexample\
+\rSec3[mask.array.assign]{\tcode{mask_array}\ assignment}
+
+\index{operator=@\tcode{operator=}!\tcode{mask_array}}%
+\begin{itemdecl}
+void operator=(const valarray<T>&) const;
+mask_array& operator=(const mask_array&);
+\end{itemdecl}
 
+\begin{itemdescr}
 \pnum
-If a degenerate slice is used as the argument to the
-non-\tcode{const}
-version of
-\tcode{operator[](const gslice\&)},
-the resulting behavior is undefined.
-\index{undefined}%
+These assignment operators have reference semantics, assigning the values
+of the argument array elements to selected elements of the
+\tcode{valarray<T>}\
+object to which it refers.
+\end{itemdescr}
 
-\rSec3[gslice.cons]{\tcode{gslice}\ constructors}
+\rSec3[mask.array.comp.assign]{\tcode{mask_array}\ computed assignment}
 
-\index{gslice@\tcode{gslice}!\tcode{gslice}}%
+\index{operator*=@\tcode{operator*=}!\tcode{mask_array}}%
+\index{operator/=@\tcode{operator/=}!\tcode{mask_array}}%
+\index{operator\%=@\tcode{operator\%=}!\tcode{mask_array}}%
+\index{operator+=@\tcode{operator+=}!\tcode{mask_array}}%
+\index{operator-=@\tcode{operator-=}!\tcode{mask_array}}%
+\index{operator\^{}=@\tcode{operator\^{}=}!\tcode{mask_array}}%
+\index{operator\&=@\tcode{operator\&=}!\tcode{mask_array}}%
+\index{operator"|=@\tcode{operator"|=}!\tcode{mask_array}}%
+\index{operator<<=@\tcode{operator\shl=}!\tcode{mask_array}}%
+\index{operator>>=@\tcode{operator\shr=}!\tcode{mask_array}}%
 \begin{itemdecl}
-gslice();
-gslice(size_t @\farg{start}@, const valarray<size_t>& @\farg{lengths}@,
- const valarray<size_t>& @\farg{strides}@);
-gslice(const gslice&);
+void operator*= (const valarray<T>&) const;
+void operator/= (const valarray<T>&) const;
+void operator%= (const valarray<T>&) const;
+void operator+= (const valarray<T>&) const;
+void operator-= (const valarray<T>&) const;
+void operator^= (const valarray<T>&) const;
+void operator&= (const valarray<T>&) const;
+void operator|= (const valarray<T>&) const;
+void operator<<=(const valarray<T>&) const;
+void operator>>=(const valarray<T>&) const;
 \end{itemdecl}
 
 \begin{itemdescr}
 \pnum
-\changedD{The default constructor creates a
-\mbox{\tcode{gslice}}
-which specifies no elements.}
-{The default constructor is equivalent to
-\mbox{\tcode{gslice(0, valarray<size_t>(), valarray<size_t>())}}.}
-The constructor with arguments builds a
-\tcode{gslice}\
-based on a specification of start, lengths, and strides, as explained
-in the previous section.
+These computed assignments have reference semantics, applying the
+indicated operation to the elements of the argument array and selected elements
+of the
+\tcode{valarray<T>}\
+object to which the mask object refers.
 \end{itemdescr}
 
-\rSec3[gslice.access]{\tcode{gslice}\ access functions}
+\rSec3[mask.array.fill]{\tcode{mask_array}\ fill function}
 
-\index{start@\tcode{start}!\tcode{gslice}}%
-\index{size@\tcode{size}!\tcode{gslice}}%
-\index{stride@\tcode{stride}!\tcode{gslice}}%
+\index{fill@\tcode{fill}!\tcode{mask_array}}%
 \begin{itemdecl}
-size_t start() const;
-valarray<size_t> size() const;
-valarray<size_t> stride() const;
+void operator=(const T&) const;
 \end{itemdecl}
 
 \begin{itemdescr}
 \pnum
-These access functions return the representation of the start, lengths, or
-strides specified for the
-\tcode{gslice}.
+This function has reference semantics, assigning the value of its
+argument to the elements of the
+\tcode{valarray<T>}\
+object to which the
+\tcode{mask_array}\
+object refers.
 \end{itemdescr}
 
-\rSec2[template.gslice.array]{Class template \tcode{gslice_array}}
+\rSec2[template.indirect.array]{Class template \tcode{indirect_array}}
 
-\index{gslice_array@\tcode{gslice_array}}%
+\index{indirect_array@\tcode{indirect_array}}%
 \begin{codeblock}
 namespace std {
- template <class T> class gslice_array {
+ template <class T> class indirect_array {
   public:
     typedef T value_type;
 
@@ -2044,48 +2143,42 @@
     void operator<<=(const valarray<T>&) const;
     void operator>>=(const valarray<T>&) const;
 
- gslice_array(const gslice_array&);
- ~gslice_array();
- gslice_array& operator=(const gslice_array&);
+ indirect_array(const indirect_array&);
+ ~indirect_array();
+ indirect_array& operator=(const indirect_array&);
     void operator=(const T&) const;
   private:
- gslice_array();
+ indirect_array();
   };
 }
 \end{codeblock}
 
 \pnum
-This template is a helper template used by the
-\tcode{slice}\
-subscript operator
+This template is a helper template used by the indirect subscript operator
 
-\index{gslice_array@\tcode{gslice_array}}%
-\index{valarray@\tcode{valarray}}%
 \begin{itemdecl}
-gslice_array<T> valarray<T>::operator[](const gslice&);
+indirect_array<T> valarray<T>::operator[](const valarray<size_t>&).
 \end{itemdecl}
 
 \begin{itemdescr}
 \pnum
-It has reference semantics to a subset of an array specified by a
-\tcode{gslice}\
-object.
-
-\pnum
-Thus, the expression
-\tcode{a[gslice(1, length, stride)] = b}\
+It has reference semantics to a subset of an array specified by an
+\tcode{indirect_array}.
+Thus the expression
+\tcode{a[\brk{}indirect] = b;}\
 has the effect of assigning the elements of
 \tcode{b}\
-to a
-generalized slice of the elements in
-\tcode{a}.
+to the elements in
+\tcode{a}\
+whose indices appear in
+\tcode{indirect}.
 \end{itemdescr}
 
-\rSec3[gslice.array.cons]{\tcode{gslice_array}\ constructors}
+\rSec3[indirect.array.cons]{\tcode{indirect_array}\ constructors}
 
-\index{gslice_array@\tcode{gslice_array}!\tcode{gslice_array}}%
+\index{indirect_array@\tcode{indirect_array}!\tcode{indirect_array}}%
 \begin{itemdecl}
-gslice_array();
+indirect_array();
 \end{itemdecl}
 
 \begin{itemdescr}
@@ -2094,12 +2187,12 @@
 This constructor need not be defined.
 \end{itemdescr}
 
-\rSec3[gslice.array.assign]{\tcode{gslice_array}\ assignment}
+\rSec3[indirect.array.assign]{\tcode{indirect_array}\ assignment}
 
-\index{operator=@\tcode{operator=}!\tcode{gslice_array}}%
+\index{operator=@\tcode{operator=}!\tcode{indirect_array}}%
 \begin{itemdecl}
 void operator=(const valarray<T>&) const;
-gslice_array& operator=(const gslice_array&);
+indirect_array& operator=(const indirect_array&);
 \end{itemdecl}
 
 \begin{itemdescr}
@@ -2107,23 +2200,43 @@
 These assignment operators have reference semantics, assigning the values
 of the argument array elements to selected elements of the
 \tcode{valarray<T>}\
-object to which the
-\tcode{gslice_array}\
-refers.
+object to which it refers.
+
+\pnum
+If the
+\tcode{indirect_array}
+specifies an element in the
+\tcode{valarray<T>}\
+object to which it refers more than once, the behavior is undefined.
+\index{undefined}%
+
+\pnum
+\enterexample\
+\begin{codeblock}
+int addr[] = {2, 3, 1, 4, 4};
+valarray<size_t> indirect(addr, 5);
+valarray<double> a(0., 10), b(1., 5);
+a[indirect] = b;
+\end{codeblock}
+results in undefined behavior since element 4 is specified twice in the
+indirection.
+\exitexample\
 \end{itemdescr}
 
-\rSec3[gslice.array.comp.assign]{\tcode{gslice_array}}
+\rSec3[indirect.array.comp.assign]{\tcode{indirect_array}\ computed assignment}
 
-\index{operator*=@\tcode{operator*=}!\tcode{gslice_array}}%
-\index{operator/=@\tcode{operator/=}!\tcode{gslice_array}}%
-\index{operator\%=@\tcode{operator\%=}!\tcode{gslice_array}}%
-\index{operator+=@\tcode{operator+=}!\tcode{gslice_array}}%
-\index{operator-=@\tcode{operator-=}!\tcode{gslice_array}}%
-\index{operator\^{}=@\tcode{operator\^{}=}!\tcode{gslice_array}}%
-\index{operator\&=@\tcode{operator\&=}!\tcode{gslice_array}}%
-\index{operator"|=@\tcode{operator"|=}!\tcode{gslice_array}}%
-\index{operator<<=@\tcode{operator\shl=}!\tcode{gslice_array}}%
-\index{operator>>=@\tcode{operator\shr=}!\tcode{gslice_array}}%
+\index{operator*=@\tcode{operator*=}!\tcode{indirect_array}}%
+\index{operator*=@\tcode{operator*=}!\tcode{indirect_array}}%
+\index{operator*=@\tcode{operator*=}!\tcode{indirect_array}}%
+\index{operator/=@\tcode{operator/=}!\tcode{indirect_array}}%
+\index{operator\%=@\tcode{operator\%=}!\tcode{indirect_array}}%
+\index{operator+=@\tcode{operator+=}!\tcode{indirect_array}}%
+\index{operator-=@\tcode{operator-=}!\tcode{indirect_array}}%
+\index{operator\^{}=@\tcode{operator\^{}=}!\tcode{indirect_array}}%
+\index{operator\&=@\tcode{operator\&=}!\tcode{indirect_array}}%
+\index{operator"|=@\tcode{operator"|=}!\tcode{indirect_array}}%
+\index{operator<<=@\tcode{operator\shl=}!\tcode{indirect_array}}%
+\index{operator>>=@\tcode{operator\shr=}!\tcode{indirect_array}}%
 \begin{itemdecl}
 void operator*= (const valarray<T>&) const;
 void operator/= (const valarray<T>&) const;
@@ -2139,18 +2252,26 @@
 
 \begin{itemdescr}
 \pnum
-These computed assignments have reference semantics, applying the
-indicated operation to the elements of the argument array and selected
-elements of the
+These computed assignments have reference semantics, applying the indicated
+operation to the elements of the argument array and selected elements of the
 \tcode{valarray<T>}\
 object to which the
-\tcode{gslice_array}\
+\tcode{indirect_array}\
 object refers.
+
+\pnum
+If the
+\tcode{indirect_array}\
+specifies an element in the
+\tcode{valarray<T>}\
+object to which it refers more than once,
+the behavior is undefined.
+\index{undefined}
 \end{itemdescr}
 
-\rSec3[gslice.array.fill]{\tcode{gslice_array}\ fill function}
+\rSec3[indirect.array.fill]{\tcode{indirect_array}\ fill function}
 
-\index{fill@\tcode{fill}!\tcode{gslice_array}}%
+\index{fill@\tcode{fill}!\tcode{indirect_array}}%
 \begin{itemdecl}
 void operator=(const T&) const;
 \end{itemdecl}
@@ -2161,305 +2282,332 @@
 to the elements of the
 \tcode{valarray<T>}\
 object to which the
-\tcode{gslice_array}\
+\tcode{indirect_array}\
 object refers.
 \end{itemdescr}
 
-\rSec2[template.mask.array]{Class template \tcode{mask_array}}
+\setcounter{section}{5}
 
-\index{mask_array@\tcode{mask_array}}%
-\begin{codeblock}
-namespace std {
- template <class T> class mask_array {
- public:
- typedef T value_type;
+\rSec1[lib.numeric.ops]{Generalized numeric operations}
 
- void operator= (const valarray<T>&) const;
- void operator*= (const valarray<T>&) const;
- void operator/= (const valarray<T>&) const;
- void operator%= (const valarray<T>&) const;
- void operator+= (const valarray<T>&) const;
- void operator-= (const valarray<T>&) const;
- void operator^= (const valarray<T>&) const;
- void operator&= (const valarray<T>&) const;
- void operator|= (const valarray<T>&) const;
- void operator<<=(const valarray<T>&) const;
- void operator>>=(const valarray<T>&) const;
+\synopsis{Header \tcode{<numeric>}\ synopsis}
+\index{numeric@\tcode{<numeric>}}%
 
- mask_array(const mask_array&);
- ~mask_array();
- mask_array& operator=(const mask_array&);
- void operator=(const T&) const;
- private:
- mask_array();
- };
+\color{addclr}
+\begin{codeblock}
+namespace std {
+ template <InputIterator Iter, HasPlus<auto, Iter::reference> T>
+ requires CopyAssignable<T, T::result_type>
+ T accumulate(Iter @\farg{first}@, Iter @\farg{last}@, T @\farg{init}@);
+ template <InputIterator Iter, class T, Callable<auto, T, Iter::reference> BinaryOperation>
+ requires CopyAssignable<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>
+ requires HasMultiply<Iter1::reference, Iter2::reference> &&
+ HasPlus<T, HasMultiply<Iter1::reference, Iter2::reference>::result_type> &&
+ CopyAssignable<
+ T,
+ HasPlus<T,
+ HasMultiply<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, Callable<auto, Iter1::reference, Iter2::reference> BinaryOperation2>
+ requires Callable<BinaryOperation1, T, BinaryOperation2::result_type> &&
+ CopyAssignable<T, BinaryOperation1::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<auto, InIter::value_type> OutIter>
+ requires HasPlus<InIter::value_type> &&
+ CopyAssignable<InIter::value_type, HasPlus<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<auto, InIter::value_type> OutIter,
+ Callable<auto, InIter::value_type, InIter::value_type> BinaryOperation>
+ requires CopyAssignable<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<auto, InIter::value_type> OutIter>
+ requires HasMinus<InIter::value_type, InIter::value_type> &&
+ CopyAssignable<OutIter, HasMinus<InIter::value_type, InIter::value_type>::result_type> &&
+ CopyConstructible<InIter::value_type> && CopyAssignable<InIter::value_type>
+ OutIter adjacent_difference(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@);
+ template <InputIterator InIter, OutputIterator<auto, InIter::value_type> OutIter,
+ Callable<auto, InIter::value_type, InIter::value_type> BinaryOperation>
+ requires CopyAssignable<OutIter::reference, BinaryOperation::result_type> &&
+ CopyConstructible<InIter::value_type> && CopyAssignable<InIter::value_type>
+ OutIter adjacent_difference(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@,
+ BinaryOperation @\farg{binary_op}@);
 }
 \end{codeblock}
+\color{black}
 
 \pnum
-This template is a helper template used by the mask subscript operator:
+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}
-mask_array<T> valarray<T>::operator[](const valarray<bool>&).
+template <InputIterator Iter, HasPlus<auto, Iter::reference> T>
+ requires CopyAssignable<T, T::result_type>
+ T accumulate(Iter @\farg{first}@, Iter @\farg{last}@, T @\farg{init}@);
+template <InputIterator Iter, class T, Callable<auto, T, Iter::reference> BinaryOperation>
+ requires CopyAssignable<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
-It has reference semantics to a subset of an array specified by a boolean mask.
-Thus, the expression
-\tcode{a[mask] = b;}\
-has the effect of assigning the elements of
-\tcode{b}\
-to the masked
-elements in
-\tcode{a}\
-(those for which the corresponding element
-in
-\tcode{mask}\
-is
-\tcode{true}.)
-\end{itemdescr}
-
-\rSec3[mask.array.cons]{\tcode{mask_array}\ constructors}
-
-\index{mask_array@\tcode{mask_array}!\tcode{mask_array}}%
-\begin{itemdecl}
-mask_array();
-\end{itemdecl}
+\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.
+}
 
-\begin{itemdescr}
 \pnum
-This constructor is declared to be private.
-This constructor need not be defined.
+\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}
 
-\rSec3[mask.array.assign]{\tcode{mask_array}\ assignment}
+\rSec2[lib.inner.product]{Inner product}
+\index{inner_product@\tcode{inner_product}}%
 
-\index{operator=@\tcode{operator=}!\tcode{mask_array}}%
+\color{addclr}
 \begin{itemdecl}
-void operator=(const valarray<T>&) const;
-mask_array& operator=(const mask_array&);
+template <InputIterator Iter1, InputIterator Iter2, class T>
+ requires HasMultiply<Iter1::reference, Iter2::reference> &&
+ HasPlus<T, HasMultiply<Iter1::reference, Iter2::reference>::result_type> &&
+ CopyAssignable<
+ T,
+ HasPlus<T,
+ HasMultiply<Iter1::reference, Iter2::reference>::result_type>::result_type>
+ @\textcolor{addclr}{}@T inner_product(Iter1 @\farg{first1}@, Iter1 @\farg{last1}@,
+ Iter2 @\farg{first2}@, T @\farg{init}@);
+template <InputIterator Iter1, InputIterator Iter2, class T,
+ class BinaryOperation1, Callable<auto, Iter1::reference, Iter2::reference> BinaryOperation2>
+ requires Callable<BinaryOperation1, T, BinaryOperation2::result_type> &&
+ CopyAssignable<T, BinaryOperation1::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
-These assignment operators have reference semantics, assigning the values
-of the argument array elements to selected elements of the
-\tcode{valarray<T>}\
-object to which it refers.
-\end{itemdescr}
-
-\rSec3[mask.array.comp.assign]{\tcode{mask_array}\ computed assignment}
-
-\index{operator*=@\tcode{operator*=}!\tcode{mask_array}}%
-\index{operator/=@\tcode{operator/=}!\tcode{mask_array}}%
-\index{operator\%=@\tcode{operator\%=}!\tcode{mask_array}}%
-\index{operator+=@\tcode{operator+=}!\tcode{mask_array}}%
-\index{operator-=@\tcode{operator-=}!\tcode{mask_array}}%
-\index{operator\^{}=@\tcode{operator\^{}=}!\tcode{mask_array}}%
-\index{operator\&=@\tcode{operator\&=}!\tcode{mask_array}}%
-\index{operator"|=@\tcode{operator"|=}!\tcode{mask_array}}%
-\index{operator<<=@\tcode{operator\shl=}!\tcode{mask_array}}%
-\index{operator>>=@\tcode{operator\shr=}!\tcode{mask_array}}%
-\begin{itemdecl}
-void operator*= (const valarray<T>&) const;
-void operator/= (const valarray<T>&) const;
-void operator%= (const valarray<T>&) const;
-void operator+= (const valarray<T>&) const;
-void operator-= (const valarray<T>&) const;
-void operator^= (const valarray<T>&) const;
-void operator&= (const valarray<T>&) const;
-void operator|= (const valarray<T>&) const;
-void operator<<=(const valarray<T>&) const;
-void operator>>=(const valarray<T>&) const;
-\end{itemdecl}
+\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.
 
-\begin{itemdescr}
 \pnum
-These computed assignments have reference semantics, applying the
-indicated operation to the elements of the argument array and selected elements
-of the
-\tcode{valarray<T>}\
-object to which the mask object refers.
+\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}
 
-\rSec3[mask.array.fill]{\tcode{mask_array}\ fill function}
-
-\index{fill@\tcode{fill}!\tcode{mask_array}}%
+\rSec2[lib.partial.sum]{Partial sum}
+\index{partial_sum@\tcode{partial_sum}}%
+\color{addclr}
 \begin{itemdecl}
-void operator=(const T&) const;
+template <InputIterator InIter, OutputIterator<auto, InIter::value_type> OutIter>
+ requires HasPlus<InIter::value_type> &&
+ CopyAssignable<InIter::value_type, HasPlus<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<auto, InIter::value_type> OutIter,
+ Callable<auto, InIter::value_type, InIter::value_type> BinaryOperation>
+ requires CopyAssignable<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
-This function has reference semantics, assigning the value of its
-argument to the elements of the
-\tcode{valarray<T>}\
-object to which the
-\tcode{mask_array}\
-object refers.
-\end{itemdescr}
-
-\rSec2[template.indirect.array]{Class template \tcode{indirect_array}}
+\effects\
+Assigns to every element referred to by iterator
+\tcode{i}\
+in the range
+\range{result}{result + (last - first)}
+a value
+correspondingly equal to
 
-\index{indirect_array@\tcode{indirect_array}}%
 \begin{codeblock}
-namespace std {
- template <class T> class indirect_array {
- public:
- typedef T value_type;
+((...(*first + *(first + 1)) + ...) + *(first + (i - result)))
+\end{codeblock}
 
- void operator= (const valarray<T>&) const;
- void operator*= (const valarray<T>&) const;
- void operator/= (const valarray<T>&) const;
- void operator%= (const valarray<T>&) const;
- void operator+= (const valarray<T>&) const;
- void operator-= (const valarray<T>&) const;
- void operator^= (const valarray<T>&) const;
- void operator&= (const valarray<T>&) const;
- void operator|= (const valarray<T>&) const;
- void operator<<=(const valarray<T>&) const;
- void operator>>=(const valarray<T>&) const;
+or
 
- indirect_array(const indirect_array&);
- ~indirect_array();
- indirect_array& operator=(const indirect_array&);
- void operator=(const T&) const;
- private:
- indirect_array();
- };
-}
+\begin{codeblock}
+binary_op(binary_op(...,
+ binary_op(*first, *(first + 1)),...), *(first + (i - result)))
 \end{codeblock}
 
 \pnum
-This template is a helper template used by the indirect subscript operator
-
-\begin{itemdecl}
-indirect_array<T> valarray<T>::operator[](const valarray<size_t>&).
-\end{itemdecl}
+\returns\
+\tcode{result + (last - first)}.
 
-\begin{itemdescr}
 \pnum
-It has reference semantics to a subset of an array specified by an
-\tcode{indirect_array}.
-Thus the expression
-\tcode{a[\brk{}indirect] = b;}\
-has the effect of assigning the elements of
-\tcode{b}\
-to the elements in
-\tcode{a}\
-whose indices appear in
-\tcode{indirect}.
-\end{itemdescr}
-
-\rSec3[indirect.array.cons]{\tcode{indirect_array}\ constructors}
+\complexity\
+Exactly
+\tcode{(last - first) - 1}\
+applications of
+\tcode{binary_op}.
 
-\index{indirect_array@\tcode{indirect_array}!\tcode{indirect_array}}%
-\begin{itemdecl}
-indirect_array();
-\end{itemdecl}
+\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.
+}
 
-\begin{itemdescr}
 \pnum
-This constructor is declared to be private.
-This constructor need not be defined.
+\notes\
+\tcode{result}\
+may be equal to
+\tcode{first}.
 \end{itemdescr}
 
-\rSec3[indirect.array.assign]{\tcode{indirect_array}\ assignment}
+\rSec2[lib.adjacent.difference]{Adjacent difference}
 
-\index{operator=@\tcode{operator=}!\tcode{indirect_array}}%
+\index{adjacent_difference@\tcode{adjacent_difference}}%
+\color{addclr}
 \begin{itemdecl}
-void operator=(const valarray<T>&) const;
-indirect_array& operator=(const indirect_array&);
+template <InputIterator InIter, OutputIterator<auto, InIter::value_type> OutIter>
+ requires HasMinus<InIter::value_type, InIter::value_type> &&
+ CopyAssignable<OutIter, HasMinus<InIter::value_type, InIter::value_type>::result_type> &&
+ CopyConstructible<InIter::value_type> && CopyAssignable<InIter::value_type>
+ OutIter adjacent_difference(InIter @\farg{first}@, InIter @\farg{last}@,
+ OutIter @\farg{result}@);
+template <InputIterator InIter, OutputIterator<auto, InIter::value_type> OutIter,
+ Callable<auto, InIter::value_type, InIter::value_type> BinaryOperation>
+ requires CopyAssignable<OutIter::reference, BinaryOperation::result_type> &&
+ CopyConstructible<InIter::value_type> && CopyAssignable<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
-These assignment operators have reference semantics, assigning the values
-of the argument array elements to selected elements of the
-\tcode{valarray<T>}\
-object to which it refers.
+\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
 
-\pnum
-If the
-\tcode{indirect_array}
-specifies an element in the
-\tcode{valarray<T>}\
-object to which it refers more than once, the behavior is undefined.
-\index{undefined}%
+\begin{codeblock}
+*(first + (i - result)) - *(first + (i - result) - 1)
+\end{codeblock}
+
+or
 
-\pnum
-\enterexample\
 \begin{codeblock}
-int addr[] = {2, 3, 1, 4, 4};
-valarray<size_t> indirect(addr, 5);
-valarray<double> a(0., 10), b(1., 5);
-a[indirect] = b;
+binary_op(*(first + (i - result)), *(first + (i - result) - 1)).
 \end{codeblock}
-results in undefined behavior since element 4 is specified twice in the
-indirection.
-\exitexample\
-\end{itemdescr}
 
-\rSec3[indirect.array.comp.assign]{\tcode{indirect_array}\ computed assignment}
+\tcode{result}
+gets the value of
+\tcode{*first}.
 
-\index{operator*=@\tcode{operator*=}!\tcode{indirect_array}}%
-\index{operator*=@\tcode{operator*=}!\tcode{indirect_array}}%
-\index{operator*=@\tcode{operator*=}!\tcode{indirect_array}}%
-\index{operator/=@\tcode{operator/=}!\tcode{indirect_array}}%
-\index{operator\%=@\tcode{operator\%=}!\tcode{indirect_array}}%
-\index{operator+=@\tcode{operator+=}!\tcode{indirect_array}}%
-\index{operator-=@\tcode{operator-=}!\tcode{indirect_array}}%
-\index{operator\^{}=@\tcode{operator\^{}=}!\tcode{indirect_array}}%
-\index{operator\&=@\tcode{operator\&=}!\tcode{indirect_array}}%
-\index{operator"|=@\tcode{operator"|=}!\tcode{indirect_array}}%
-\index{operator<<=@\tcode{operator\shl=}!\tcode{indirect_array}}%
-\index{operator>>=@\tcode{operator\shr=}!\tcode{indirect_array}}%
-\begin{itemdecl}
-void operator*= (const valarray<T>&) const;
-void operator/= (const valarray<T>&) const;
-void operator%= (const valarray<T>&) const;
-void operator+= (const valarray<T>&) const;
-void operator-= (const valarray<T>&) const;
-void operator^= (const valarray<T>&) const;
-void operator&= (const valarray<T>&) const;
-void operator|= (const valarray<T>&) const;
-void operator<<=(const valarray<T>&) const;
-void operator>>=(const valarray<T>&) const;
-\end{itemdecl}
+\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.
+}
 
-\begin{itemdescr}
 \pnum
-These computed assignments have reference semantics, applying the indicated
-operation to the elements of the argument array and selected elements of the
-\tcode{valarray<T>}\
-object to which the
-\tcode{indirect_array}\
-object refers.
+\notes\
+\tcode{result}\
+may be equal to
+\tcode{first}.
 
 \pnum
-If the
-\tcode{indirect_array}\
-specifies an element in the
-\tcode{valarray<T>}\
-object to which it refers more than once,
-the behavior is undefined.
-\index{undefined}
+\returns\
+\tcode{result + (last - first)}.
+
+\pnum
+\complexity\
+Exactly
+\tcode{(last - first) - 1}\
+applications of
+\tcode{binary_op}.
 \end{itemdescr}
 
-\rSec3[indirect.array.fill]{\tcode{indirect_array}\ fill function}
+\end{paras}
 
-\index{fill@\tcode{fill}!\tcode{indirect_array}}%
-\begin{itemdecl}
-void operator=(const T&) const;
-\end{itemdecl}
+\bibliographystyle{plain}
+\bibliography{local}
 
-\begin{itemdescr}
-\pnum
-This function has reference semantics, assigning the value of its argument
-to the elements of the
-\tcode{valarray<T>}\
-object to which the
-\tcode{indirect_array}\
-object refers.
-\end{itemdescr}
+\end{document}
\ No newline at end of file


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