Uploaded image for project: '1D Redmine '
  1. 1D Redmine
  2. REDMINE1D-25

[RM-6371] [wiki] Check and Apply "Rule of zero" or else "Rule of the 5 defaults", to possibly all classes in the library

    XMLWordPrintable

    Details

    • Type: Task
    • Status: Done (View Workflow)
    • Priority: Normal
    • Resolution: Done
    • Labels:
      None

      Description

      Created on 2021-03-15 13:11:55 by Mira Sarkis. % Done: 100

      Motivations for this action (based on https://www.fluentcpp.com/2019/04/23/the-rule-of-zero-zero-constructor-zero-calorie/):
      Among the new practices in C++11 appears the Rule of 5 vs Rule of zero

      • "Rule of 5" states that if any of the "Big Five" (i.e., the copy/move constructors, copy/move assignment operators or destructor) has a user-defined implementation, we should obligatory define the implementation of the remaining "Big Fives" .
        This is important because otherwise we will have to deal with some side effects notably on the generation of the move operations. In most of the cases move operations are replaced by copy operations (which are far more expensive than the former).
        This applies also when setting to 'default' at least one of the "Big Fives" and the rest non-default
      • "Rule of 5 default ", always declare the 5 resource-management functions. And if they are trivial, use @= default@. This avoid, for instance, the non implicit generation of the 2 move functions, without the need to explicit their definitions.
      • "Rule of zero": do not define any of the "Big Five".

      Conclusion and rules to check their correct usage in the library:

      • stick to rule of zero if there is no need for user-defined implementation
      • if one of the Big Five should be user-defined, then explicitly default the rest

        Attachments

          Activity

            People

            • Assignee:
              r2j.migrate Redmine-Jira Migtation
              Reporter:
              r2j.migrate Redmine-Jira Migtation
            • Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: