Commit Graph

1511 Commits

Author SHA1 Message Date
Ralf W. Grosse-Kunstleve
70ba91f721 Inline smart_holder_type_caster_support, trampoline_self_life_support in type_caster_base.h: the organization of the existing code makes it very difficult to factor the added code properly. 2024-07-06 11:04:25 -07:00
Ralf W. Grosse-Kunstleve
fcc868df59 Add PYBIND11_TYPE_CASTER_BASE_HOLDER(...) (no-op) 2024-07-05 14:37:15 -07:00
Ralf W. Grosse-Kunstleve
46ab14ebb4 Add missing explicit to resolve clang-tidy error. 2024-07-05 12:33:19 -07:00
Ralf W. Grosse-Kunstleve
c84dacc379 Factor out smart_holder_value_and_holder_support.h to avoid code duplication.
All unit tests pass ASAN and MSAN testing with the Google-internal toolchain.
2024-07-05 12:18:11 -07:00
Ralf W. Grosse-Kunstleve
e593589c61 inline unique_ptr_to_python() in cast.h 2024-07-05 10:12:21 -07:00
Ralf W. Grosse-Kunstleve
12c0eb3889 inline shared_ptr_to_python() in cast.h 2024-07-05 10:05:29 -07:00
Ralf W. Grosse-Kunstleve
0b7a628a04 Check for Python instance is uninitialized/disowned in type_caster_base.h. CRUDE intermediate state, needs refactoring.
All 4 remaining BAKEIN_BREAK removed from test_class_sh_basic.py. With that both test_class_sh_basic.cpp and test_class_sh_basic.py are identical to the smart_holder branch.

All unit tests pass ASAN and MSAN testing with the Google-internal toolchain.
2024-07-05 00:28:43 -07:00
Ralf W. Grosse-Kunstleve
fd1afdb2b9 move_only_holder_caster<...unique_ptr...>::load_value(): throw instead of return false (i.e. prefer noisy failure over potentially silent failure). 2024-07-04 23:57:34 -07:00
Ralf W. Grosse-Kunstleve
66fb5c942c
Merge branch 'master' into bakein 2024-07-04 18:21:55 -07:00
Ralf W. Grosse-Kunstleve
874f69d898 Add cast(const std::unique_ptr<type, deleter> &, ...). Remove the last 3 remaining BAKEIN_BREAK in test_class_sh_basic.cpp 2024-07-04 16:09:01 -07:00
Ralf W. Grosse-Kunstleve
ebbe066841 Implement operator std::unique_ptr<type, deleter>(). Resolves all but 1 block of 4 BAKEIN_BREAK in test_class_sh_basic.py 2024-07-04 11:26:43 -07:00
Ralf W. Grosse-Kunstleve
391d7726ad Remove operator type *() unique_ptr, and & (not sure how they would be useful). 2024-07-04 08:25:06 -07:00
Ralf W. Grosse-Kunstleve
d4fc392ebe move_only_holder_caster<type, std::unique_ptr<T, D>>: inherit from type_caster_base<T>
CRUDE INTERMEDIATE STATE, just to see if this builds on all platforms.
2024-07-03 15:16:46 -07:00
Ralf W. Grosse-Kunstleve
224e9343d2 Implement operator std::shared_ptr<type> &(), remove 2 BAKEIN_BREAK: pass_shmp, pass_shcp 2024-07-03 13:51:50 -07:00
Ralf W. Grosse-Kunstleve
af66246fb6 Resolve clang-tidy errors:
```
/__w/pybind11/pybind11/include/pybind11/cast.h:918:44: error: std::move of the variable 'v_h' of the trivially-copyable type 'pybind11::detail::value_and_holder' has no effect [performance-move-const-arg,-warnings-as-errors]
            return load_value_smart_holder(std::move(v_h));
                                           ^
/__w/pybind11/pybind11/include/pybind11/cast.h:911:53: note: consider changing the 1st parameter of 'load_value_smart_holder' from 'pybind11::detail::value_and_holder &&' to 'const pybind11::detail::value_and_holder &'
    bool load_value_smart_holder(value_and_holder &&v_h) {
                                                    ^
/__w/pybind11/pybind11/include/pybind11/cast.h:920:38: error: std::move of the variable 'v_h' of the trivially-copyable type 'pybind11::detail::value_and_holder' has no effect [performance-move-const-arg,-warnings-as-errors]
        return load_value_shared_ptr(std::move(v_h));
                                     ^
/__w/pybind11/pybind11/include/pybind11/cast.h:895:51: note: consider changing the 1st parameter of 'load_value_shared_ptr' from 'pybind11::detail::value_and_holder &&' to 'const pybind11::detail::value_and_holder &'
    bool load_value_shared_ptr(value_and_holder &&v_h) {
                                                  ^
```
2024-07-03 12:54:41 -07:00
Ralf W. Grosse-Kunstleve
fc5678b08b Add value_and_holder loaded_v_h; member (set, but currently unused). 2024-07-03 11:26:04 -07:00
Ralf W. Grosse-Kunstleve
2837df178e Rename holder to shared_ptr_holder to improve readability. No functional changes. 2024-07-03 10:49:17 -07:00
Ralf W. Grosse-Kunstleve
17c0354050 copyable_holder_caster<type, std::shared_ptr<type>>: split load_value_shared_ptr(), load_value_smart_holder() (the latter just throws right now) 2024-07-03 10:30:14 -07:00
Ralf W. Grosse-Kunstleve
556f28a1a4 Add smart_holder_from_shared_ptr() specialization for std::shared_ptr<T const>
Resolves one `// BAKEIN_WIP: Better Const2Mutbl`.
2024-07-03 07:41:48 -07:00
Ralf W. Grosse-Kunstleve
5957133b6e Add smart_holder_from_unique_ptr() specialization for std::unique_ptr<T const, D>
Enables removing:
4 BAKEIN_BREAK in test_class_sh_basic.cpp
2 BAKEIN_BREAK in test_class_sh_basic.py
2024-07-03 07:38:18 -07:00
Ralf W. Grosse-Kunstleve
7a6d30ca58 Fix rtrn_shmp, rtrn_shmp by transferring smart_holder_from_shared_ptr() functionality from smart_holder branch. 2024-07-02 18:25:01 -07:00
Ralf W. Grosse-Kunstleve
12b01305de Add no-op pybind11/smart_holder.h, 21 BAKEIN_BREAK in test_class_sh_basic.cpp, 26 BAKEIN_BREAK in test_class_sh_basic.py
```
========================================================= short test summary info ==========================================================
SKIPPED [1] test_class_sh_basic.py:59: got empty parameter set ('pass_f', 'rtrn_f', 'expected'), function test_load_with_rtrn_f at /usr/local/google/home/rwgk/forked/pybind11/tests/test_class_sh_basic.py:58
SKIPPED [1] test_class_sh_basic.py:70: got empty parameter set ('pass_f', 'rtrn_f', 'regex_expected'), function test_deleter_roundtrip at /usr/local/google/home/rwgk/forked/pybind11/tests/test_class_sh_basic.py:69
SKIPPED [1] test_class_sh_basic.py:99: got empty parameter set ('pass_f', 'rtrn_f', 'expected'), function test_pass_unique_ptr_disowns at /usr/local/google/home/rwgk/forked/pybind11/tests/test_class_sh_basic.py:98
SKIPPED [1] test_class_sh_basic.py:120: got empty parameter set ('pass_f', 'rtrn_f'), function test_cannot_disown_use_count_ne_1 at /usr/local/google/home/rwgk/forked/pybind11/tests/test_class_sh_basic.py:119
SKIPPED [1] test_class_sh_basic.py:145: BAKEIN_BREAK: AttributeError unique_ptr_roundtrip
SKIPPED [1] test_class_sh_basic.py:157: unconditional skip
SKIPPED [1] test_class_sh_basic.py:169: got empty parameter set ('pass_f', 'rtrn_f', 'moved_out', 'moved_in'), function test_unique_ptr_consumer_roundtrip at /usr/local/google/home/rwgk/forked/pybind11/tests/test_class_sh_basic.py:168
SKIPPED [1] test_class_sh_basic.py:210: BAKEIN_BREAK: AttributeError args_unique_ptr
====================================================== 17 passed, 8 skipped in 0.04s =======================================================```
2024-07-02 14:43:23 -07:00
Ralf W. Grosse-Kunstleve
c92b4d86da Insert PYBIND11_SMART_HOLDER_PADDING (with the idea to catch undefined behavior sooner rather than later). 2024-07-02 10:57:25 -07:00
Sam Gross
bb05e0810b
Use PyMutex instead of std::mutex in free-threaded build. (#5219)
* Use PyMutex instead of std::mutex in free-threaded build.

PyMutex is now part of the public C API as of 3.13.0b3 and generally has
slightly less overhead than std::mutex.

* style: pre-commit fixes

* Fix instance_map_shard padding

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-07-02 09:58:09 -07:00
Ralf W. Grosse-Kunstleve
b0cfeec63c Merge branch 'master' into bakein 2024-07-01 21:51:36 -07:00
Ralf W. Grosse-Kunstleve
ae08f51e38 Start pybind11/detail/smart_holder_type_caster_support.h, move unique_ptr_to_python() there, add smart_holder_from_unique_ptr() 2024-07-01 15:52:50 -07:00
Ralf W. Grosse-Kunstleve
6ff547e18a Introduce type_caster_base<>::unique_ptr_to_python() 2024-07-01 12:39:45 -07:00
Ralf W. Grosse-Kunstleve
5518e01562 Copy-paste-and-specialize copyable_holder_caster<shared_ptr>, move_only_holder_caster<unique_ptr>. No functional changes. 2024-07-01 11:47:34 -07:00
Ralf W. Grosse-Kunstleve
e4d0a55575 Remove is_holder_type<unique_ptr> 2024-07-01 11:18:56 -07:00
Ralf W. Grosse-Kunstleve
381fdc54e9 Bring in smart_holder_from_unique_ptr(), smart_holder_from_shared_ptr() from smart_holder_type_casters.h (with this test_wip builds and runs successfully). 2024-06-30 11:32:10 -07:00
Ralf W. Grosse-Kunstleve
e8cd42953e pybind11/detail/init.h: replace type_uses_smart_holder_type_caster<> with is_same<Holder<Class>, smart_holder> (still does not build). 2024-06-30 11:22:41 -07:00
Ralf W. Grosse-Kunstleve
03e6a93c73 Remove stray line (probably from an accident/oversight a long time ago; harmless). 2024-06-30 10:03:58 -07:00
Ralf W. Grosse-Kunstleve
dfaa49bb21 Bring in pybind11/detail/class.h, init.h as-is from smart_holder branch (does not build). 2024-06-30 10:00:33 -07:00
Michael Carlstrom
d805e9967f
feat(types) Adds special Case for empty C++ tuple type annotation (#5214)
* add special case and unit test

* add newline
2024-06-30 09:52:37 -07:00
Ralf W. Grosse-Kunstleve
144ae8be51 Also bring in try_initialization_using_shared_from_this() from smart_holder_type_casters.h. With this test_wip builds and succeeds. 2024-06-29 14:00:34 -07:00
Ralf W. Grosse-Kunstleve
fbf88cb298 Bring smart_holder init_instance_for_type<> directly into the init_instance() specialization. Also bring in dynamic_raw_ptr_cast_if_possible.h. Does not build because try_initialization_using_shared_from_this() is still missing. 2024-06-29 13:53:50 -07:00
Ralf W. Grosse-Kunstleve
00a91571fb fix build failure by introducing init_instance() specialization for smart_holder (test fails) 2024-06-29 12:13:19 -07:00
Ralf W. Grosse-Kunstleve
97a3a49678 make smart_holder the default holder (baby step; does not build) 2024-06-29 12:07:28 -07:00
Ralf W. Grosse-Kunstleve
8b0b377fc1 Bring in smart_holder_poc.h from smart_holder branch (baby step). 2024-06-28 23:02:14 -07:00
wenqing
51c2aa16de
Fixed a compilation error with gcc 14 (#5208) 2024-06-28 07:12:32 -07:00
Michael Carlstrom
08f946a431
fix: add guard for GCC <10.3 on C++20 (#5205)
* Update CI

* update define guard

* style: pre-commit fixes

* updated define guard

* style: pre-commit fixes

* update guard

* testing new guards

* update guards

* surely this time

* style: pre-commit fixes

* Define PYBIND11_TYPING_H_HAS_STRING_LITERAL to avoid repeating a complex expression.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: Ralf W. Grosse-Kunstleve <rwgk@google.com>
2024-06-27 22:20:28 -07:00
Michael Carlstrom
4bd538a40a
feat(types): add support for Typing.Callable Special Case (#5202)
* Add special case

* linty
2024-06-26 16:34:06 -04:00
Sam Gross
2e35470cff
fix: use manual padding of instance_map_shard (#5200)
* Use manual padding of instance_map_shard.

The alignas(64) specifier requires aligned allocation, which is not
available on macOS when targeting versions before 10.14.

* Add 'see #5200'

* Update include/pybind11/detail/internals.h

* Update include/pybind11/detail/internals.h

---------

Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
2024-06-26 15:46:46 -04:00
Henry Schreiner
895e657220
chore: back to work
Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
2024-06-26 00:42:54 -04:00
Henry Schreiner
0c69e1eb21
chore: prepare for 2.13.0 (#5198)
* chore: prepare for 2.13.0

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>

* Update changelog.rst

---------

Signed-off-by: Henry Schreiner <henryschreineriii@gmail.com>
2024-06-25 23:51:27 -04:00
Michael Carlstrom
2be85c6041
feat(types): adds support for TypeGuard and TypeIs (#5194)
* Adds support for TypeGuard and TypeIs

* style: pre-commit fixes

---------

Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-25 22:53:15 -04:00
Michael Carlstrom
26281c7986
feat(types): adds support for Never and NoReturn from python Typing (#5193)
* Adds support for Never and NoReturn

* lint
2024-06-25 21:10:25 -04:00
Michael Carlstrom
183059f9a4
feat(types): add support for typing.Literal type (#5192)
* typevar prototype

* style: pre-commit fixes

* change to NameT

* style: pre-commit fixes

* make string const

* add missing closing bracket

* style: pre-commit fixes

* clean up handle_type_name

* style: pre-commit fixes

* add back missing <

* style: pre-commit fixes

* add back NameT

* try fixed_string

* style: pre-commit fixes

* std::basic_fixed_string

* test c++20

* style: pre-commit fixes

* cleanup

* fix object to typevar conversion

* style: pre-commit fixes

* And CPP20 checks

* style: pre-commit fixes

* add missing cpp20++ check

* style: pre-commit fixes

* Add C++20 check to python

* Fix python if {

* style: pre-commit fixes

* update test name

* style: pre-commit fixes

* remove call on cpp_std

* make field const

* test nontype_template

* update feature check

* update name of guard

* fix try except in test

* fix pre commit

* remove extra semi colon

* except AttributeError

* fix try except in test

* remove const

* Clean up tests

* style: pre-commit fixes

* start string literal

* start int literal

* func declare

* commit clean

* use contextlib.suppres

* resolve stash

* more literal type

* fix annotation name

* stash

* request changes

* lint

* Add comments

* style: pre-commit fixes

* Add support for unions and optionals to be compatible with object

* lint

* remove comment

* Create Literal Type implementation

* clean up

* Update comment

* remove incorrect comment

* rerun CI

* rerun CI

* fix extra line

* lint

* move if defined block

* style: pre-commit fixes

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-25 17:57:34 -04:00
Michael Carlstrom
aebcd704d2
Add TypeVars / method generics typing (#5167)
* typevar prototype

* style: pre-commit fixes

* change to NameT

* style: pre-commit fixes

* make string const

* add missing closing bracket

* style: pre-commit fixes

* clean up handle_type_name

* style: pre-commit fixes

* add back missing <

* style: pre-commit fixes

* add back NameT

* try fixed_string

* style: pre-commit fixes

* std::basic_fixed_string

* test c++20

* style: pre-commit fixes

* cleanup

* fix object to typevar conversion

* style: pre-commit fixes

* And CPP20 checks

* style: pre-commit fixes

* add missing cpp20++ check

* style: pre-commit fixes

* Add C++20 check to python

* Fix python if {

* style: pre-commit fixes

* update test name

* style: pre-commit fixes

* remove call on cpp_std

* make field const

* test nontype_template

* update feature check

* update name of guard

* fix try except in test

* fix pre commit

* remove extra semi colon

* except AttributeError

* fix try except in test

* remove const

* Clean up tests

* style: pre-commit fixes

* use contextlib.suppres

* request changes

* lint

* Add comments

* style: pre-commit fixes

* Add support for unions and optionals to be compatible with object

* lint

* remove comment

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2024-06-25 16:25:40 -04:00
Ralf W. Grosse-Kunstleve
a406a62e5b
fix: use std::addressof in type_caster_base.h (#5189)
* Add tests only. Fails to build with this error message:

```
g++ -o pybind11/tests/test_copy_move.os -c -std=c++17 -fPIC -fvisibility=hidden -O0 -g -Wall -Wextra -Wconversion -Wcast-qual -Wdeprecated -Wundef -Wnon-virtual-dtor -Wunused-result -Werror -isystem /usr/include/python3.11 -isystem /usr/include/eigen3 -DPYBIND11_STRICT_ASSERTS_CLASS_HOLDER_VS_TYPE_CASTER_MIX -DPYBIND11_ENABLE_TYPE_CASTER_ODR_GUARD_IF_AVAILABLE -DPYBIND11_TEST_BOOST -DPYBIND11_INTERNALS_VERSION=10000000 -Ipybind11/include -I/usr/local/google/home/rwgk/forked/pybind11/include -I/usr/local/google/home/rwgk/clone/pybind11/include /usr/local/google/home/rwgk/forked/pybind11/tests/test_copy_move.cpp
In file included from /usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../cast.h:15,
                 from /usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../attr.h:14,
                 from /usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/class.h:12,
                 from /usr/local/google/home/rwgk/forked/pybind11/include/pybind11/pybind11.h:13,
                 from /usr/local/google/home/rwgk/forked/pybind11/include/pybind11/stl.h:12,
                 from /usr/local/google/home/rwgk/forked/pybind11/tests/test_copy_move.cpp:11:
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../detail/type_caster_base.h: In instantiation of ‘static pybind11::handle pybind11::detail::type_caster_base<type>::cast(const itype&, pybind11::return_value_policy, pybind11::handle) [with type = UnusualOpRef; itype = UnusualOpRef]’:
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../cast.h:1230:37:   required from ‘pybind11::object pybind11::cast(T&&, return_value_policy, handle) [with T = const UnusualOpRef&; typename std::enable_if<(! std::is_base_of<detail::pyobject_tag, typename std::remove_reference<_Tp>::type>::value), int>::type <anonymous> = 0]’
/usr/local/google/home/rwgk/forked/pybind11/tests/test_copy_move.cpp:162:80:   required from here
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../detail/type_caster_base.h:1110:20: error: no matching function for call to ‘pybind11::detail::type_caster_base<UnusualOpRef>::cast(const UnusualOpRef::NonTrivialType, pybind11::return_value_policy&, pybind11::handle&)’
 1110 |         return cast(&src, policy, parent);
      |                ~~~~^~~~~~~~~~~~~~~~~~~~~~
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../detail/type_caster_base.h:1105:19: note: candidate: ‘static pybind11::handle pybind11::detail::type_caster_base<type>::cast(const itype&, pybind11::return_value_policy, pybind11::handle) [with type = UnusualOpRef; itype = UnusualOpRef]’
 1105 |     static handle cast(const itype &src, return_value_policy policy, handle parent) {
      |                   ^~~~
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../detail/type_caster_base.h:1105:37: note:   no known conversion for argument 1 from ‘const UnusualOpRef::NonTrivialType’ {aka ‘const std::shared_ptr<int>’} to ‘const pybind11::detail::type_caster_base<UnusualOpRef>::itype&’ {aka ‘const UnusualOpRef&’}
 1105 |     static handle cast(const itype &src, return_value_policy policy, handle parent) {
      |                        ~~~~~~~~~~~~~^~~
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../detail/type_caster_base.h:1113:19: note: candidate: ‘static pybind11::handle pybind11::detail::type_caster_base<type>::cast(itype&&, pybind11::return_value_policy, pybind11::handle) [with type = UnusualOpRef; itype = UnusualOpRef]’
 1113 |     static handle cast(itype &&src, return_value_policy, handle parent) {
      |                   ^~~~
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../detail/type_caster_base.h:1113:32: note:   no known conversion for argument 1 from ‘const UnusualOpRef::NonTrivialType’ {aka ‘const std::shared_ptr<int>’} to ‘pybind11::detail::type_caster_base<UnusualOpRef>::itype&&’ {aka ‘UnusualOpRef&&’}
 1113 |     static handle cast(itype &&src, return_value_policy, handle parent) {
      |                        ~~~~~~~~^~~
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../detail/type_caster_base.h:1142:19: note: candidate: ‘static pybind11::handle pybind11::detail::type_caster_base<type>::cast(const itype*, pybind11::return_value_policy, pybind11::handle) [with type = UnusualOpRef; itype = UnusualOpRef]’
 1142 |     static handle cast(const itype *src, return_value_policy policy, handle parent) {
      |                   ^~~~
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../detail/type_caster_base.h:1142:37: note:   no known conversion for argument 1 from ‘const UnusualOpRef::NonTrivialType’ {aka ‘const std::shared_ptr<int>’} to ‘const pybind11::detail::type_caster_base<UnusualOpRef>::itype*’ {aka ‘const UnusualOpRef*’}
 1142 |     static handle cast(const itype *src, return_value_policy policy, handle parent) {
      |                        ~~~~~~~~~~~~~^~~
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../detail/type_caster_base.h: In instantiation of ‘static pybind11::handle pybind11::detail::type_caster_base<type>::cast(itype&&, pybind11::return_value_policy, pybind11::handle) [with type = UnusualOpRef; itype = UnusualOpRef]’:
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../cast.h:1230:37:   required from ‘pybind11::object pybind11::cast(T&&, return_value_policy, handle) [with T = UnusualOpRef; typename std::enable_if<(! std::is_base_of<detail::pyobject_tag, typename std::remove_reference<_Tp>::type>::value), int>::type <anonymous> = 0]’
/usr/local/google/home/rwgk/forked/pybind11/tests/test_copy_move.cpp:163:74:   required from here
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../detail/type_caster_base.h:1114:20: error: no matching function for call to ‘pybind11::detail::type_caster_base<UnusualOpRef>::cast(UnusualOpRef::NonTrivialType, pybind11::return_value_policy, pybind11::handle&)’
 1114 |         return cast(&src, return_value_policy::move, parent);
      |                ~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../detail/type_caster_base.h:1105:19: note: candidate: ‘static pybind11::handle pybind11::detail::type_caster_base<type>::cast(const itype&, pybind11::return_value_policy, pybind11::handle) [with type = UnusualOpRef; itype = UnusualOpRef]’
 1105 |     static handle cast(const itype &src, return_value_policy policy, handle parent) {
      |                   ^~~~
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../detail/type_caster_base.h:1105:37: note:   no known conversion for argument 1 from ‘UnusualOpRef::NonTrivialType’ {aka ‘std::shared_ptr<int>’} to ‘const pybind11::detail::type_caster_base<UnusualOpRef>::itype&’ {aka ‘const UnusualOpRef&’}
 1105 |     static handle cast(const itype &src, return_value_policy policy, handle parent) {
      |                        ~~~~~~~~~~~~~^~~
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../detail/type_caster_base.h:1113:19: note: candidate: ‘static pybind11::handle pybind11::detail::type_caster_base<type>::cast(itype&&, pybind11::return_value_policy, pybind11::handle) [with type = UnusualOpRef; itype = UnusualOpRef]’
 1113 |     static handle cast(itype &&src, return_value_policy, handle parent) {
      |                   ^~~~
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../detail/type_caster_base.h:1113:32: note:   no known conversion for argument 1 from ‘UnusualOpRef::NonTrivialType’ {aka ‘std::shared_ptr<int>’} to ‘pybind11::detail::type_caster_base<UnusualOpRef>::itype&&’ {aka ‘UnusualOpRef&&’}
 1113 |     static handle cast(itype &&src, return_value_policy, handle parent) {
      |                        ~~~~~~~~^~~
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../detail/type_caster_base.h:1142:19: note: candidate: ‘static pybind11::handle pybind11::detail::type_caster_base<type>::cast(const itype*, pybind11::return_value_policy, pybind11::handle) [with type = UnusualOpRef; itype = UnusualOpRef]’
 1142 |     static handle cast(const itype *src, return_value_policy policy, handle parent) {
      |                   ^~~~
/usr/local/google/home/rwgk/forked/pybind11/include/pybind11/detail/../detail/type_caster_base.h:1142:37: note:   no known conversion for argument 1 from ‘UnusualOpRef::NonTrivialType’ {aka ‘std::shared_ptr<int>’} to ‘const pybind11::detail::type_caster_base<UnusualOpRef>::itype*’ {aka ‘const UnusualOpRef*’}
 1142 |     static handle cast(const itype *src, return_value_policy policy, handle parent) {
      |                        ~~~~~~~~~~~~~^~~
```

* Replace `&src` with `std::addressof(src)` to fix the error building the added tests.

* Fix accident (not sure how the `const` slipped in here when transferring the diff from pybind11k).
2024-06-24 08:59:55 -07:00