4 #include <pybind11/pybind11.h> 7 #include <pybind11/stl.h> 10 #ifndef BINDER_PYBIND11_TYPE_CASTER 11 #define BINDER_PYBIND11_TYPE_CASTER 19 using std::exception::exception;
21 const char *
what() const noexcept
override {
22 pybind11::gil_scoped_acquire gil;
23 pybind11::function overload = pybind11::get_overload(static_cast<const std::exception *>(
this),
"what");
25 auto o = overload.operator()<pybind11::return_value_policy::reference>();
26 if (pybind11::detail::cast_is_temporary_value_reference<const char *>::value) {
27 static pybind11::detail::overload_caster_t<const char *> caster;
28 return pybind11::detail::cast_ref<const char *>(std::move(o), caster);
30 else return pybind11::detail::cast_safe<const char *>(std::move(o));
32 return exception::what();
39 pybind11::class_<std::exception, std::shared_ptr<std::exception>,
PyCallBack_std_exception> cl(M(
"std"),
"exception",
"");
42 cl.def( pybind11::init( [](std::exception
const &o){
return new std::exception(o); } ) );
43 cl.def(
"assign", (
class std::exception & (std::exception::*)(
const class std::exception &)) &std::exception::operator=,
"C++: std::exception::operator=(const class std::exception &) --> class std::exception &", pybind11::return_value_policy::automatic, pybind11::arg(
""));
44 cl.def(
"what", (
const char * (std::exception::*)()
const) &std::exception::what,
"C++: std::exception::what() const --> const char *", pybind11::return_value_policy::automatic);
PYBIND11_MAKE_OPAQUE(std::shared_ptr< void >)
void bind_std_exception(std::function< pybind11::module &(std::string const &namespace_) > &M)
const char * what() const noexceptoverride
PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr< T >)