Lines Matching refs:cast

2     pybind11/cast.h: Partial template specializations to cast between
63 /// at argument preparation time or by `py::cast()` at execution time.
67 throw cast_error("When called outside a bound function, py::cast() cannot "
416 errorString += handle(scope.type).attr("__name__").cast<std::string>();
442 " " + handle(frame->f_code->co_filename).cast<std::string>() +
444 handle(frame->f_code->co_name).cast<std::string>() + "\n";
495 PYBIND11_NOINLINE static handle cast(const void *_src, return_value_policy policy, handle parent,
589 for (auto &cast : typeinfo->implicit_casts) {
590 type_caster_generic sub_caster(*cast.first);
592 value = cast.second(sub_caster.value);
835 static handle cast(const itype &src, return_value_policy policy, handle parent) {
838 return cast(&src, policy, parent);
841 static handle cast(itype &&src, return_value_policy, handle parent) {
842 return cast(&src, return_value_policy::move, parent);
865 // don't do a cast
869 static handle cast(const itype *src, return_value_policy policy, handle parent) {
871 return type_caster_generic::cast(
878 return type_caster_generic::cast(
914 // Shortcut for calling a caster's `cast_op_type` cast operator for casting a type_caster to a T
934 static handle cast(const std::reference_wrapper<type> &src, return_value_policy policy, handle parent) {
938 return caster_t::cast(&src.get(), policy, parent);
950 static handle cast(T_ *src, return_value_policy policy, handle parent) { \
953 auto h = cast(std::move(*src), policy, parent); delete src; return h; \
955 return cast(*src, policy, parent); \
1029 cast(U src, return_value_policy /* policy */, handle /* parent */) {
1035 cast(U src, return_value_policy /* policy */, handle /* parent */) {
1041 cast(U src, return_value_policy /* policy */, handle /* parent */) {
1047 cast(U src, return_value_policy /* policy */, handle /* parent */) {
1053 cast(U src, return_value_policy /* policy */, handle /* parent */) {
1067 static handle cast(T, return_value_policy /* policy */, handle /* parent */) {
1077 using type_caster<void_type>::cast;
1104 static handle cast(const void *ptr, return_value_policy /* policy */, handle /* parent */) {
1154 static handle cast(bool src, return_value_policy /* policy */, handle /* parent */) {
1215 static handle cast(const StringType &src, return_value_policy /* policy */, handle /* parent */) {
1293 static handle cast(const CharT *src, return_value_policy policy, handle parent) {
1295 return StringCaster::cast(StringType(src), policy, parent);
1298 static handle cast(CharT src, return_value_policy policy, handle parent) {
1304 return StringCaster::cast(StringType(1, src), policy, parent);
1377 static handle cast(T &&src, return_value_policy policy, handle parent) {
1408 reinterpret_steal<object>(make_caster<Ts>::cast(std::get<Is>(std::forward<T>(src)), policy, parent))...
1444 using base::cast;
1464 static handle cast(const holder_type &src, return_value_policy, handle) {
1482 throw cast_error("Unable to cast from non-held to held instance (T& to Holder<T>) "
1496 for (auto &cast : typeinfo->implicit_casts) {
1497 copyable_holder_caster sub_caster(*cast.first);
1499 value = cast.second(sub_caster.value);
1522 static handle cast(holder_type &&src, return_value_policy, handle) {
1575 static handle cast(const handle &src, return_value_policy /* policy */, handle /* parent */) {
1612 // Detect whether returning a `type` from a cast on type's type_caster is going to result in a
1622 // When a value returned from a C++ function is being cast back to Python, we almost always want to
1642 throw cast_error("Unable to cast Python instance to C++ type (compile in debug mode for details)");
1644 throw cast_error("Unable to cast Python instance of type " +
1661 T cast(const handle &handle) {
1664 "Unable to cast type to reference: value is local to type caster");
1670 T cast(const handle &handle) { return T(reinterpret_borrow<object>(handle)); }
1674 object cast(const T &value, return_value_policy policy = return_value_policy::automatic_reference,
1680 return reinterpret_steal<object>(detail::make_caster<T>::cast(value, policy, parent));
1683 template <typename T> T handle::cast() const { return pybind11::cast<T>(*this); }
1684 template <> inline void handle::cast() const { return; }
1690 throw cast_error("Unable to cast Python instance to C++ rvalue: instance has multiple references"
1702 // Calling cast() on an rvalue calls pybind::cast with the object rvalue, which does:
1707 template <typename T> detail::enable_if_t<detail::move_always<T>::value, T> cast(object &&object) {
1710 template <typename T> detail::enable_if_t<detail::move_if_unreferenced<T>::value, T> cast(object &&object) {
1712 return cast<T>(object);
1716 template <typename T> detail::enable_if_t<detail::move_never<T>::value, T> cast(object &&object) {
1717 return cast<T>(object);
1720 template <typename T> T object::cast() const & { return pybind11::cast<T>(*this); }
1721 template <typename T> T object::cast() && { return pybind11::cast<T>(std::move(*this)); }
1722 template <> inline void object::cast() const & { return; }
1723 template <> inline void object::cast() && { return; }
1729 object object_or_cast(T &&o) { return pybind11::cast(std::forward<T>(o)); }
1735 // Trampoline use: for reference/pointer types to value-converted values, we do a value cast, then
1743 // Trampoline use: Having a pybind11::cast with an invalid reference type is going to static_assert, even
1744 // though if it's in dead code, so we provide a "trampoline" to pybind11::cast that only does anything in
1745 // cases where pybind11::cast is valid.
1747 return pybind11::cast<T>(std::move(o)); }
1761 { reinterpret_steal<object>(detail::make_caster<Args>::cast(
1807 detail::make_caster<T>::cast(x, return_value_policy::automatic, {})
1999 auto o = reinterpret_steal<object>(detail::make_caster<T>::cast(std::forward<T>(x), policy, {}));