Page MenuHome

Clenaup: Clang-Tidy modernize-use-equals-default
AbandonedPublic

Authored by Pablo Dobarro (pablodp606) on Nov 6 2020, 11:23 PM.

Diff Detail

Repository
rB Blender
Branch
clang-tidy-modernize-use-equals-default (branched from master)
Build Status
Buildable 11168
Build 11168: arc lint + arc unit

Event Timeline

Pablo Dobarro (pablodp606) requested review of this revision.Nov 6 2020, 11:23 PM
Pablo Dobarro (pablodp606) created this revision.

If Foo() = default; can be specified in the declaration (in the header file), then implementation would not be needed at all.
https://godbolt.org/z/ez68PM

Think the default implementation is to be provided in the header. Maybe even removed from derived classes, as this doesn't bring any value.
Although, lets hear @Jacques Lucke (JacquesLucke) here as well.

I agree with @Sergey Sharybin (sergey).
If the default constructor does all you need, either don't specify it at all, or default it in the header (sometimes you have to default it explicitly, e.g. when there is another constructor).
Generally, I don't explicitly default the constructor, because it does not add any information. Although, in some cases I do it, I don't have a rule for that yet.

Using = default; in the header has some benefits:

  • It's more clear to the reader that there is nothing special happening in the constructor.
  • If all the members are trivially constructible, the new type is also trivially constructible. This can improve performance, although probably not in the cases that are changed here. Some containers can be optimized when it is known that the contained type is trivial in some ways (e.g. can be copied with memcpy).

The same applies to the destructor and copy/move constructors/assignment operators as well.

@Pablo Dobarro (pablodp606), Hey! Do you think you'll have time to move = default the the header files whenever possible, so that we can apply this patch?

Closing this in favor of D10911.