# Reading and Loading RNTuple Fields with Run-Time Determined Types

**URL:** <https://root-forum.cern.ch/t/reading-and-loading-rntuple-fields-with-run-time-determined-types/63765>\
**Category:** Newbie\
**Tags:** root\
**Created:** [June 19, 2025, 3:00pm UTC](https://root-forum.cern.ch/t/reading-and-loading-rntuple-fields-with-run-time-determined-types/63765 "2025-06-19T15:00:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Oswaldo\_Cardenas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/oswaldo_cardenas/32/39039_2.png) [@Oswaldo\_Cardenas](https://root-forum.cern.ch/u/Oswaldo_Cardenas)\
**Post date:** [June 19, 2025, 3:00pm UTC](https://root-forum.cern.ch/t/reading-and-loading-rntuple-fields-with-run-time-determined-types/63765/1 "2025-06-19T15:00:37Z")

</div>

Hello,

I am currently working on a project that requires me to iterate over multiple fields and graph the contents of each field.

Currently, I am trying to establish a pointer to its data entry and loading it from that, however I see that it needs a specified type when establishing said pointer.

Is there a command that would allow me to create a field pointer without the need of specifying the type of the field?

The code I have currently looks like

```auto
  auto ntuple = ROOT::Experimental::RNTupleReader::Open(rntupleName,newfileName);

  for (const auto &value : ntuple->GetModel().GetDefaultEntry()){
    auto entryPtr = value.GetPtr() 
  };

```

_ROOT Version:_ 6.34.04  
_Platform:_ Not Provided  
_Compiler:_ Not Provided

* * *

---

<div class="post-metadata">

**Author:** ![Danilo](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/danilo/32/34528_2.png) [@Danilo](https://root-forum.cern.ch/u/Danilo)\
**Post date:** [June 19, 2025, 4:10pm UTC](https://root-forum.cern.ch/t/reading-and-loading-rntuple-fields-with-run-time-determined-types/63765/2 "2025-06-19T16:10:08Z")

</div>

Hi Oswaldo,

I am sure @silverweed will have an answer.

Cheers,  
D

---

<div class="post-metadata">

**Author:** ![jblomer](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/j/439d5e/32.png) [@jblomer](https://root-forum.cern.ch/u/jblomer)\
**Post date:** [June 19, 2025, 8:38pm UTC](https://root-forum.cern.ch/t/reading-and-loading-rntuple-fields-with-run-time-determined-types/63765/3 "2025-06-19T20:38:33Z")

</div>

You can use `value.GetPtr<void>()`. Note that this also implies that you leave the type-safe land.

Depending on your use case, you can consider instead to use `RNTupleReader::GetView(std::string_view fieldName, void *rawPtr, std::string_view typeName)`, which gives you runtime type checks.

---

<div class="post-metadata">

**Author:** ![Oswaldo\_Cardenas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/oswaldo_cardenas/32/39039_2.png) [@Oswaldo\_Cardenas](https://root-forum.cern.ch/u/Oswaldo_Cardenas)\
**Post date:** [June 19, 2025, 10:17pm UTC](https://root-forum.cern.ch/t/reading-and-loading-rntuple-fields-with-run-time-determined-types/63765/4 "2025-06-19T22:17:13Z")

</div>

For `value.GetPtr<void>() `, I seem to be getting the error

```auto
 indirection requires pointer operand ('std::shared_ptr<void>' invalid)

```

Is it not possible to dereference a `std::shared_ptr<void> ` ? In my case, I want to be able to use the data associated with each field.

---

<div class="post-metadata">

**Author:** ![silverweed](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/silverweed/32/36670_2.png) [@silverweed](https://root-forum.cern.ch/u/silverweed)\
**Post date:** [June 20, 2025, 7:36am UTC](https://root-forum.cern.ch/t/reading-and-loading-rntuple-fields-with-run-time-determined-types/63765/5 "2025-06-20T07:36:36Z")

</div>

> In my case, I want to be able to use the data associated with each field.

In this case you should at some point in your program know the type of the data you’re operating on, so you can cast the pointer to the appropriate type. Otherwise all you can really do is memcpy’ing the data around.

---

<div class="post-metadata">

**Author:** ![Oswaldo\_Cardenas](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/oswaldo_cardenas/32/39039_2.png) [@Oswaldo\_Cardenas](https://root-forum.cern.ch/u/Oswaldo_Cardenas)\
**Post date:** [June 20, 2025, 4:35pm UTC](https://root-forum.cern.ch/t/reading-and-loading-rntuple-fields-with-run-time-determined-types/63765/6 "2025-06-20T16:35:34Z")

</div>

I see, I might try to figure out a clean way to do this. Thank you!
