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

C++ example for asset3d_out_of_tree and related cleanup #3913

Merged
merged 2 commits into from
Oct 18, 2023

Conversation

Wumpf
Copy link
Member

@Wumpf Wumpf commented Oct 18, 2023

What

  • part of Implement missing code-examples for C++ #3751
  • use Result for from_file
  • move heavy impl to c++ (codegen TODO: need to not leak heavy headers into public; make putting headers in _ext opt-in!)
  • (unrelated) rolled back some local vscode cmake settings that weren't that great after all
image

Checklist

  • I have read and agree to Contributor Guide and the Code of Conduct
  • I've included a screenshot or gif (if applicable)
  • I have tested demo.rerun.io (if applicable)
  • The PR title and labels are set such as to maximize their usefulness for the next release's CHANGELOG

@Wumpf Wumpf added 🌊 C++ API C/C++ API specific exclude from changelog PRs with this won't show up in CHANGELOG.md labels Oct 18, 2023
@Wumpf Wumpf changed the title example for asset3d_out_of_tree and related cleanup C++ example for asset3d_out_of_tree and related cleanup Oct 18, 2023
@@ -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& {
Copy link
Member

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?

Copy link
Member Author

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() && {
Copy link
Member

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?

Copy link
Member Author

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

@Wumpf Wumpf merged commit 2b7baef into main Oct 18, 2023
@Wumpf Wumpf deleted the andreas/cpp/out-of-tree-transform branch October 18, 2023 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🌊 C++ API C/C++ API specific exclude from changelog PRs with this won't show up in CHANGELOG.md
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants