Operator overloading

Jarrett Billingsley jarrett.billingsley at gmail.com
Sat Dec 27 11:19:28 PST 2008


On Sat, Dec 27, 2008 at 11:10 AM, Bill Baxter <wbaxter at gmail.com> wrote:
>> I got the impression from your argument that you thought that without
>> an appropriate method of overloading the increment operator, it's not
>> possible to duplicate the _syntax_ of STL-style iterators.  My
>> response is - who cares?  I don't think of iterators as "pointers that
>> can be incremented," and I doubt anyone who doesn't have a C++
>> background thinks of them that way either.  It seems that the
>> semantics of STL iterators can be implemented with methods just as
>> well.
>
> There is a little something nice about being able to use a pointer and
> iterator interchangeably for templated container algorithms.  You lose
> that if ++iter can't be used to iterate your iterator.

Except that in D, you rarely use pointers, and ++ isn't defined on
arrays.  So you lose a lot of the unity that the syntax affords you in
C++.



More information about the Digitalmars-d mailing list