C++ Reflection and Qt MOC

wiki.qt.io

77 points by coffeeaddict1 4 days ago


ogoffart - 4 hours ago

10 years ago, in another life, I was already experimenting with trying to provides feature from moc with reflections and from other macros:

- https://woboq.com/blog/reflection-in-cpp-and-qt-moc.html 2014, That was based on a previous reflection proposal

- https://github.com/woboq/verdigris : 2016, Replaces the moc by a set of macros.

What my verdigris experience shows is that it is perfectly possible to replace the moc at the cost of slightly uglier macros. And this was using C++14. I haven't look in details at the C++26 reflection, but I'm sure it would make it easier to make these macro more pretty.

pjmlp - 10 hours ago

Even if C++26 covers all scenarios needed for MOC, it is going to take ages until Qt can rely on it being available across all their customer platforms, unfortunely after a spike in the last decades regarding ISO C++ support, the compilers velocity has slowed down, while proprietary compilers have decided to freeze their support somewhere between C++14 and C++17.

Most likely the raise of AOT compiled alternatives, for scenarios where C and C++ were only being used due to being compiled languages, big names in C++ compiler world rather put money on their own alternatives, are the two main reasons of the slow down.

- https://en.cppreference.com/w/cpp/compiler_support.html

- https://en.cppreference.com/w/cpp/compiler_support/17.html

- https://en.cppreference.com/w/cpp/compiler_support/14.html

rixed - 7 hours ago

Meanwhile, copperspice got rid of the MOC more than 10 years ago.

I'm no longer familiar with Qt nor C++, but I guess the real blocker here is that the Qt foundation is only looking for ways that are 100% backward-compatible to inccur no change in its commercial userbase? Or am I missing something more subtle?

5- - 7 hours ago

related: https://www.copperspice.com/

Kelteseth - 10 hours ago

Related issue https://bugreports.qt.io/browse/QTBUG-140912

bluGill - 9 hours ago

Moc is complex. reflection is complex. round one was trying to be as simple as possible while still allowing some real world use and allow room for the future.

- 10 hours ago
[deleted]
waynecochran - 7 hours ago

Moc?

z3ratul163071 - 5 hours ago

"Reflection in C++26 might be insufficient for replacing moc."

C++ is such a dinosaur, that even after all these years the reflection that was lacking and was introduced is still unusable.