Boost logo

Boost-Commit :

From: dgregor_at_[hidden]
Date: 2008-03-16 18:03:16


Author: dgregor
Date: 2008-03-16 18:03:16 EDT (Sun, 16 Mar 2008)
New Revision: 43659
URL: http://svn.boost.org/trac/boost/changeset/43659

Log:
Pare down what we're putting into the numerics chapter, for now
Text files modified:
   sandbox/committee/concepts/stdlib/clib-numerics.tex | 1845 ++++++++++++++++++++-------------------
   1 files changed, 927 insertions(+), 918 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-03-16 18:03:16 EDT (Sun, 16 Mar 2008)
@@ -44,7 +44,7 @@
 \end{center}
 
 \vspace{1in}
-\par\noindent Document number: D2574=08-0084\vspace{-6pt}
+\par\noindent Document number: N2574=08-0084\vspace{-6pt}
 \par\noindent Revises document number: N2041=06-0111\vspace{-6pt}
 \par\noindent Date: \today\vspace{-6pt}
 \par\noindent Project: Programming Language \Cpp{}, Library Working Group\vspace{-6pt}
@@ -52,6 +52,13 @@
 
 \section*{Introduction}
 \libintrotext{Chapter 26}
+
+\paragraph*{Changes from N2041}
+\begin{itemize}
+\item Update to the latest concepts syntax and the appropriate names
+ of the core concepts.
+\end{itemize}
+
 \end{titlepage}
 
 %%--------------------------------------------------
@@ -78,109 +85,435 @@
 \rSec0[lib.numerics]{Numerics library}
 \begin{paras}
 
-\setcounter{section}{4}
-\rSec1[numarray]{Numeric arrays}
+\setcounter{section}{5}
 
-\rSec2[valarray.synopsis]{Header \tcode{<valarray>}\ synopsis}
-\index{valarray@\tcode{<valarray>}}%
+\rSec1[lib.numeric.ops]{Generalized numeric operations}
+
+\synopsis{Header \tcode{<numeric>}\ synopsis}
+\index{numeric@\tcode{<numeric>}}%
+
+\color{addclr}
 \begin{codeblock}
 namespace std {
- template<@\changedCC{class}{Regular}@ 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;
- 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
+ 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}
 
- @\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>\&\&);}@
+\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.
 
- 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 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>&);
+\rSec2[lib.accumulate]{Accumulate}
 
- 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 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>&);
+\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}
 
- 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 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>&);
+\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.
+}
 
- 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 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>&);
+\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}
 
- 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 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>&);
+\rSec2[lib.inner.product]{Inner product}
+\index{inner_product@\tcode{inner_product}}%
 
- 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 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>&);
+\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}
 
- 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 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>&);
+\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.
 
- 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 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>&);
+\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}
+
+\rSec2[valarray.synopsis]{Header \tcode{<valarray>}\ synopsis}
+\index{valarray@\tcode{<valarray>}}%
+\begin{codeblock}
+namespace std {
+ template<@\changedCC{class}{Regular}@ 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;
+ 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 HasMultiply<T> \&\& Convertible<T::result_type, 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 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 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 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 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 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 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 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 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 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 HasLeftShift<T> \&\& Convertible<T::result_type, T>}@
     valarray<T> operator<<(const valarray<T>&, const T&);
   template<class T>
@@ -1322,380 +1655,81 @@
     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
-\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[cons.slice.arr]{\tcode{slice_array}\ constructors}
-
-\index{slice_array@\tcode{slice_array}!\tcode{slice_array}}%
-\begin{itemdecl}
-slice_array();
-\end{itemdecl}
-
-\begin{itemdescr}
-\pnum
-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}
-void operator=(const valarray<T>&) const;
-slice_array& operator=(const slice_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
-\tcode{valarray<T>}\
-object to which the
-\tcode{slice_array}\
-object refers.
-\end{itemdescr}
-
-\rSec3[slice.arr.comp.assign]{\tcode{slice_array}\ computed assignment}
-
-\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}
-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
-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[slice.arr.fill]{\tcode{slice_array}\ fill function}
-
-\index{fill@\tcode{fill}!\tcode{slice_array}}%
-\begin{itemdecl}
-void operator=(const T&) const;
-\end{itemdecl}
-
-\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{slice_array}\
-object refers.
-\end{itemdescr}
-
-\rSec2[class.gslice]{The \tcode{gslice}\ class}
-
-\index{gslice@\tcode{gslice}!class}%
-\begin{codeblock}
-namespace std {
- class gslice {
- 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$.
-
-\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\
+ size_t start() const;
+ size_t size() const;
+ size_t stride() const;
+ };
+}
+\end{codeblock}
 
 \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}%
+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[gslice.cons]{\tcode{gslice}\ constructors}
+\rSec3[cons.slice]{\tcode{slice}\ constructors}
 
-\index{gslice@\tcode{gslice}!\tcode{gslice}}%
+\index{slice@\tcode{slice}!\tcode{slice}}%
 \begin{itemdecl}
-gslice();
-gslice(size_t @\farg{start}@, const valarray<size_t>& @\farg{lengths}@,
- const valarray<size_t>& @\farg{strides}@);
-gslice(const gslice&);
+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 creates a
-\mbox{\tcode{gslice}}
+\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{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}
+{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.
 
-\rSec3[gslice.access]{\tcode{gslice}\ access functions}
+\pnum
+\enterexample\
+\tcode{slice(3, 8, 2)}\
+constructs a slice which selects elements 3, 5, 7, ... 17 from an array.
+\exitexample\
+\end{itemdescr}
 
-\index{start@\tcode{start}!\tcode{gslice}}%
-\index{size@\tcode{size}!\tcode{gslice}}%
-\index{stride@\tcode{stride}!\tcode{gslice}}%
+\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;
-valarray<size_t> size() const;
-valarray<size_t> stride() const;
+size_t start() const;
+size_t size() const;
+size_t stride() const;
 \end{itemdecl}
 
 \begin{itemdescr}
 \pnum
-These access functions return the representation of the start, lengths, or
-strides specified for the
-\tcode{gslice}.
+These functions return the start, length, or stride specified by a
+\tcode{slice}\ object.
 \end{itemdescr}
 
-\rSec2[template.gslice.array]{Class template \tcode{gslice_array}}
+\rSec2[template.slice.array]{Class template \tcode{slice_array}}
 
-\index{gslice_array@\tcode{gslice_array}}%
+\index{slice_array@\tcode{slice_array}}%
 \begin{codeblock}
 namespace std {
- template <class T> class gslice_array {
+ template <class T> class slice_array {
   public:
     typedef T value_type;
 
@@ -1711,48 +1745,50 @@
     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&);
- void operator=(const T&) const;
+ slice_array(const slice_array&);
+ ~slice_array();
+ slice_array& operator=(const slice_array&);
+ void operator=(const T&) const;
   private:
- gslice_array();
+ slice_array();
   };
 }
 \end{codeblock}
 
 \pnum
-This template is a helper template used by the
+The
+\tcode{slice_array}\
+template is a helper template used by the
 \tcode{slice}\
 subscript operator
 
-\index{gslice_array@\tcode{gslice_array}}%
-\index{valarray@\tcode{valarray}}%
-\begin{itemdecl}
-gslice_array<T> valarray<T>::operator[](const gslice&);
-\end{itemdecl}
+\begin{codeblock}
+slice_array<T> valarray<T>::operator[](slice);
+\end{codeblock}
 
-\begin{itemdescr}
-\pnum
 It has reference semantics to a subset of an array specified by a
-\tcode{gslice}\
+\tcode{slice}
 object.
 
 \pnum
-Thus, the expression
-\tcode{a[gslice(1, length, stride)] = b}\
+\enterexample\
+The expression
+\tcode{a[slice(1, 5, 3)] = b;}\
 has the effect of assigning the elements of
 \tcode{b}\
-to a
-generalized slice of the elements in
+to a slice of the elements in
 \tcode{a}.
-\end{itemdescr}
+For the slice shown, the elements
+selected from
+\tcode{a}\
+are 1, 4, ..., 13.
+\exitexample\
 
-\rSec3[gslice.array.cons]{\tcode{gslice_array}\ constructors}
+\rSec3[cons.slice.arr]{\tcode{slice_array}\ constructors}
 
-\index{gslice_array@\tcode{gslice_array}!\tcode{gslice_array}}%
+\index{slice_array@\tcode{slice_array}!\tcode{slice_array}}%
 \begin{itemdecl}
-gslice_array();
+slice_array();
 \end{itemdecl}
 
 \begin{itemdescr}
@@ -1761,36 +1797,37 @@
 This constructor need not be defined.
 \end{itemdescr}
 
-\rSec3[gslice.array.assign]{\tcode{gslice_array}\ assignment}
+\rSec3[slice.arr.assign]{\tcode{slice_array}\ assignment}
 
-\index{operator=@\tcode{operator=}!\tcode{gslice_array}}%
+\index{operator=@\tcode{operator=}!\tcode{slice_array}}%
 \begin{itemdecl}
-void operator=(const valarray<T>&) const;
-gslice_array& operator=(const gslice_array&);
+void operator=(const valarray<T>&) const;
+slice_array& operator=(const slice_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{gslice_array}\
-refers.
+\tcode{slice_array}\
+object refers.
 \end{itemdescr}
 
-\rSec3[gslice.array.comp.assign]{\tcode{gslice_array}}
+\rSec3[slice.arr.comp.assign]{\tcode{slice_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{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}
 void operator*= (const valarray<T>&) const;
 void operator/= (const valarray<T>&) const;
@@ -1807,17 +1844,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{gslice_array}\
+\tcode{slice_array}\
 object refers.
 \end{itemdescr}
 
-\rSec3[gslice.array.fill]{\tcode{gslice_array}\ fill function}
+\rSec3[slice.arr.fill]{\tcode{slice_array}\ fill function}
 
-\index{fill@\tcode{fill}!\tcode{gslice_array}}%
+\index{fill@\tcode{fill}!\tcode{slice_array}}%
 \begin{itemdecl}
 void operator=(const T&) const;
 \end{itemdecl}
@@ -1828,151 +1865,170 @@
 to the elements of the
 \tcode{valarray<T>}\
 object to which the
-\tcode{gslice_array}\
+\tcode{slice_array}\
 object refers.
 \end{itemdescr}
 
-\rSec2[template.mask.array]{Class template \tcode{mask_array}}
+\rSec2[class.gslice]{The \tcode{gslice}\ class}
 
-\index{mask_array@\tcode{mask_array}}%
+\index{gslice@\tcode{gslice}!class}%
 \begin{codeblock}
 namespace std {
- template <class T> class mask_array {
+ class gslice {
   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;
+ gslice();
+ gslice(size_t s, const valarray<size_t>& l, const valarray<size_t>& d);
 
- mask_array(const mask_array&);
- ~mask_array();
- mask_array& operator=(const mask_array&);
- void operator=(const T&) const;
- private:
- mask_array();
+ size_t start() const;
+ valarray<size_t> size() const;
+ valarray<size_t> stride() const;
   };
 }
 \end{codeblock}
 
-\pnum
-This template is a helper template used by the mask subscript operator:
+\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$.
+
+\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
 
-\begin{itemdecl}
-mask_array<T> valarray<T>::operator[](const valarray<bool>&).
-\end{itemdecl}
+$$k = 3 + (0,1) \times 19 + (0,1,2,3) \times 4 + (0,1,2) \times 1$$
 
-\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}
+which are ordered as shown in the following table:
 
-\rSec3[mask.array.cons]{\tcode{mask_array}\ constructors}
+\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}
 
-\index{mask_array@\tcode{mask_array}!\tcode{mask_array}}%
-\begin{itemdecl}
-mask_array();
-\end{itemdecl}
+That is, the highest-ordered index turns fastest.
+\exitexample\
 
-\begin{itemdescr}
 \pnum
-This constructor is declared to be private.
-This constructor need not be defined.
-\end{itemdescr}
+It is possible to have degenerate generalized slices in which an address
+is repeated.
 
-\rSec3[mask.array.assign]{\tcode{mask_array}\ assignment}
+\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
 
-\index{operator=@\tcode{operator=}!\tcode{mask_array}}%
-\begin{itemdecl}
-void operator=(const valarray<T>&) const;
-mask_array& operator=(const mask_array&);
-\end{itemdecl}
+\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\
 
-\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}
+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[mask.array.comp.assign]{\tcode{mask_array}\ computed assignment}
+\rSec3[gslice.cons]{\tcode{gslice}\ constructors}
 
-\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}}%
+\index{gslice@\tcode{gslice}!\tcode{gslice}}%
 \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;
+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
-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.
+\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.
 \end{itemdescr}
 
-\rSec3[mask.array.fill]{\tcode{mask_array}\ fill function}
+\rSec3[gslice.access]{\tcode{gslice}\ access functions}
 
-\index{fill@\tcode{fill}!\tcode{mask_array}}%
+\index{start@\tcode{start}!\tcode{gslice}}%
+\index{size@\tcode{size}!\tcode{gslice}}%
+\index{stride@\tcode{stride}!\tcode{gslice}}%
 \begin{itemdecl}
-void operator=(const T&) const;
+size_t start() const;
+valarray<size_t> size() const;
+valarray<size_t> stride() const;
 \end{itemdecl}
 
 \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.
+These access functions return the representation of the start, lengths, or
+strides specified for the
+\tcode{gslice}.
 \end{itemdescr}
 
-\rSec2[template.indirect.array]{Class template \tcode{indirect_array}}
+\rSec2[template.gslice.array]{Class template \tcode{gslice_array}}
 
-\index{indirect_array@\tcode{indirect_array}}%
+\index{gslice_array@\tcode{gslice_array}}%
 \begin{codeblock}
 namespace std {
- template <class T> class indirect_array {
+ template <class T> class gslice_array {
   public:
     typedef T value_type;
 
@@ -1988,42 +2044,48 @@
     void operator<<=(const valarray<T>&) const;
     void operator>>=(const valarray<T>&) const;
 
- indirect_array(const indirect_array&);
- ~indirect_array();
- indirect_array& operator=(const indirect_array&);
+ gslice_array(const gslice_array&);
+ ~gslice_array();
+ gslice_array& operator=(const gslice_array&);
     void operator=(const T&) const;
   private:
- indirect_array();
+ gslice_array();
   };
 }
 \end{codeblock}
 
 \pnum
-This template is a helper template used by the indirect subscript operator
+This template is a helper template used by the
+\tcode{slice}\
+subscript operator
 
+\index{gslice_array@\tcode{gslice_array}}%
+\index{valarray@\tcode{valarray}}%
 \begin{itemdecl}
-indirect_array<T> valarray<T>::operator[](const valarray<size_t>&).
+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 an
-\tcode{indirect_array}.
-Thus the expression
-\tcode{a[\brk{}indirect] = b;}\
+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}\
 has the effect of assigning the elements of
 \tcode{b}\
-to the elements in
-\tcode{a}\
-whose indices appear in
-\tcode{indirect}.
+to a
+generalized slice of the elements in
+\tcode{a}.
 \end{itemdescr}
 
-\rSec3[indirect.array.cons]{\tcode{indirect_array}\ constructors}
+\rSec3[gslice.array.cons]{\tcode{gslice_array}\ constructors}
 
-\index{indirect_array@\tcode{indirect_array}!\tcode{indirect_array}}%
+\index{gslice_array@\tcode{gslice_array}!\tcode{gslice_array}}%
 \begin{itemdecl}
-indirect_array();
+gslice_array();
 \end{itemdecl}
 
 \begin{itemdescr}
@@ -2032,12 +2094,12 @@
 This constructor need not be defined.
 \end{itemdescr}
 
-\rSec3[indirect.array.assign]{\tcode{indirect_array}\ assignment}
+\rSec3[gslice.array.assign]{\tcode{gslice_array}\ assignment}
 
-\index{operator=@\tcode{operator=}!\tcode{indirect_array}}%
+\index{operator=@\tcode{operator=}!\tcode{gslice_array}}%
 \begin{itemdecl}
 void operator=(const valarray<T>&) const;
-indirect_array& operator=(const indirect_array&);
+gslice_array& operator=(const gslice_array&);
 \end{itemdecl}
 
 \begin{itemdescr}
@@ -2045,43 +2107,23 @@
 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.
-
-\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\
+object to which the
+\tcode{gslice_array}\
+refers.
 \end{itemdescr}
 
-\rSec3[indirect.array.comp.assign]{\tcode{indirect_array}\ computed assignment}
+\rSec3[gslice.array.comp.assign]{\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}}%
+\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;
@@ -2097,26 +2139,18 @@
 
 \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{indirect_array}\
+\tcode{gslice_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[indirect.array.fill]{\tcode{indirect_array}\ fill function}
+\rSec3[gslice.array.fill]{\tcode{gslice_array}\ fill function}
 
-\index{fill@\tcode{fill}!\tcode{indirect_array}}%
+\index{fill@\tcode{fill}!\tcode{gslice_array}}%
 \begin{itemdecl}
 void operator=(const T&) const;
 \end{itemdecl}
@@ -2127,330 +2161,305 @@
 to the elements of the
 \tcode{valarray<T>}\
 object to which the
-\tcode{indirect_array}\
+\tcode{gslice_array}\
 object refers.
 \end{itemdescr}
 
-\rSec1[lib.numeric.ops]{Generalized numeric operations}
-
-\synopsis{Header \tcode{<numeric>}\ synopsis}
-\index{numeric@\tcode{<numeric>}}%
+\rSec2[template.mask.array]{Class template \tcode{mask_array}}
 
-\color{addclr}
+\index{mask_array@\tcode{mask_array}}%
 \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}@);
+ template <class T> class mask_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;
+
+ mask_array(const mask_array&);
+ ~mask_array();
+ mask_array& operator=(const mask_array&);
+ void operator=(const T&) const;
+ private:
+ mask_array();
+ };
 }
 \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}
+This template is a helper template used by the mask subscript operator:
 
-\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}@);
+mask_array<T> valarray<T>::operator[](const valarray<bool>&).
 \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.
-}
+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}
 
+\begin{itemdescr}
 \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
-}
+This constructor is declared to be private.
+This constructor need not be defined.
 \end{itemdescr}
 
-\rSec2[lib.inner.product]{Inner product}
-\index{inner_product@\tcode{inner_product}}%
+\rSec3[mask.array.assign]{\tcode{mask_array}\ assignment}
 
-\color{addclr}
+\index{operator=@\tcode{operator=}!\tcode{mask_array}}%
 \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}@);
+void operator=(const valarray<T>&) const;
+mask_array& operator=(const mask_array&);
 \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.
+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}
 
-\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
-}
+\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}
+
+\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.
 \end{itemdescr}
 
-\rSec2[lib.partial.sum]{Partial sum}
-\index{partial_sum@\tcode{partial_sum}}%
-\color{addclr}
+\rSec3[mask.array.fill]{\tcode{mask_array}\ fill function}
+
+\index{fill@\tcode{fill}!\tcode{mask_array}}%
 \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}@);
+void operator=(const T&) const;
 \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
+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}}
 
+\index{indirect_array@\tcode{indirect_array}}%
 \begin{codeblock}
-((...(*first + *(first + 1)) + ...) + *(first + (i - result)))
-\end{codeblock}
+namespace std {
+ template <class T> class indirect_array {
+ public:
+ typedef T value_type;
 
-or
+ 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;
 
-\begin{codeblock}
-binary_op(binary_op(...,
- binary_op(*first, *(first + 1)),...), *(first + (i - result)))
+ indirect_array(const indirect_array&);
+ ~indirect_array();
+ indirect_array& operator=(const indirect_array&);
+ void operator=(const T&) const;
+ private:
+ indirect_array();
+ };
+}
 \end{codeblock}
 
 \pnum
-\returns\
-\tcode{result + (last - first)}.
+This template is a helper template used by the indirect subscript operator
 
-\pnum
-\complexity\
-Exactly
-\tcode{(last - first) - 1}\
-applications of
-\tcode{binary_op}.
+\begin{itemdecl}
+indirect_array<T> valarray<T>::operator[](const valarray<size_t>&).
+\end{itemdecl}
 
+\begin{itemdescr}
 \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.
-}
+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}
+
+\index{indirect_array@\tcode{indirect_array}!\tcode{indirect_array}}%
+\begin{itemdecl}
+indirect_array();
+\end{itemdecl}
 
+\begin{itemdescr}
 \pnum
-\notes\
-\tcode{result}\
-may be equal to
-\tcode{first}.
+This constructor is declared to be private.
+This constructor need not be defined.
 \end{itemdescr}
 
-\rSec2[lib.adjacent.difference]{Adjacent difference}
+\rSec3[indirect.array.assign]{\tcode{indirect_array}\ assignment}
 
-\index{adjacent_difference@\tcode{adjacent_difference}}%
-\color{addclr}
+\index{operator=@\tcode{operator=}!\tcode{indirect_array}}%
 \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}@);
+void operator=(const valarray<T>&) const;
+indirect_array& operator=(const indirect_array&);
 \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}
+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.
 
-or
+\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}
-binary_op(*(first + (i - result)), *(first + (i - result) - 1)).
+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}
 
-\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.
-}
+\rSec3[indirect.array.comp.assign]{\tcode{indirect_array}\ computed assignment}
 
-\pnum
-\notes\
-\tcode{result}\
-may be equal to
-\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}
 
+\begin{itemdescr}
 \pnum
-\returns\
-\tcode{result + (last - first)}.
+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.
 
 \pnum
-\complexity\
-Exactly
-\tcode{(last - first) - 1}\
-applications of
-\tcode{binary_op}.
+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}
 
-\end{paras}
+\rSec3[indirect.array.fill]{\tcode{indirect_array}\ fill function}
 
-\bibliographystyle{plain}
-\bibliography{local}
+\index{fill@\tcode{fill}!\tcode{indirect_array}}%
+\begin{itemdecl}
+void operator=(const T&) const;
+\end{itemdecl}
 
-\end{document}
\ No newline at end of file
+\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}


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