Skip to content

Commit 4d9d722

Browse files
committed
Use new PYBIND11_TESTS_PURE_CPP_SMART_HOLDER_POC_TEST_CPP to exclude smart_holder::as_unique_ptr method from production code.
1 parent 4fb7d12 commit 4d9d722

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed

include/pybind11/detail/smart_holder_poc.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@ struct smart_holder {
335335
return hld;
336336
}
337337

338+
#ifdef PYBIND11_TESTS_PURE_CPP_SMART_HOLDER_POC_TEST_CPP
338339
template <typename T, typename D = std::default_delete<T>>
339340
std::unique_ptr<T, D> as_unique_ptr() {
340341
static const char *context = "as_unique_ptr";
@@ -344,6 +345,7 @@ struct smart_holder {
344345
release_ownership();
345346
return std::unique_ptr<T, D>(raw_ptr);
346347
}
348+
#endif
347349

348350
template <typename T>
349351
static smart_holder from_shared_ptr(std::shared_ptr<T> shd_ptr) {

tests/pure_cpp/smart_holder_poc_test.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#define PYBIND11_TESTS_PURE_CPP_SMART_HOLDER_POC_TEST_CPP
2+
13
#include "pybind11/detail/smart_holder_poc.h"
24

35
#include <functional>

0 commit comments

Comments
 (0)