cppyabm
1.0.17
An agent-based library to integrate C++ and Python
|
|
Go to the documentation of this file.
24 value.arg =
"loading ArgInspector1 argument " +
25 std::string(convert ?
"WITH" :
"WITHOUT") +
" conversion allowed. "
26 "Argument value = " + (std::string)
str(src);
39 value.arg =
"loading ArgInspector2 argument " +
40 std::string(convert ?
"WITH" :
"WITHOUT") +
" conversion allowed. "
41 "Argument value = " + (std::string)
str(src);
58 return py::none().release();
74 namespace pybind11 {
namespace detail {
80 return py::bool_(
true).release();
98 return a.
arg +
"\n" + b.
arg +
"\n" + std::to_string(c) +
"\n" + d->
arg;
103 py::class_<ArgInspector>(
m,
"ArgInspector")
107 .def_static(
"h", &ArgInspector::h, py::arg{}.noconvert(), py::arg() =
ArgAlwaysConverts())
112 m.def(
"floats_preferred", [](
double f) {
return 0.5 * f; },
"f"_a);
113 m.def(
"floats_only", [](
double f) {
return 0.5 * f; },
"f"_a.noconvert());
114 m.def(
"ints_preferred", [](
int i) {
return i / 2; },
"i"_a);
115 m.def(
"ints_only", [](
int i) {
return i / 2; },
"i"_a.noconvert());
121 m.def(
"custom_caster_no_destroy", []() {
static auto *dt =
new DestructionTester();
return dt; });
124 py::return_value_policy::take_ownership);
126 py::return_value_policy::take_ownership);
127 m.def(
"destruction_tester_cstats", &ConstructorStats::get<DestructionTester>, py::return_value_policy::reference);
bool load(handle src, bool convert)
static handle cast(const ArgInspector2 &src, return_value_policy, handle)
PYBIND11_TYPE_CASTER(ArgInspector2, _("ArgInspector2"))
constexpr descr< N - 1 > _(char const(&text)[N])
bool load(handle, bool convert)
void print_copy_created(T *inst, Values &&...values)
void print_default_created(T *inst, Values &&...values)
static handle cast(const DestructionTester &, return_value_policy, handle)
static handle cast(const ArgAlwaysConverts &, return_value_policy, handle)
void print_copy_assigned(T *inst, Values &&...values)
DestructionTester & operator=(DestructionTester &&)
bool load(handle src, bool convert)
DestructionTester(DestructionTester &&)
static handle cast(const ArgInspector1 &src, return_value_policy, handle)
PYBIND11_TYPE_CASTER(ArgInspector1, _("ArgInspector1"))
DestructionTester(const DestructionTester &)
void print_move_created(T *inst, Values &&...values)
void print_destroyed(T *inst, Values &&...values)
return_value_policy
Approach used to cast a previously unknown C++ instance into a Python object.
void print_move_assigned(T *inst, Values &&...values)
TEST_SUBMODULE(custom_type_casters, m)
PYBIND11_TYPE_CASTER(DestructionTester, _("DestructionTester"))
DestructionTester & operator=(const DestructionTester &)
PYBIND11_TYPE_CASTER(ArgAlwaysConverts, _("ArgAlwaysConverts"))