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

QSpan<const T> causes Qt container to detach

    XMLWordPrintable

Details

    • All
    • 2
    • 05b9a4b2d (dev), aff082764 (6.9), cad7935b6 (6.8), 287234704 (dev), cddddd753 (6.9)
    • Foundation Sprint 122, Foundation Sprint 123

    Description

      I know that std::as_const can be used; nevertheless, I would not expect QSpan<const T> to cause a Qt container to detach.
      If this behavior is considered "normal," it should be mentioned and highlighted in the Qt documentation, as, IMHO, the current behavior does not align with the "Principle of Least Astonishment" for a Qt developer.

      void
      foo(QSpan<const int>)
      {
      }
      
      void main()
      {
      	QList<int> list{0, 1, 2};
      	QList<int> list2{list};
      
      	qDebug() << list2.isDetached();   // false
      	foo(list2);
      	qDebug() << list2.isDetached();   // true
      }
      

      Attachments

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

        Activity

          People

            mmutz Marc Mutz
            philippe philippe
            Vladimir Minenko Vladimir Minenko
            Alex Blasche Alex Blasche
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews