Skip to content

[ntuple] RValue::GetRef<T> should type-check #18316

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

Open
hahnjo opened this issue Apr 8, 2025 · 0 comments
Open

[ntuple] RValue::GetRef<T> should type-check #18316

hahnjo opened this issue Apr 8, 2025 · 0 comments
Assignees

Comments

@hahnjo
Copy link
Member

hahnjo commented Apr 8, 2025

Using RNTupleView<void>, it is possible to write the following code:

#include <ROOT/RNTupleModel.hxx>
#include <ROOT/RNTupleReader.hxx>
#include <ROOT/RNTupleWriter.hxx>
#include <ROOT/RNTupleView.hxx>

#include <iostream>

void ntuple_view_void() {
  {
    auto model = ROOT::RNTupleModel::Create();
    *model->MakeField<float>("px") = 42.0f;
    auto writer = ROOT::RNTupleWriter::Recreate(std::move(model), "ntpl", "void.root");
    writer->Fill();
  }

  auto reader = ROOT::RNTupleReader::Open("ntpl", "void.root");
  auto view = reader->GetView<void>("px");
  view(0);
  auto value = view.GetValue().GetRef<double>();
  std::cout << "value = " << value << "\n";
}

This should throw when trying to get a double reference to a float object.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants