Re: UT_String


Subject: Re: UT_String
From: Joaquín Cuenca Abela (cuenca@celium.net)
Date: Sat Apr 14 2001 - 17:45:12 CDT


Mike Nordell wrote:
>
> 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.

I will explain this one.
I did a commit with some add-ons to UT_String, but I was so stupid to
not even verify that it compiled (in fact I *forget* to compile, I just
realized that I commited without compiling with dom said it at irc).
Dom kindly fixed the compilation, but
char& operator[](size_t)

is not more exactly the same thing that I had in my head.

I wanted something like:

char& UT_String::operator[](size_t iPos)
{
        UT_ASSERT(iPos <= size());
        return pimpl->data()[iPos];
}

and in UT_Stringbuf to add something like

char_type* UT_Stringbuf::data()
{
        return m_psz;
}

of course, in its current state, the function is useless.
If nobody disagrees, I will change the current implementation by this
one.

Sorry for committing without compiling.

(now, Mike, if you still think that char& operator[] with the
implementation that I explain in this email is broken, a hack, etc. we
can start a discussion)

Cheers,

--
Joaquín Cuenca Abela
cuenca@celium.net



This archive was generated by hypermail 2b25 : Sat Apr 14 2001 - 17:45:17 CDT