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 = pybind11::get_overload(
25 static_cast<const std::exception*>(
this),
"what");
29 overload.operator()<pybind11::return_value_policy::reference>();
30 if (pybind11::detail::cast_is_temporary_value_reference<
34 #if (PYBIND11_MAJOR_VERSION == 2 && PYBIND11_MINOR_VERSION <= 4) 35 static pybind11::detail::overload_caster_t<const char*> caster;
37 static pybind11::detail::override_caster_t<const char*> caster;
39 return pybind11::detail::cast_ref<const char*>(
40 std::move(o), caster);
43 return pybind11::detail::cast_safe<const char*>(std::move(o));
45 return exception::what();
50 std::function<pybind11::module&(std::string
const& namespace_)>& M)
54 std::exception, std::shared_ptr<std::exception>,
56 cl(M(
"std"),
"exception",
"");
57 cl.def(pybind11::init(
58 []() {
return new std::exception(); },
63 cl.def(pybind11::init(
64 [](std::exception
const& o) {
return new std::exception(o); }));
67 (
class std::exception &
68 (std::exception::*)(
const class std::exception&)) &
69 std::exception::operator=,
70 "C++: std::exception::operator=(const class std::exception &) --> " 71 "class std::exception &",
72 pybind11::return_value_policy::automatic, pybind11::arg(
""));
75 (
const char* (std::exception::*)()
const) & std::exception::what,
76 "C++: std::exception::what() const --> const char *",
77 pybind11::return_value_policy::automatic);
const char * what() const override
void bind_std_exception(std::function< pybind11::module &(std::string const &namespace_)> &M)