NABLA  Nabla Ain't Basic Linear Algebra
reference Struct Reference

Reference tag. More...

Detailed Description

Reference tag.

Requirements:
Expressions tagged with reference must be mutable, i.e. one can change (or just get) object's elements using subscript operator. All changes are reflected on the referred object.

Reference Concept Description

Formally this concept can be thought of as a refinement of tag::expression .

Here is a concept description of a matrix reference class.

class type_id : public expression_id<value_type_id, type_id, tag::reference >
{
public:
//Type of elements manipulated by this class.
typedef value_type_id value_type;
//Reference to value type, typically 'value_type&'.
typedef implementation_defined reference;
//Reference to constant value type, typically 'const value_type&'.
typedef implementation_defined const_reference;
//Copy constructor with ordinary semantics.
type_id(type_id&);
//Subscript operator.
reference operator()(size_t row, size_t col);
//Subscript operator.
const_reference operator()(size_t row, size_t col) const;
//Returns number of rows.
size_t rows() const;
//Returns number of columns.
size_t cols() const;
private:
//Inaccessible copy assignment operator.
type_id &operator=(const type_id&); //do not define
};

And here is one for a vector reference class.

class type_id : public expression_id<value_type_id, type_id, tag::reference >
{
public:
//Type of elements manipulated by this class.
typedef value_type_id value_type;
//Reference to value type, typically 'value_type&'.
typedef implementation_defined reference;
//Reference to constant value type, typically 'const value_type&'.
typedef implementation_defined const_reference;
//Copy constructor with ordinary semantics.
type_id(type_id&);
//Subscript operator.
reference operator()(size_t i);
//Subscript operator.
const_reference operator()(size_t i) const;
//Returns size of vector.
size_t size() const;
private:
//Inaccessible copy assignment operator.
type_id &operator=(const type_id&); //do not define
};

All entities are fully analogous to the case of tag::storage.

For description of value_type, reference, const_reference, copy constructor, subscript operator, rows(), cols() and size() members see Storage Concept Description.

A reference object can refer to an arbitrary object and even to its part. In other words a reference is an object with fixed structure but with mutable elements. Thus to preserve the invariants and structure of the referred object it is forbidden to directly assign an expression (inluding another reference) to the reference. That's why the copy assignment operator must be hidden (declared private and not implemented). It states that copy assignment is not the part of the reference interface, however it may be implemented in user types as convenience function.

See Also
storage, expression

Definition at line 921 of file matrix.h.


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