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
I have a function at C++ side, which is template function
template<classF> voidfoo(F&& handler);
which accepts everything suitable to my Handler concept. For instance, F type must have operator() and cancel() member functions. I also have some predefined classes implementing Handler concept. Lets call them x_handler, y_handler, and z_handler. All of them are wrapped using pybind11 for Python side.
I would like to wrap foo function for Python side. I need the following two use-cases supported simultaneously:
Python user call the function with predefined handler class:
h=XHandler(args)
foo(h)
In this case I want not to have double wrapping (C++ -> Python -> C++), yet I understand that I would still need some any_handler type erasure wrapper to kill the template type in order to expose the function via pybind11.
Python user calls the function with its own Python handler class:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Hello,
I have a function at C++ side, which is template function
which accepts everything suitable to my Handler concept. For instance, F type must have
operator()
andcancel()
member functions. I also have some predefined classes implementing Handler concept. Lets call themx_handler
,y_handler
, andz_handler
. All of them are wrapped usingpybind11
for Python side.I would like to wrap
foo
function for Python side. I need the following two use-cases supported simultaneously:any_handler
type erasure wrapper to kill the template type in order to expose the function via pybind11.Beta Was this translation helpful? Give feedback.
All reactions