Converting shared_ptr<const T> fails
まだ誰も着手していません。
評価
調査の方向性
まず、shared_ptr を使用して、示されている C++ バインディングを create_shared_ptr、accept_shared_ptr、register_ptr_to_python で再現します。const ターゲット型に対する Boost.Python の変換経路を追跡します。create_shared_ptr が返す Python の Foo が ArgumentError なしで accept_shared_ptr に受け入れられれば完了です。
索引モデルが issue の本文から書いたものです。
説明
Boost Python (1.63) works well with shared_ptr<T>; if I write this in C++:
shared_ptr<Foo> create_shared_ptr() { return shared_ptr{...}; }
void accept_shared_ptr(const shared_ptr<Foo>& p) { }
...
class_<Foo, boost::noncopyable>("Foo", no_init); //Expose abstract class
register_ptr_to_python< shared_ptr<Foo> >();
def("create_shared_ptr", create_shared_ptr);
def("accept_shared_ptr", accept_shared_ptr);
Then I can write this in Python and everything works:
accept_shared_ptr(create_shared_ptr())
The problem comes when I try and wrap shared_ptr<const Foo>. (Which I need to do because I am wrapping a library that returns this.) If I modify the C++ functions as follows:
shared_ptr<const Foo> create_shared_ptr() { return shared_ptr{...}; }
void accept_shared_ptr(const shared_ptr<const Foo>& p) { }
Then I get the error:
Boost.Python.ArgumentError: Python argument types in w3w_python.accept_shared_ptr(Foo) did not match C++ signature: accept_shared_ptr(std::shared_ptr<Foo const>)
It seems the internals are implementing conversion from python Foo to C++ shared_ptr<Foo>, but not to C++ shared_ptr<const Foo>. Using
register_ptr_to_python< shared_ptr<const Foo> >();
doesn't help. How can I fix this?
- 主要言語
- C++
- スター
- 537
- フォーク
- 223
- 平均マージ
- 11時間 22分
- マージ済み PR(30日)
- 2
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
boostorg/python のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 84/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 64/100
-
BoostDetectToolset-1.90.0.cmake file not found in an include() call in boost_python-config.cmake オープン
難易度 3/5 1〜2日 初心者へのやさしさ 48/100
-
難易度 4/5 3〜5日 初心者へのやさしさ 25/100
boostorg/python の issue をすべて見る
似ている issue
-
ai_reviewed
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
ydb-platform/ydb#53869 · コメント 3 件 ·
-
bug cert blocker needs triage
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
project-chip/connectedhomeip#74373 ·
-
upstream update
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
conan-io/conan-center-index#31035 ·
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
documentation
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
vllm-project/vllm-ascend#17329 ·