Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mds/Mutation.h: simplify constructors #11455

Merged
merged 1 commit into from Oct 20, 2016

Conversation

stiopaa1
Copy link
Contributor

Signed-off-by: Michal Jarzabek stiopa@gmail.com

Signed-off-by: Michal Jarzabek <stiopa@gmail.com>
@tchaikov tchaikov added cephfs Ceph File System cleanup labels Oct 13, 2016
dzafman pushed a commit that referenced this pull request Oct 13, 2016
Fixes: #11455
When dealing with old manifest that has explicit objs, we also
need to set the head size and head object correctly so that
code that relies on this info doesn't break.

Signed-off-by: Yehuda Sadeh <yehuda@redhat.com>
(cherry picked from commit d7bf8cb)
@gregsfortytwo
Copy link
Member

Hmm. I guess I know you can do this in some cases and I'm guessing recent C++ revisions have added more. But I don't know the rules; is there a benefit beyond Don't Repeat Yourself? Is there a cost?

@stiopaa1
Copy link
Contributor Author

stiopaa1 commented Oct 15, 2016

@gregsfortytwo
Advantages would be as you mentioned no code duplication and then in case you ever wanted to add additional constructors in the future, there is no way to leave those member uninitialised even if you forget to initialise them.
There is no additional cost: (http://en.cppreference.com/w/cpp/language/initializer_list)

If a non-static data member has an default member initializer and also appears in a member initializer list, then member initializer list is executed and the default member initializer is ignored:

struct S {
    int n = 42;   // default member initializer
    S() : n(7) {} // will set n to 7, not 42
};

(since C++11)

The only surprising effect it has in C++11 is that it makes a class a not an aggregate. More information about it here:
http://stackoverflow.com/questions/27118535/c11-aggregate-initialization-for-classes-with-non-static-member-initializers

@gregsfortytwo
Copy link
Member

LGTM

@jcsp jcsp merged commit 6345036 into ceph:master Oct 20, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants