1 #include <pybind11/pybind11.h>
2 #include <pybind11/stl.h>
9 #ifndef BINDER_PYBIND11_TYPE_CASTER
10 #define BINDER_PYBIND11_TYPE_CASTER
11 PYBIND11_DECLARE_HOLDER_TYPE(T, std::shared_ptr<T>)
12 PYBIND11_DECLARE_HOLDER_TYPE(T, T*)
13 PYBIND11_MAKE_OPAQUE(std::shared_ptr<void>)
19 using std::exception::exception;
21 const char*
what()
const throw()
override
23 pybind11::gil_scoped_acquire gil;
24 pybind11::function overload =
25 pybind11::get_overload(
static_cast<const std::exception*
>(
this),
"what");
28 auto o = overload.operator()<pybind11::return_value_policy::reference>();
29 if (pybind11::detail::cast_is_temporary_value_reference<const char*>::value)
32 #if (PYBIND11_MAJOR_VERSION == 2 && PYBIND11_MINOR_VERSION <= 4)
33 static pybind11::detail::overload_caster_t<const char*> caster;
35 static pybind11::detail::override_caster_t<const char*> caster;
37 return pybind11::detail::cast_ref<const char*>(std::move(o), caster);
40 return pybind11::detail::cast_safe<const char*>(std::move(o));
42 return exception::what();
50 cl(M(
"std"),
"exception",
"");
51 cl.def(pybind11::init(
52 []() {
return new std::exception(); },
56 cl.def(pybind11::init([](std::exception
const& o) {
return new std::exception(o); }));
59 (
class std::exception & (std::exception::*)(
const class std::exception&)) &
60 std::exception::operator=,
61 "C++: std::exception::operator=(const class std::exception &) --> "
62 "class std::exception &",
63 pybind11::return_value_policy::automatic, pybind11::arg(
""));
65 "what", (
const char* (std::exception::*)()
const) & std::exception::what,
66 "C++: std::exception::what() const --> const char *",
67 pybind11::return_value_policy::automatic);