[Development] C++11 decltype magic with a container?

Stephen Kelly stephen.kelly at kdab.com
Wed May 22 19:34:49 CEST 2013


On Wednesday, May 22, 2013 08:15:59 Thiago Macieira wrote:
> On quarta-feira, 22 de maio de 2013 17.04.21, Stephen Kelly wrote:
> > > In other words, QPair has an operator==, but it can't be used because it
> > > won't compile. Your code detects that it exists, but can't be sure that
> > > it
> > > works?
> > 
> > Correct. The compiler sees that operator==() exists, but it doesn't look
> > into the implementation to see that it contains t1 == other.t1, and
> > therefore it doesn't check if T1::operator==() exists.
> 
> The operator exists and there's nothing preventing it from existing. The
> problem is that the operator exists but can't be used.

Yes.

> > > You need to modify all operator== in classes with templates to make sure
> > > they are enable_if for the case where its template(s) is(are)
> > > comparable.
> > 
> > See my initial email. Now that we've stepped back it might make more sense
> > to you.
> 
> It does. You need to make sure that there's an enable_if in the function
> you're trying to detect. You can't detect if the function compiles.

Sorry, I don't see how that suggestion is different from the code I posted in 
my initial mail.

Maybe you could change the code in my initial mail to show what you mean.

Thanks,

-- 
Stephen Kelly <stephen.kelly at kdab.com> | Software Engineer
KDAB (Deutschland) GmbH & Co.KG, a KDAB Group Company
www.kdab.com || Germany +49-30-521325470 || Sweden (HQ) +46-563-540090
KDAB - Qt Experts - Platform-Independent Software Solutions
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 198 bytes
Desc: This is a digitally signed message part.
URL: <http://lists.qt-project.org/pipermail/development/attachments/20130522/a835afd3/attachment.sig>


More information about the Development mailing list