std::begin(std::valarray) - cppreference.com

##### cppreference.com

##### Search

Create account

##### Namespaces

- Page
- Discussion

##### Variants

##### Views

- View
- Edit
- History

##### Actions

# std::begin(std::valarray)

From cppreference.com
< cpp‎ | numeric‎ | valarray

template< class T > /*unspecified1*/ begin( valarray<T>& v ); | (1) | (since C++11)
template< class T > /*unspecified2*/ begin( const valarray<T>& v ); | (2) | (since C++11)

The overload of std::begin for `valarray` returns an iterator of unspecified type referring to the first element in the numeric array.

1) The return type meets the requirements of mutable `RandomAccessIterator`.
2) The return type meets the requirements of constant `RandomAccessIterator`.

The iterator obtained from this function is invalidated when the member function resize() is called on the array `v` or when the lifetime of `v` ends, whichever comes first.

### [edit] Parameters

v | - | a numeric array

### [edit] Return value

Iterator to the first value in the numeric array.

### [edit] Exceptions

(none)

### [edit] Notes

Unlike other functions that take `std::valarray` arguments, `begin()` cannot accept the replacement types (such as the types produced by expression templates) that may be returned from expressions involving valarrays: std::begin(v1 + v2) is not portable, std::begin(std::valarray<T>(v1 + v2)) has to be used instead.

The intent of this function is to allow range for loops to work with valarrays, not to provide container semantics.

### [edit] Example

| This section is incomplete Reason: no example

### [edit] See also

std::end(std::valarray) (C++11) | specializes std::end (function template) [edit]

Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/numeric/valarray/begin2&oldid=71047"
Category:

- Todo no example