Use new PYBIND11_TESTS_PURE_CPP_SMART_HOLDER_POC_TEST_CPP to exclude smart_holder::as_unique_ptr method from production code.

This commit is contained in:
Ralf W. Grosse-Kunstleve 2023-11-01 08:12:28 -07:00
parent 4fb7d12813
commit 4d9d722215
2 changed files with 4 additions and 0 deletions

View File

@ -335,6 +335,7 @@ struct smart_holder {
return hld;
}
#ifdef PYBIND11_TESTS_PURE_CPP_SMART_HOLDER_POC_TEST_CPP
template <typename T, typename D = std::default_delete<T>>
std::unique_ptr<T, D> as_unique_ptr() {
static const char *context = "as_unique_ptr";
@ -344,6 +345,7 @@ struct smart_holder {
release_ownership();
return std::unique_ptr<T, D>(raw_ptr);
}
#endif
template <typename T>
static smart_holder from_shared_ptr(std::shared_ptr<T> shd_ptr) {

View File

@ -1,3 +1,5 @@
#define PYBIND11_TESTS_PURE_CPP_SMART_HOLDER_POC_TEST_CPP
#include "pybind11/detail/smart_holder_poc.h"
#include <functional>