Boost logo

Glas :

[glas] assignment policy

From: Karl Meerbergen (Karl.Meerbergen_at_[hidden])
Date: 2006-01-23 07:18:08


Hi,

Next to the evaluation of expressions by some backend, there might also
be need for different assigment policies: e.g.
1) left hand side and right hand side must have the same size.
2) left hand side resizes before the assignment if sizes do not match.

For sparse collections, there are more choices:
3) the sparse structure on left and right hand sides must be the same
4) the sparse left hand side takes the structure of the right hand side
(it does no look at the numerical values)
5) the sparse left hand side only creates a structural non-zero when the
corresponding element in the right-hand side has a non-zero value (the
numerical values are checked).

Etc.

There can also be user defined policies.

The syntax to get this assignment behaviour can happen in the same way
as the dispatching to a back_end.

For example, we can have
assign<my_policy,my_back_end>(v, e);
which is by default:
v = e;

and also

add_assign<policy,backend>(v,e) or by default: v+=e
subtract_assign<policy,backend>(v,e) or by default v-=e;

Alternatively, we can provide adaptors: e.g.

keep_sparse_structure(v) += e ;
fixed_size(v) = e ;

etc.

In addition, containers (and views) may have a tag or attribute that
decides which is the default assignment policy.

Karl