MCPcopy Create free account
hub / github.com/pybind/pybind11 / cast

Function cast

include/pybind11/stl.h:205–218  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

203
204 template <typename T>
205 static handle cast(T &&src, return_value_policy policy, handle parent) {
206 if (!std::is_lvalue_reference<T>::value) {
207 policy = return_value_policy_override<Key>::policy(policy);
208 }
209 pybind11::set s;
210 for (auto &&value : src) {
211 auto value_ = reinterpret_steal<object>(
212 key_conv::cast(detail::forward_like<T>(value), policy, parent));
213 if (!value_ || !s.add(std::move(value_))) {
214 return handle();
215 }
216 }
217 return s.release();
218 }
219
220 PYBIND11_TYPE_CASTER(type,
221 io_name("collections.abc.Set", "set") + const_name("[") + key_conv::name

Callers 10

initializeMethod · 0.70
enum_Class · 0.70
make_iterator_implFunction · 0.70
format_message_key_errorFunction · 0.70
runMethod · 0.70
castMethod · 0.70
castMethod · 0.70
castMethod · 0.70
castMethod · 0.70
operator()Method · 0.70

Calls 4

moveFunction · 0.85
releaseMethod · 0.80
handleFunction · 0.70
addMethod · 0.45

Tested by

no test coverage detected