1
- // Copyright (c) 2020-2021 The Pybind Development Team.
1
+ // Copyright (c) 2020-2024 The Pybind Development Team.
2
2
// All rights reserved. Use of this source code is governed by a
3
3
// BSD-style license that can be found in the LICENSE file.
4
4
@@ -44,16 +44,6 @@ High-level aspects:
44
44
* The `void_cast_raw_ptr` option is needed to make the `smart_holder` `vptr`
45
45
member invisible to the `shared_from_this` mechanism, in case the lifetime
46
46
of a `PyObject` is tied to the pointee.
47
-
48
- * Regarding `PYBIND11_TESTS_PURE_CPP_SMART_HOLDER_POC_TEST_CPP` below:
49
- This define serves as a marker for code that is NOT used
50
- from smart_holder_type_casters.h, but is exercised only from
51
- tests/pure_cpp/smart_holder_poc_test.cpp. The marked code was useful
52
- mainly for bootstrapping the smart_holder work. At this stage, with
53
- smart_holder_type_casters.h in production use (at Google) since around
54
- February 2021, it could be moved from here to tests/pure_cpp/ (help welcome).
55
- It will probably be best in most cases to add tests for new functionality
56
- under test/test_class_sh_*.
57
47
*/
58
48
59
49
#pragma once
@@ -256,26 +246,6 @@ struct smart_holder {
256
246
return static_cast <T *>(vptr.get ());
257
247
}
258
248
259
- #ifdef PYBIND11_TESTS_PURE_CPP_SMART_HOLDER_POC_TEST_CPP // See comment near top.
260
- template <typename T>
261
- T &as_lvalue_ref () const {
262
- static const char *context = " as_lvalue_ref" ;
263
- ensure_is_populated (context);
264
- ensure_has_pointee (context);
265
- return *as_raw_ptr_unowned<T>();
266
- }
267
- #endif
268
-
269
- #ifdef PYBIND11_TESTS_PURE_CPP_SMART_HOLDER_POC_TEST_CPP // See comment near top.
270
- template <typename T>
271
- T &&as_rvalue_ref() const {
272
- static const char *context = " as_rvalue_ref" ;
273
- ensure_is_populated (context);
274
- ensure_has_pointee (context);
275
- return std::move (*as_raw_ptr_unowned<T>());
276
- }
277
- #endif
278
-
279
249
template <typename T>
280
250
static smart_holder from_raw_ptr_take_ownership (T *raw_ptr, bool void_cast_raw_ptr = false ) {
281
251
ensure_pointee_is_destructible<T>(" from_raw_ptr_take_ownership" );
@@ -319,16 +289,6 @@ struct smart_holder {
319
289
release_disowned ();
320
290
}
321
291
322
- #ifdef PYBIND11_TESTS_PURE_CPP_SMART_HOLDER_POC_TEST_CPP // See comment near top.
323
- template <typename T>
324
- T *as_raw_ptr_release_ownership (const char *context = " as_raw_ptr_release_ownership" ) {
325
- ensure_can_release_ownership (context);
326
- T *raw_ptr = as_raw_ptr_unowned<T>();
327
- release_ownership ();
328
- return raw_ptr;
329
- }
330
- #endif
331
-
332
292
template <typename T, typename D>
333
293
static smart_holder from_unique_ptr (std::unique_ptr<T, D> &&unq_ptr,
334
294
void *void_ptr = nullptr ) {
@@ -351,19 +311,6 @@ struct smart_holder {
351
311
return hld;
352
312
}
353
313
354
- #ifdef PYBIND11_TESTS_PURE_CPP_SMART_HOLDER_POC_TEST_CPP // See comment near top.
355
- template <typename T, typename D = std::default_delete<T>>
356
- std::unique_ptr<T, D> as_unique_ptr () {
357
- static const char *context = " as_unique_ptr" ;
358
- ensure_compatible_rtti_uqp_del<T, D>(context);
359
- ensure_use_count_1 (context);
360
- T *raw_ptr = as_raw_ptr_unowned<T>();
361
- release_ownership ();
362
- // KNOWN DEFECT (see PR #4850): Does not copy the deleter.
363
- return std::unique_ptr<T, D>(raw_ptr);
364
- }
365
- #endif
366
-
367
314
template <typename T>
368
315
static smart_holder from_shared_ptr (std::shared_ptr<T> shd_ptr) {
369
316
smart_holder hld;
0 commit comments