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

Example in QSharedDataPointer should be modernized

    XMLWordPrintable

Details

    • Suggestion
    • Resolution: Unresolved
    • Not Evaluated
    • None
    • 6.4.2
    • Documentation
    • None
    • All

    Description

      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.

      Attachments

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

        Activity

          People

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

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes