-
Notifications
You must be signed in to change notification settings - Fork 520
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
Move constructor is added to support dmlc::optional<T> #658
Move constructor is added to support dmlc::optional<T> #658
Conversation
29211ba
to
fe6c4ea
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. It would be nice to see if there is a performance boost thanks to supporting move here.
9367bcb
to
46ad95b
Compare
b5ea461
to
fce1d9f
Compare
@szha @mozga-intel Do you still want my review? |
@hcho3 If you can review it, I'll be grateful. Thanks! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. I will leave it open for a couple more days in case there's any concern before I merge.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No objection from me. Hopefully we can use std::optional
in the future.
@mozga-intel sounds good. Do you intend to continue in this PR or as a follow-up? |
@szha after merge! Because I need to test it before. |
not quite sure why yet, but it looks like when i apply this patch to TVM, the following command (in tvm repo, at rev c07a46327c86fc541297ebb985cc9c1dcef5a0db, using docker container tlcpack/ci-cpu:v0.84 and config.cmake generated with
still tracing through to see why, but posting up here in case any of you all have ideas. cc @tqchen |
optional(dmlc::nullopt_t) noexcept : is_none(true) {} // NOLINT(*) | ||
/*! \brief copy constructor, if other contains a value, then stored value is | ||
* direct-intialized with it. */ | ||
optional(const optional &other) = default; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
it seems that reverting the use of the default copy constructor here stops the segfault
Description
The class template std::optional manages an optional contained value, i.e. a value that may or may not be present. In this pull request, a few things were implemented, such as extended series of constructors and a function of value. Mainly, this pull request is a realization of changes that have an impact on constructors, as follows, (upgrade dmlc::optional constructors):
optional(optional &&other) noexcept() { }
other
parameter.optional(U &&other) noexcept { }
Upgrade: dmlc::optional value
1.
T &value() &
2.
const T &value() const &
3.
T &&value() &
4.
const T && value() const &&