UT_String


Subject: UT_String
From: Mike Nordell (tamlin@algonet.se)
Date: Sat Apr 14 2001 - 16:53:59 CDT


I just noticed another wierd thing added to the UT_String class.

It has been added a function
char& UT_String::operator[](size_t iPos);

This one doesn't follow the pattern of normal mutator functions. Indeed, I
agree with the comment:
  // hack, evil, why does this function exist?

I wonder too, since it's both useless and wrong.

Everywhere a container returns a non-const ref to anything from that
containers operator[], you expect to get a writable copy to that element.
Think of how a plain char array works and follow that pattern. Good or bad
is a matter of discussion, but this one just doesn't follow the rules.

Rather than just fixing it quietly (someone must have added it for a reason,
or?), I felt it appropriate to take a moment putting on the teachers hat.
:-)

/Mike



This archive was generated by hypermail 2b25 : Sat Apr 14 2001 - 16:53:16 CDT