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

Example in QSharedDataPointer should be modernized

XMLWordPrintable

    • Icon: Suggestion Suggestion
    • Resolution: Fixed
    • Icon: Not Evaluated Not Evaluated
    • 6.11.0 FF
    • 6.4.2
    • Documentation
    • None
    • All
    • b52c0dafd (dev)

      Instead of

          Employee(const Employee &other)
                : d (other.d)
          {
          } 

      I would recommend using

          Employee(const Employee &other) = default;

      And I would also add

      Employee& operator=(const Employee& other) = default;

      ...since copy constructor and copy assignment operator should come in pairs.

      I agree that the latter isn't strictly necessary for a working QSharedDataPointer example, but people learn from these examples and will use these approaches in their own code.

      Whether or not to add defaulted move constructor and move assignment operator is up to debate....according to the rule of 6, it should be added, but it might be confusing.

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

            docteam Qt Documentation Team
            asperamanca Robert Schimkowitsch
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes