From 4d9d722215cce2a5aabc8a894208dc5c1fdf2182 Mon Sep 17 00:00:00 2001 From: "Ralf W. Grosse-Kunstleve" Date: Wed, 1 Nov 2023 08:12:28 -0700 Subject: [PATCH] Use new `PYBIND11_TESTS_PURE_CPP_SMART_HOLDER_POC_TEST_CPP` to exclude `smart_holder::as_unique_ptr` method from production code. --- include/pybind11/detail/smart_holder_poc.h | 2 ++ tests/pure_cpp/smart_holder_poc_test.cpp | 2 ++ 2 files changed, 4 insertions(+) diff --git a/include/pybind11/detail/smart_holder_poc.h b/include/pybind11/detail/smart_holder_poc.h index 658657dc5..d9eda2f77 100644 --- a/include/pybind11/detail/smart_holder_poc.h +++ b/include/pybind11/detail/smart_holder_poc.h @@ -335,6 +335,7 @@ struct smart_holder { return hld; } +#ifdef PYBIND11_TESTS_PURE_CPP_SMART_HOLDER_POC_TEST_CPP template > std::unique_ptr as_unique_ptr() { static const char *context = "as_unique_ptr"; @@ -344,6 +345,7 @@ struct smart_holder { release_ownership(); return std::unique_ptr(raw_ptr); } +#endif template static smart_holder from_shared_ptr(std::shared_ptr shd_ptr) { diff --git a/tests/pure_cpp/smart_holder_poc_test.cpp b/tests/pure_cpp/smart_holder_poc_test.cpp index 1eaef9009..f820b9bf6 100644 --- a/tests/pure_cpp/smart_holder_poc_test.cpp +++ b/tests/pure_cpp/smart_holder_poc_test.cpp @@ -1,3 +1,5 @@ +#define PYBIND11_TESTS_PURE_CPP_SMART_HOLDER_POC_TEST_CPP + #include "pybind11/detail/smart_holder_poc.h" #include