Skip to content

Commit

Permalink
strip const-ness of pointers before wrapping in cpp::Pointer for dynamic
Browse files Browse the repository at this point in the history
  • Loading branch information
Aidan Lee committed Feb 9, 2025
1 parent 28e9aee commit 4625a2a
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion include/hx/Invoker.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,9 @@ namespace hx
template< class T >
using remove_pointer_t = typename std::remove_pointer<T>::type;

template< class T >
using remove_const_t = typename std::remove_const<T>::type;

namespace unwrap
{
template<typename T>
Expand Down Expand Up @@ -106,11 +109,23 @@ namespace hx
}

template<typename T>
Dynamic __hx_object_pointer(T value, std::false_type)
Dynamic __hx_object_pointer_strip_const(T value, std::false_type)
{
return Dynamic(cpp::Pointer<remove_pointer_t<T>>(value));
}

template<typename T>
Dynamic __hx_object_pointer_strip_const(T value, std::true_type)
{
return Dynamic(cpp::Pointer<remove_const_t<remove_pointer_t<T>>>(value));
}

template<typename T>
Dynamic __hx_object_pointer(T value, std::false_type)
{
return __hx_object_pointer_strip_const(value, std::is_const<remove_pointer_t<T>>{});
}

template<typename T>
Dynamic __hx_pointer(T value, std::true_type)
{
Expand Down

0 comments on commit 4625a2a

Please sign in to comment.