-
Hi all, I'm in an odd situation where I have the I imagine this is possible with existing machinery, but I'm having trouble figuring out how! I'd greatly appreciate any help :D I've gotten as far as the following: nanobind::object cast_value(
const std::type_info* type_info,
void* address,
nanobind::rv_policy policy = nanobind::rv_policy::copy
)
{
nanobind::handle handle = nanobind::detail::nb_type_put(type_info, address, policy, nullptr);
if (!handle.is_valid())
{
nanobind::detail::raise_cast_error();
}
return nanobind::steal(handle);
} When provided with the Followup: it seems like at the time of casting, Followup: oh, I guess |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 1 reply
-
If it's primitive types, your best bet will be to iterate through all of the possibilities, |
Beta Was this translation helpful? Give feedback.
If it's primitive types, your best bet will be to iterate through all of the possibilities,
static_cast
in C++, and then callnb::cast
. The nanobind data structures would only be helpful for types exposed using bindings (i.e. vianb::class_<T>
), which isn't even possible forint
etc.