template<class T>
class indirect_array {
public:
typedef T value_type;
void operator=(const valarray<T> x) const;
void operator=(const T& x);
void operator*=(const valarray<T> x) const;
void operator/=(const valarray<T> x) const;
void operator%=(const valarray<T> x) const;
void operator+=(const valarray<T> x) const;
void operator-=(const valarray<T> x) const;
void operator^=(const valarray<T> x) const;
void operator&=(const valarray<T> x) const;
void operator|=(const valarray<T> x) const;
void operator<<=(const valarray<T> x) const;
void operator>>=(const valarray<T> x) const;
void fill();
};
The class describes an object that stores a reference to an object x of class valarray<T>, along with an object xa of
class valarray<size_t>, which describes the sequence of elements to select from the valarray<T> object.
You construct an indirect_array<T> object only by writing an expression of the form x[xa]. The member
functions of class indirect_array then behave like the corresponding function signatures defined for valarray<T>,
except that only the sequence of selected elements is affected.
The sequence consists of xa.size() elements, where element i becomes the index xa[i] within x. For example:
const size_t vi[] = {7, 5, 2, 3, 8};
// x[valarray<size_t>(vi, 5)] selects elements with indices
// 7, 5, 2, 3, 8