We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a8c64c0 commit 6b59d1eCopy full SHA for 6b59d1e
dynd/include/utility_functions.hpp
@@ -404,6 +404,16 @@ class py_ref_t {
404
return py_ref_t<true, not_null>(o, false);
405
}
406
407
+ // Copy the current reference.
408
+ py_ref_t<owns_ref, not_null> copy() noexcept
409
+ {
410
+ // Assert that the wrapped pointer is not null if it shouldn't be.
411
+ PYDYND_ASSERT_IF(not_null, o != nullptr);
412
+ // Assert that the wrapped reference is actually valid if it isn't null.
413
+ PYDYND_ASSERT_IF(o != nullptr, Py_REFCNT(o) > 0);
414
+ return py_ref_t<owns_ref, not_null>(o, false);
415
+ }
416
+
417
// Return a reference to the encapsulated PyObject as a raw pointer.
418
// Set the encapsulated pointer to NULL.
419
// If this is a type that owns its reference, an owned reference is returned.
0 commit comments