| 2096 | /// Get the pointer the capsule holds. |
| 2097 | template <typename T = void> |
| 2098 | T *get_pointer() const { |
| 2099 | const auto *name = this->name(); |
| 2100 | T *result = static_cast<T *>(PyCapsule_GetPointer(m_ptr, name)); |
| 2101 | if (!result) { |
| 2102 | throw error_already_set(); |
| 2103 | } |
| 2104 | return result; |
| 2105 | } |
| 2106 | |
| 2107 | /// Replaces a capsule's pointer *without* calling the destructor on the existing one. |
| 2108 | void set_pointer(const void *value) { |