-
Notifications
You must be signed in to change notification settings - Fork 409
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
C++ example for asset3d_out_of_tree and related cleanup #3913
Conversation
@@ -47,10 +47,16 @@ namespace rerun { | |||
|
|||
#ifdef __cpp_exceptions | |||
/// Returns the value if status is ok, throws otherwise. | |||
T value_or_throw() const { | |||
const T& value_or_throw() const& { |
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.
wait, what does the extra &
after const&
do?
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.
since we do rvalue ref qualifier for an overload we explicitly need to make the non rvalue one distinct. This is done like so
error.throw_on_failure(); | ||
return value; | ||
} | ||
|
||
/// Returns the value if status is ok, throws otherwise. | ||
T value_or_throw() && { |
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.
Whoa, I didn't know C++ had this - is this still C++17? Do you have a link about this?
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's actually C++11 :)
Check
Member functions with ref-qualifier
on this page https://en.cppreference.com/w/cpp/language/member_functions
What
Checklist