Re: commit -- operator[] for UT_String


Subject: Re: commit -- operator[] for UT_String
From: Joaquín Cuenca Abela (cuenca@celium.net)
Date: Sun Apr 15 2001 - 18:11:02 CDT


"Michael D. Pritchett" wrote:
>
> From: Joaquín Cuenca Abela <cuenca@celium.net>
> Sent: Saturday, April 14, 2001 2:13 PM
>
> > operator[] and operator[] const for UT_String
> >
> > Cheers,
> >
> > --
> > Joaquín Cuenca Abela
> > cuenca@celium.net
> >
>
> Joaquin -
>
> MSVC 5.0 is having difficultly with this:
>
> char& UT_String::operator[](size_t iPos)
> {
> UT_ASSERT(iPos <= size());
> return pimpl->data()[iPos];
> }
>
> saying something about return cannot convert 'const char' to 'char &'.
> Substituting
>
> return (char) pimpl->data()[iPos];
>
> allows it to compile and continue, but I am not sure if this is what you
> wanted.

not, at all. (I'm not saying that this way it will not work, but a
const_cast<> is out of question.)
I added a

        char_type* data() { return m_psz; }

method to UT_Stringbuf. Can you please check that you have it?
If it's there, then MSVC 5.0 is broken here...

Cheers,

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



This archive was generated by hypermail 2b25 : Sun Apr 15 2001 - 18:11:09 CDT