Boost logo

Boost :

From: Michael Stevens (michael_at_[hidden])
Date: 2002-09-26 19:31:43

> From:
> Kresimir Fresl <fresl_at_[hidden]>
>> Therefore to get a pointer to the first element of matrix A use:
> Yes, ublas::unbounded_array<>::begin() returns
> ublas::unbounded_array<>::iterator (or const_iterator),
> which *happens* to be a pointer. (The same is true
> for ublas::bounded_array<>.)

> But, for other storage types this need not be true; e.g. storage
> type can be std::vector<> and its iterator can be `proper' class
> (and it is in gnu library).
> One can try
> &[0]
> OR
> &*

Hmm.. Interesting. I've given this a bit of thought before and concluded
that the .begin() is better. When used where a pointer is required, it
will ONLY compile if the iterator is a pointer. This is a good thing; it
almost certainly is not a good idea to use the linear memory after the
first entry unless this is true.
As you say all this only works if storage type has continuous storage.
To keep things simple I would simply define these two properties
(iterator==pointer, linear storage) as being equivilent!

>> I don't think it is possible at present to go the other way.
> Oh, it is. There is (undocumented) class array_adaptor<>
> (in storage.hpp):

Oops, you are right. I thought there was something like it in there. I
wonder why it is undocumented. Maybe it is only experimental?


Boost list run by bdawes at, gregod at, cpdaniel at, john at