You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[embind] Fix misindexed template parameters which prevented policies from being applied to class functions or constructors (#24053)
Hi, trying to `allow_raw_pointers()` in a class method bound with embind
when a custom signature was given as a template argument to
`.class_function` failed. It's easy to see why by comparing the
definition of either `RegisterClassMethod` or `RegisterClassConstructor`
with their usage:
```cpp
template<typename ReturnType, typename ThisType, typename... Args>
struct RegisterClassMethod<ReturnType (ThisType, Args...)> {
template <typename ClassType, typename Callable, typename... Policies>
static void invoke(const char* methodName,
...
```
and its invocation in `class_function`:
```cpp
using invoker = internal::RegisterClassConstructor<
typename std::conditional<std::is_same<Signature, internal::DeduceArgumentsTag>::value,
Callable,
Signature>::type>;
invoker::template invoke<ClassType, Policies...>(callable);
```
which will skip the `Callable` template argument in some specializations
(and `Callable` will become the return value policy). To fix this, I
used the same approach used by the getters/setter `PropertyTag`s (c.f.
diff). Please let me know if anything is off.
0 commit comments