Re: BZDEV: Indirection

From: Todd Veldhuizen (tveldhui@oonumerics.org)
Date: Fri Jul 31 1998 - 08:35:40 EST


> - In the current design, an index set is contained in an STL
> - container [...]
>
> - A[I] = B;
>
> Something like A[I.begin(), I.end()] = B would actually be
> more STL-ish. I'm assuming the operator[] has a definition
> something like
> template <typename _Cont>
> out_type
> Array::operator[] (const _Cont& c)
> If you were to change it to something like
> template <typename _Iter>
> out_type
> Array::operator[] (const _Iter first, const _Iter last)
> you could use the indirection with plain old pointers and
> C-style arrays. You'd have to pull some traits-tricks
> to keep the latter from being called when you do things
> like A[1, 2], though.

This is a good idea. I think the A[I] syntax is cleaner,
so I'll keep it, but I can also add a begin/end style for
people who want to use a subset of a container. We'll
have to devise a different syntax for begin/end because []
can't take multiple arguments. And () is already overloaded
to the wazoo for arrays.

> The STL style gets cumbersome to write, but it does give some
> extra flexibility. I find the ability to initialize from a plain
> C array (or a block of memory I treat that way) terribly useful.
> The block of memory could be wrapped in an object, but that isn't
> really necessary when I'm just feeding data from a chunk of C into
> an object. (I've forgotten if you already have a memory-wrapping
> object in there.)

Yes, you can do this with Array objects.

> Query: What are your assumptions about the iterator types
> involved? Do you use them as just forward iterators (non-input
> for the indexSex), as bidirectional iterators, etc?

Just as forward iterators.

Cheers,
Todd
--------------------- blitz-dev list --------------------------------
* To subscribe/unsubscribe: mail to majordomo@oonumerics.org, with
"subscribe blitz-dev" or "unsubscribe blitz-dev" in the body of the message
* Blitz++ web page: http://oonumerics.org/blitz/



This archive was generated by hypermail 2b29 : Wed Feb 20 2002 - 04:30:06 EST