[Qt-interest] Advices on safer SIGNAL macro
Thiago Macieira
thiago at kde.org
Wed Oct 19 22:26:57 CEST 2011
On Wednesday, 19 de October de 2011 21:47:18 Johannes Schaub wrote:
> namespace static_signal_detail {
> template<typename>
> struct take { };
> }
>
> #define STATIC_SIGNAL(SIG) (static_signal_detail::take<void(void SIG)>(), \
> SIGNAL(SIG))
It's an interesting technique. It will verify that the types exist. However,
it will not complain about:
connect(this, SIGNAL(changed(int id)), SLOT(executeAction()));
The compiler will find nothing wrong with the presence of the name of the
parameter, but QObject::connect will.
It will also not complain in your case:
> connect(pages, SIGNAL(changed(Ptr)), SLOT(update(Ptr)));
If Ptr is a local type.
The Qt 5 solution is more powerful and will check all cases.
--
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
Software Architect - Intel Open Source Technology Center
PGP/GPG: 0x6EF45358; fingerprint:
E067 918B B660 DBD1 105C 966C 33F5 F005 6EF4 5358
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 190 bytes
Desc: This is a digitally signed message part.
Url : http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20111019/a170ddc8/attachment.bin
More information about the Qt-interest-old
mailing list