Views

The concepts

A view is a Collection that puts a window on the data, e.g. a matrix row, a subvector. Whereas an expression usually is read-only, a view allows changing its data.

A view is used to access a part of the data or modify or adapt the data. Element access using operator[] or operator() and (sometimes) iterators (or pointers) are defined for views. In other words, when an iterator should be put on a Collection that is no STL-Container, first select a View that also is an STL-Container with the desired iterator.

A Sequence is too strong a condition. Which is the reason for requiring a Container or a Sequence?

Creation of a view

Let X be a Collection, and suppose we want to create a view on this, e.g. view. A view is created by invoking a function, view( x, arguments ) whose result_type is determined by a meta function or a functor. We consider two cases :
  1. view_type<X>::type view( x, arguments ) ;
    
    where view_type selects the right type for performing the view.

    view(x,...) is a shortcut for view_type<X>::type(x,...).

  2. view_functor<X>::result_type view( x, arguments ) ;
    
    where view_functor implements the view for the given type.

    view(x,...) is a shortcut for view_functor<X>() (x,...).

Resizing a view

Is a view a constant size window on an Expression, view or Container. Can it be changed or not?

Copying a view

Do we copy the data or only the view?