View Template Library


union_view<Cont_a, Cont_b, Const_tag, Iter_tag, Base_a, Base_b>

Category: adaptors

Component type: type

Description

The union_view template represents objects that reference two containers, and that have methods for accessing their elements. The properties of any union_view instance depend on the properties of the container template parameters. More accurately, a union_view referencing Container provides a Container interface, a union_view referencing Forward Containers provides a Forward Container interface while a Random Access Container provides a Random Access Conatiner interface.[1].

The union_view presents all the elements of both containers concatenated.

The guarantees of the order of elements are the same as those provided by both underlying container, as is the validity of more than one active iterators at any one time.

union_views are mutable if and only if the const_tag template parameter is mutable_view_tag.

A union_view owns its referenced containers, if its corresponding base template parameter is aggregated_ownership, it merely references its containers, if the base template parameter is referenced_ownership.

WARNING: Do not confuse the view type with the view concept!

Template parameters

Parameter

Description

Default

container_a

The view's container A type: the type of container referenced by this view


container_b

The view's container B type: the type of container referenced by this view


const_tag

The view's const tag: either const_view_tag or mutable_view_tag

const_view_tag

iterator_tag

The view's directional iterator category

The minium of container_a::iterator::iterator_cateory and container_b::iterator::iterator_category

base_a

The view's ownership type: the base class that determines if the view references or owns the container

referenced_ownership

base_b

The view's ownership type: the base class that determines if the view references or owns the container

referenced_ownership

Definition

Defined in the header union_view.h.

Model of

View

Type requirements

The two containers have to have the same value type. The requirements the union_view satisfies depend on the requirements its template parameters satisfy:

Container satisfies

View satisfies

Container

Container [1]

Forward Containers

Forward Containers [1]

Members

Member

Where defined

Description

value_type

Container

The type T of the elements accessed through the container.

domain_type_a

view

The type of the referenced container A.

domain_type_b

view

The type of the referenced container B.

pointer

Container

container::pointer.

reference

Container

container::reference.

const_reference

Container

container::const_reference.

size_type

Container

conainer::size_type.

difference_type

Container

container::difference_type.

iterator

Container

Iterator used to iterate through the view.

const_iterator

Container

Const iterator used to iterate through the view.

reverse_iterator

Reversible Container

Iterator used to iterate backwards through a container.

const_reverse_iterator

Reversible Container

Const iterator used to iterate backwards through a container.

iterator begin()

Container

Returns an iterator pointing to the begin of the view.

iterator end()

Container

Returns an iterator pointing to the end of the view.

const_iterator begin() const

Container

Returns a const_iterator pointing to the begin of the view.

const_iterator end() const

Container

Returns a const_iterator pointing to the end of the view.

reverse_iterator rbegin()

Reversible Container

Valid for bidirectional container's only. Returns a reverse_iterator pointing to the beginning of the reversed container.

reverse_iterator rend()

Reversible Container

Valid for bidirectional container's only. Returns a reverse_iterator pointing to the end of the reversed container.

const_reverse_iterator rbegin() const

Reversible Container

Valid for bidirectional container's only. Returns a const_reverse_iterator pointing to the beginning of the reversed container.

const_reverse_iterator rend() const

Reversible Container

Valid for bidirectional container's only. Returns a "const_reverse_iterator pointing to the end of the reversed container.

reference front()

Sequence

Returns a reference for the first element in the container.

reference back()

Sequence

Returns a reference for the last element in the container. Requires a bidirectional container.

const_reference front() const

Sequence

Returns a const_reference for the first element in the view.

const_reference back() const

Sequence

Returns a const_reference for the last element in the view. Requires a bidirectional container.

reference operator[](size_type n)

Random access container

Returns a reference for the nth element in the container.

const_reference operator[](size_type n)const

Random access container

Returns a const_reference for the nth element in the container.

reference at(size_type n)

Random access container

Returns a const_reference for the nth element in the container. Does a range check on n and will throw std::range_error if it fails.

const_reference at(size_type n)const

Random access container

Returns a const_reference for the nth element in the container. Does a range check on n and will throw std::range_error if it fails.

size_type size() const

Container

Returns the size of the view.

size_type max_size() const

Container

Returns the largest possible size of the view.

bool empty() const

Container

true if the view's size is 0.

union_view()

view

Creates an empty view.

union_view(domain_a_type&, domain_b_type&)

view

Creates a view of given container.

void swap(union_view&)

Container

Swaps the two views. Iterators are invalidated by this operation. For referencing views, the containers themselves are not swapped.

bool operator==(const union_view&, const union_view&)

Forward Container

Tests two views for equality. This is a global function, not a member function. Views may be equal even if their referenced containers are not.

bool operator<(const union_view&, const union_view&)

Forward Container

Lexicographical comparison. This is a global function, not a member function.

Notes

[1]


VTL Home
Copyright © 1999 Konrad-Zuse-Zentrum für Informationstechnik Berlin & Gary Powell All Rights Reserved.