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

    Details

      Description

      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.

        Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

            Assignee:
            qtqmlteam Qt Qml Team User
            Reporter:
            fabiankosmale Fabian Kosmale
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes