generic classes for safe %macro substitution

Harri Porten porten at kde.org
Thu Jan 2 12:21:45 GMT 2003


On Thu, 2 Jan 2003, Oswald Buddenhagen wrote:

> have you looked at the code generated for returning temporaries? things
> would look different if gcc realized that a qstring is actually only a
> pointer, but it does not ...

QString _is_ a bit more than a pointer because of the copy ctor and
assignment operator.

> > Even your kmxtest.cpp program contains extra copy statements because
> > of this :)
> > 
> it would need some either way ...

My point was that the saving of variables isn't any argument anymore then.

> > These functions can all be "const", can't they ?
> > 
> if i knew exactly what the keyword means, i could decide ... :}

It's somewhat of a promise that calling this function won't modify "this" 
object. Whether that is actually true is a different matter but it's vital
for the semantics.

> >     bool isIdentifier(uint c) { return c == '_' || (c >= 'A' && c <= 'Z')
> > || (c >= 'a' && c <= 'z') || (c >= '0' && c <= '9'); }
> > };
> > 
> > "const" :)
> > 
> whatever. the function is inline, so i doubt we can tell the compiler
> more than it can find out by itself. otoh, g++ already surprised me with
> its stupidity.

It's not so much an issue of optimization but the ability to call a
function on a const object. One easily notices when trying to call a
non-const function from a const function :) In this case I should have
rather suggested to make this function static btw.

Harri.





More information about the kde-core-devel mailing list