opStar

Walter Bright newshound1 at digitalmars.com
Mon Nov 12 00:50:36 PST 2007


Janice Caron wrote:
> On Nov 12, 2007 2:17 AM, Walter Bright <newshound1 at digitalmars.com> wrote:
>> There are other ways to do smart pointers. I happen to strongly dislike
>> the C++ way of doing it.
> 
> Great! So do I!
> 
> Which leads me to wonder why you gave us opStar(), which seems to me
> to be /exactly/ the C++ way (except without the convenience of ->)

It's not for smart pointers. It's for iterators. To do an iterator, you 
need 4 operations:

1) copy
2) increment
3) compare for equality
4) get the value

The first 3 are already covered by operator overloading, so we need one 
for the last. You could do these through member functions, but then you 
couldn't use a pointer as an iterator.



More information about the Digitalmars-d mailing list