Interface Documentation
Version: invalid
array_ref< T > Class Reference

Detailed Description

immutable array of size() elements of type T. The storage for the array is not owned by the array_ref object, and clients must arrange for the backing store to remain live while the array_ref object is in use.

Implicit conversion operations are provided from types with contiguous iterators like std::vector, std::string, std::array, and primitive arrays. array_ref objects are invalidated by any operation that invalidates their underlying pointers.

One common use for array_ref is when passing arguments to a routine where you want to be able to accept a variety of array types. The usual approach here is to have the client explicitly pass in a pointer and a length, as in:

Unfortunately, this leads to ugly and error-prone code at the call site:
Instead, you can use an array_ref as the argument to the routine:
This makes the call sites cleaner, for the most part:
Todo:
The existing array_ref classes make the view const. It may be useful to extend that to allow modifications of the referenced array elements, and use array_ref<const T> for immutable views.

The documentation for this class was generated from the following file: