Files
2025-10-25 03:02:53 +03:00

5.0 KiB
Raw Permalink Blame History

[template.indirect.array]

29 Numerics library [numerics]

29.6 Numeric arrays [numarray]

29.6.9 Class template indirect_array [template.indirect.array]

29.6.9.1 Overview [template.indirect.array.overview]

🔗

namespace std {template class indirect_array {public:using value_type = T; void operator= (const valarray&) const; void operator*= (const valarray&) const; void operator/= (const valarray&) const; void operator%= (const valarray&) const; void operator+= (const valarray&) const; void operator-= (const valarray&) const; void operator^= (const valarray&) const; void operator&= (const valarray&) const; void operator|= (const valarray&) const; void operator<<=(const valarray&) const; void operator>>=(const valarray&) const;

indirect_array(const indirect_array&); ~indirect_array(); const indirect_array& operator=(const indirect_array&) const; void operator=(const T&) const;

indirect_array() = delete; // as implied by declaring copy constructor above};}

1

#

This template is a helper template used by the indirect subscript operator

🔗

indirect_array<T> valarray<T>::operator[](const valarray<size_t>&);

2

#

It has reference semantics to a subset of an array specified by anindirect_array.

Thus, the expressiona[indirect] = b; has the effect of assigning the elements ofb to the elements ina whose indices appear inindirect.

29.6.9.2 Assignment [indirect.array.assign]

🔗

void operator=(const valarray<T>&) const; const indirect_array& operator=(const indirect_array&) const;

1

#

These assignment operators have reference semantics, assigning the values of the argument array elements to selected elements of thevalarray object to which it refers.

2

#

If theindirect_array specifies an element in thevalarray object to which it refers more than once, the behavior is undefined.

3

#

[Example 1:

int addr[] = {2, 3, 1, 4, 4}; valarray<size_t> indirect(addr, 5); valarray a(0., 10), b(1., 5); a[indirect] = b; results in undefined behavior since element 4 is specified twice in the indirection.

— end example]

29.6.9.3 Compound assignment [indirect.array.comp.assign]

🔗

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;

1

#

These compound assignments have reference semantics, applying the indicated operation to the elements of the argument array and selected elements of thevalarray object to which theindirect_array object refers.

2

#

If theindirect_array specifies an element in thevalarray object to which it refers more than once, the behavior is undefined.

29.6.9.4 Fill function [indirect.array.fill]

🔗

void operator=(const T&) const;

1

#

This function has reference semantics, assigning the value of its argument to the elements of thevalarray object to which theindirect_array object refers.