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

Add QtContainer::usize(), returning size() unsigned

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Unresolved
    • Icon: Not Evaluated Not Evaluated
    • None
    • None
    • None
    • 19aa5da9b (dev), 01aabb5ee (tqtc/lts-6.5)

      The following code can produce a warning:

      QList<Bar> entries;
      
      std::vector<Foo> values;
      
      values.reserve(entries.size()); // warning
      

      You can silence the warning with:

      QList<Bar> entries;
      
      std::vector<Foo> values;
      
      values.reserve(static_cast<std::size_t>(entries.size())); // no warning but very verbose
      

      Adding usize() to Qt Container would improve the readability of the code:

      QList<Bar> entries;
      
      std::vector<Foo> values;
      
      values.reserve(entries.usize()); // warning
      

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

            thiago Thiago Macieira
            bubke Marco Bubke
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: