View Template Library


transform_view<Container, Transform, Const_tag, T, Base>

Category: adaptors

Component type: type

Description

The transform_view template represents objects that reference one container, and that have methods for accessing its elements. The properties of any transform_view instance depend on the properties of the container template parameter. The interface of transform_view adapts itself [1] to the referenced container, if this is one of Container provides a Container interface, a transform_view referencing Forward Containers provides a Forward Container interface while a Random Access Container provides a Random Access Conatiner interface, or Sequence interface.

The transform_view presents transformed values, depending on the transformation template parameter. Transformation is only applied in presenting the elements, the container's elements themselves are not altered.

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

A transform_view owns its referenced container, if its base template parameter is aggregated_ownership, it merely references its container, if the base template parameter is referenced_ownership.

Template parameters

Parameter

Description

Default

container

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


transformation

The view's transformation type: the type of the transformation used to transform the container's elements


const_tag

The view's const tag: either const_view_tag or mutable_view_tag

const_view_tag

T

The view's value type: the type of elements referenced by this view.

transformation::result_type

base

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 transform_view.hpp.

Model of

View

Type requirements

T has to be assignable. transformation has to be a functor with result type T and argument type container::value_type. transformation's operator() has to be a const member.


Members

Member

Where defined

Description

value_type

Container

The type T of the elements accessed through the container.

domain_t

view

The type of the referenced container.

transform_t

view

The type of the transformation.

pointer

Container

Pointer to T.

reference

Container

T

const_reference

Container

const T

size_type

Container

An unsigned integral type.

difference_type

Container

A signed integral 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 the view.

const_reverse_iterator

Reversible Container

Const iterator used to iterate backwards through the view.

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 reversible container's only. Returns a reverse_iterator pointing to the beginning of the reversed view.

reverse_iterator rend()

Reversible Container

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

const_reverse_iterator rbegin() const

Reversible Container

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

const_reverse_iterator rend() const

Reversible Container

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

reference front()

Sequence

Returns a reference for the first element in the view. Only supported if container is a sequence.

reference back()

Sequence

Returns a reference for the last element in the view. Only supported if container is a sequence.

const_reference front() const

Sequence

Returns a const_reference for the first element in the view. Only supported if container is a sequence.

const_reference back() const

Sequence

Returns a const_reference for the last element in the view. Only supported if container is a sequence.

void pop_front()

Sequence

Call pop_front on the underlying container.

void pop_back()

Sequence

Call pop_back on the underlying container.

reference operator[](size_type n)

Random access container

Returns a reference for the nth element in the view. Only supported if container is random access.

const_reference operator[](size_type n) const

Random access container

Returns a const_reference for the nth element in the view. Only supported if container is random access.

reference at(size_type n)

Random access container

Returns a reference for the nth element in the view. Only supported if container is random access. 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 view. Only supported if container is random access. 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.

transform_view()

view

Creates an empty view.

transform_view(container_t&, const transform_t&)

view

Creates a view of given container.

void swap(transform_view&)

Container

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

bool operator==(const transform_view&, const transform_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 transform_view&, const transform_view&)

Forward Container

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

Notes

[1] Since in general the transformation results in temporary objects, non const references as return value of e.g. front are useless. Instead, reference is defined to be the same as value_type here. Whether and how altering the elements of the view affects the elements of the referenced contianer depends on the template parameter const_tag and the transformation.



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