[Development] constexpr construct QObject?

achartier at fastmail.fm achartier at fastmail.fm
Sun Sep 1 04:23:11 CEST 2013


Hi all,

I'm wondering if QObject could be made to be constexpr constructable. I
haven't taken a look at the QObject source code, so it may not be
possible given the types of operations that need to be performed when
constructing a QObject, but I thought I'd ask anyway. I have seen some
cases in our team's code where we have potentially hundreds of objects
that need to be constructed. The initial data for these classes is known
at compile-time and it would be really nice to be able to constexpr
construct these objects to avoid the run-time object instantiation
overhead. At the same time, it's desirable for these same objects to
derive from QObject to make use of signals/slots, properties, Qt
parent-child memory management, etc. as well. Hence, my original
question of whether QObject could be made constexpr constructable. :)

Has anyone already looked into this? Is it even possible?

Thanks!



More information about the Development mailing list