:? ??

Allan Sandfeld Jensen snowwolf@one2one-networks.com
Tue Mar 19 14:53:00 GMT 2002


On Tuesday 19 March 2002 19:17, Joe Buck wrote:
> > On Tue, 19 Mar 2002, Joe Buck wrote:
> > > > Is it doing:
> > > >   (exp) ? QString("xyz") : a
> > > > or
> > > >   QString(exp ? "xyz" : (const char*)a);
> > >
> > > Does QString define an operator const char*() ?
> >
> > Under certain circumstances.  In "strict" mode it doesn't.
It does unless QT_NO_ASCII_CAST flag is set, in fact no part of kde would 
compile with this flag since at least the implicit constructor from const 
char* is too widely used.

> If there is both an operator const char*() and a constructor that takes
> a const char* argument that is not marked explicit, then
>
> 	QString qstring_var;
> 	...
> 	QString fred = cond ? "foo" : qstring_var;
>
> is ambiguous, otherwise not.

Well in that case it is ambiguous, they are both defined. Plus operator=, 
the full monty :)
( I didnt know about the explicit mark, but they dont use it anyway )

Sun's compiler might be a little too touchy about type-casting, but in this 
case it is right.  

I have never seen any warnings from gcc, so it should be a problem in 2.95, 
3.0 and 3.1.

`Allan



More information about the Gcc mailing list