lundi 3 juillet 2017

Get a function reference with decltype(this)

I'm trying to create a macro that will install and remove a Qt event filter constructed from a lambda. In this case, this is known to be a QObject, and thus has a member destroyed. filter is just some QObject-derived event filter. However I have a problem with the line:

connect(this, &decltype(this)::destroyed, [filter]() 
{ 
    qApp->removeEventFilter(filter); 
    filter->deleteLater();
});

which gives the (MSVC2013) error:

left of '::' must be a class, struct or union

Am I just getting the syntax wrong, or can I not do this?

Aucun commentaire:

Enregistrer un commentaire