Skip to content

Commit 437afad

Browse files
committed
[ntuple] fix type check in REntry::BindRawPtr()
The BindRawPtr() overload receiving a field name mistakenly disabled the type check.
1 parent f82906a commit 437afad

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

tree/ntuple/inc/ROOT/REntry.hxx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ public:
215215
template <typename T>
216216
void BindRawPtr(std::string_view fieldName, T *rawPtr)
217217
{
218-
BindRawPtr<void>(GetToken(fieldName), rawPtr);
218+
BindRawPtr<T>(GetToken(fieldName), rawPtr);
219219
}
220220

221221
/// Get the (typed) pointer to the value for the field referenced by `token`.

tree/ntuple/test/ntuple_basics.cxx

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -817,6 +817,12 @@ TEST(REntry, Basics)
817817
EXPECT_EQ("float", e->GetTypeName("pt"));
818818
EXPECT_EQ("float", e->GetTypeName(model->GetToken("pt")));
819819

820+
float rawPt;
821+
double wrongType;
822+
e->BindRawPtr("pt", &rawPt);
823+
EXPECT_EQ(&rawPt, e->GetPtr<float>("pt").get());
824+
EXPECT_THROW(e->BindRawPtr("pt", &wrongType), ROOT::RException);
825+
820826
auto ptrPt = std::make_shared<float>();
821827
e->BindValue("pt", ptrPt);
822828
EXPECT_EQ(ptrPt.get(), e->GetPtr<float>("pt").get());

0 commit comments

Comments
 (0)