Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-104899

QML(_NAMED)_ELEMENT should generate a clear error if the type in not default constructible

XMLWordPrintable

    • 6bdeafcad (dev), 83697e49e (6.5)

      If a type is marked with QML_ELEMENT, but does not have a default ctor, it becomes uncreatable. Unless the type has been explicitly marked as such, that should create an actionable warning message, or even a compile time error.

       

      We might be able to get a compilation error by having the macro expand to 

      consteval void check() {
          using Self = std::remove_cvref_t<decltype(*this);
          static_assert(!std::is_default_constructible<Self>> || is_uncreatable<Self>);
      }
      

      However, we would need to evaluate the compile time overhead of such a solution, and potentially deal with shadowing warning.

        For Gerrit Dashboard: QTBUG-104899
        # Subject Branch Project Status CR V

            ulherman Ulf Hermann
            fabiankosmale Fabian Kosmale
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes