Relational database theory also defines a concept known as a view. There is a fairly strong analogy between the concept of a relational view and that of the domain view defined here. The following table shows the analogy between a domain view and a relational view of that form. One reason for using a view is reduce the complexity of code that works with containers. It is often the case that only a subset of a container's elements are interesting to a user of the container.
Views allow the user to create an abstract container that contains only the interesting elements.
A view constructed in this way is represented by a single object. A trivial benefit of using a view is that conditional filtering code can be eliminated from the body of processing loops. Examples of this can be seen in the sample program, examples.cpp . A view can be useful when the user of a container needs to use a set of objects functionally derived from the objects in the container, rather than the objects themselves. In this case, the user defines a view using a transformation function that implements the required transformation.