On Mon, 2006-12-04 at 23:10 -0800, Erick Tryzelaar wrote:
> So I was looking through your implementation of the felix STL wrapper, 
> and I wanted to see if I could implement the new iterator concepts from 
> boost:
> 
> http://www.boost.org/libs/iterator/doc/new-iter-concepts.html
> 
> I ran into a couple issues though. The spec says that readable iterators 
> should reference should deref into the element type (eg: "fun deref: it 
> -> t") and lvalue iterators should deref into a reference of the element 
> type ("fun deref: it -> lvalue[t]").

Obvious crap. Lvalueness of an iterator only affects whether it
can be ++ incremented or not.

An iterator which when dereferenced returns an lvalue is a different
type to an iterator which when dereferenced returns merely an rvalue.

In addition in C++ a const lvalue is distinct from a non-const one.

To make matters worse, am STL map has a value which is a struct
type with one const and one non-const element.

> difference_type. Since we can't yet embed a type in a typeclass, I'm not 
> sure how to model this. 

Yes, at the moment the best you can do is add it as a parameter
to the typeclass.

> // value access
> 
> typeclass Readable_iterator[it,t] {
>   virtual fun deref: it -> t;
> }
> 
> typeclass Writable_iterator[it,t] {
>   virtual proc store: &it -> t;
> }

This is just wrong, the correct signature is

        virtual proc store: it * t;

Whether or not a particular iterator supports storing
will determine whether to instantiate it under this
typeclass.

> typeclass Swappable_iterator[it,t] {
>   virtual proc iter_swap: &it -> ⁢
> }

Not sure I understand this: iterators are always swappable.
Whether the value they point at are swappable depends on whether
the iterator types are Writable_iterator's (in your classification).
You can always implement swap using a temporary in that case ..
so swap method should probably be added to Writable_iterator,
in case there is a more efficient way to do it.


-- 
John Skaller <skaller at users dot sf dot net>
Felix, successor to C++: http://felix.sf.net

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your
opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Felix-language mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/felix-language

Reply via email to