hipo::get
template always returns double
auto px = particleBank.get("px", row); // type is `double`, even though px is `float` in the schema
auto px = particleBank.get<float>("px", row); // still appears to be a `double`
This is because the default type in template<typename T = double> T get
is set to double
, to give the compiler a "default", but that's not the correct thing to do here. We need to fix the type deduction here, but the types are stored in hipo::Type
, an enumerator:
https://github.com/gavalian/hipo/blob/9122a657f09c664a9f9d5615072959d317e7ed41/hipo4/dictionary.h#L36-L43
I tried something based on https://stackoverflow.com/a/58622942 but I was unsuccessful, since I need bankSchema
in the trailing return type (to lookup the type), but bankSchema
is not static; I was also not successful simply declaring bankSchema
as static, since parameter item
seems to not be accessible in the trailing return type.
After a few hours trying to resolve this, it's time to ask ChatGPT
Alternatively, give up and remove these templated get
methods (whereas the templated put
seems to work fine, since the type is deduced by the parameter type).