* Replace `unique_ptr_cref_roundtrip()` with `pass_unique_ptr_cref()`, `rtrn_unique_ptr_cref()` to make the current behavior obvious.
* add in unique_ptr_storage, unique_ptr_storage_deleter
* Add shared_ptr_storage (with that disowning fails as expected).
* Add load_as_const_unique_ptr()
* Restore original struct_smart_holder.h
* factor out `smart_holder::extract_deleter()`
* Better error message.
* Misc cleanup/tidying.
* Use `re.match("ctor_arg(_MvCtor)*_MvCtor", ...)` for compatibility with MSVC, NVHPC, ICC
* Add small comments.
* Fix small, inconsequential oversight in test code.
* Apply suggestion by @iwanders under PR #5334
* Remove `std::move()` in `smart_holder::extract_deleter()`
* Add `static_assert()` following a suggestion by @iwanders under PR #5334
PREPARATION for:
PR #5332 — Fix handling of const unique_ptr<T, D> & (do not disown).
Splitting out so that the functional changes under PR #5332 will be more obvious.
The only functional change under this PR is that
```
assert(custom_deleter_ptr != nullptr);
```
is replaced with:
```
if (custom_deleter_ptr == nullptr) {
throw std::runtime_error(
std::string("smart_holder::extract_deleter() precondition failure (") + context
+ ").");
}
```
PREPARATION for:
PR #5332 — Fix handling of const unique_ptr<T, D> & (do not disown).
Splitting out so that the functional changes under PR #5332 will be more obvious.
* DOC: Clarify requirements for including pybind11
Inherited from requirements for including Python.h
Closes#4999
* style: pre-commit fixes
---------
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* fix: allow -Wpedantic again
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* tests: ignore pedantic warning for PYBIND11_DECLARE_HOLDER_TYPE
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* tests: try just turning off pedantic for one file
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* tests: only run pedantic in C++20 mode
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* Update tests/local_bindings.h
---------
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* feat: add `<ranges>` support for `py::tuple` and `py::list`
* fix: format the code
* fix: disable `ranges` in clang < 16
* refactor: move `<ranges>` test macro to `test_pytypes.h`
* refactor: seperate `ranges` test into 3 funcs
* style: compress the if statement
* style: pre-commit fixes
* style: better formatting
---------
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
* fix: never use `..` in a header include
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* fix: one more parent include
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
---------
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* fix: Escape paths with spaces in include list from --includes
* fix: --includes should not use shlex on Windows platforms
* Apply suggestions from code review
* fix: use custom impl
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* Support trailing backslashes
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
---------
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
Co-authored-by: Markus Bauer <markus.bauer@cispa.saarland>
Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
* Configure only one job per OS kind to build and run tests with `-DPYBIND11_USE_SMART_HOLDER_AS_DEFAULT`
Remove ci_sh_def.yml
Piggy-backed: Add `smart_holder` to `branches` in emscripten.yaml
* Fix misunderstanding.
* Add `/GR /EHsc` for Windows.
* #error "Intentional Breakage" (to verify: PYBIND11_ACTUALLY_USING_SMART_HOLDER_AS_DEFAULT)
* Revert "#error "Intentional Breakage" (to verify: PYBIND11_ACTUALLY_USING_SMART_HOLDER_AS_DEFAULT)"
This reverts commit 4f6f5cb6e9.
* Add `test_pass_std_vector_int()`, `test_pass_std_set_int()` in test_stl
* Change `list_caster` to also accept generator objects (`PyGen_Check(src.ptr()`).
Note for completeness: This is a more conservative change than https://github.com/google/pywrapcc/pull/30042
* Drop in (currently unpublished) PyCLIF code, use in `list_caster`, adjust tests.
* Use `PyObjectTypeIsConvertibleToStdSet()` in `set_caster`, adjust tests.
* Use `PyObjectTypeIsConvertibleToStdMap()` in `map_caster`, add tests.
* Simplify `list_caster` `load()` implementation, push str/bytes check into `PyObjectTypeIsConvertibleToStdVector()`.
* clang-tidy cleanup with a few extra `(... != 0)` to be more consistent.
* Also use `PyObjectTypeIsConvertibleToStdVector()` in `array_caster`.
* Update comment pointing to clif/python/runtime.cc (code is unchanged).
* Comprehensive test coverage, enhanced set_caster load implementation.
* Resolve clang-tidy eror.
* Add a long C++ comment explaining what led to the `PyObjectTypeIsConvertibleTo*()` implementations.
* Minor function name change in test.
* strcmp -> std::strcmp (thanks @Skylion007 for catching this)
* Add `PyCallable_Check(items)` in `PyObjectTypeIsConvertibleToStdMap()`
* Resolve clang-tidy error
* Use `PyMapping_Items()` instead of `src.attr("items")()`, to be internally consistent with `PyMapping_Check()`
* Update link to PyCLIF sources.
* Fix typo (thanks @wangxf123456 for catching this)
* Add `test_pass_std_vector_int()`, `test_pass_std_set_int()` in test_stl
* Change `list_caster` to also accept generator objects (`PyGen_Check(src.ptr()`).
Note for completeness: This is a more conservative change than https://github.com/google/pywrapcc/pull/30042
* Drop in (currently unpublished) PyCLIF code, use in `list_caster`, adjust tests.
* Use `PyObjectTypeIsConvertibleToStdSet()` in `set_caster`, adjust tests.
* Use `PyObjectTypeIsConvertibleToStdMap()` in `map_caster`, add tests.
* Simplify `list_caster` `load()` implementation, push str/bytes check into `PyObjectTypeIsConvertibleToStdVector()`.
* clang-tidy cleanup with a few extra `(... != 0)` to be more consistent.
* Also use `PyObjectTypeIsConvertibleToStdVector()` in `array_caster`.
* Update comment pointing to clif/python/runtime.cc (code is unchanged).
* Comprehensive test coverage, enhanced set_caster load implementation.
* Resolve clang-tidy eror.
* Add a long C++ comment explaining what led to the `PyObjectTypeIsConvertibleTo*()` implementations.
* Minor function name change in test.
* strcmp -> std::strcmp (thanks @Skylion007 for catching this)
* Add `PyCallable_Check(items)` in `PyObjectTypeIsConvertibleToStdMap()`
* Resolve clang-tidy error
* Use `PyMapping_Items()` instead of `src.attr("items")()`, to be internally consistent with `PyMapping_Check()`
* Update link to PyCLIF sources.
* Fix typo (thanks @wangxf123456 for catching this)
* Fix typo discovered by new version of codespell.
* fix(cmake): add required emscripten flags
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* Update emscripten.yaml
* fix(cmake): add required emscripten flags to headers target
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* fix(cmake): incorrect detection of Emscripten
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* fix(cmake): allow pybind11::headers to be modified
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* fix(cmake): hide a warning when building the tests standalone
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* fix(cmake): use explicit variable for is config
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* fix(cmake): go back to ALIAS target
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* chore: reduce overall diff
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* chore: reduce overall diff
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* chore: shorten code a bit
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
---------
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
* Allow specializations based on callback function return values.
* clang-tidy auto fix
* Add a test case for function specialization.
* Add test for callback function that raises Python exception.
* Fix test failures.
* style: pre-commit fixes
* Add `#define PYBIND11_HAS_TYPE_CASTER_STD_FUNCTION_SPECIALIZATIONS`
---------
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>