[indirect.array.assign]

# 29 Numerics library [[numerics]](./#numerics)

## 29.6 Numeric arrays [[numarray]](numarray#indirect.array.assign)

### 29.6.9 Class template indirect_array [[template.indirect.array]](template.indirect.array#indirect.array.assign)

#### 29.6.9.2 Assignment [indirect.array.assign]

[ð](#lib:operator=,indirect_array)

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

[1](#1)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9057)

These assignment operators have reference semantics, assigning the values
of the argument array elements to selected elements of thevalarray<T> object to which it refers[.](#1.sentence-1)

[2](#2)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9063)

If theindirect_array specifies an element in thevalarray<T> object to which it refers more than once, the behavior is undefined[.](#2.sentence-1)

[3](#3)

[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/numerics.tex#L9071)

[*Example [1](#example-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; results in undefined behavior since element 4 is specified twice in the
indirection[.](#3.sentence-1)

â *end example*]
