Converting shared_ptr<const T> fails
Personne n'a encore pris cette issue.
Évaluation
- Difficulté
- 4/5
- Temps estimé
- 3-5 jours
- Accessibilité débutants
- 35/100
Piste de recherche
Commencez par reproduire les bindings C++ montrés avec create_shared_ptr, accept_shared_ptr et register_ptr_to_python en utilisant shared_ptr. Suivez le chemin de conversion de Boost.Python pour le type cible const ; c’est terminé lorsque le Foo Python renvoyé par create_shared_ptr est accepté par accept_shared_ptr sans ArgumentError.
Rédigé par le modèle d'indexation à partir du texte de l'issue.
Description
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?
- Langage dominant
- C++
- Étoiles
- 537
- Forks
- 223
- Merge moyen
- 11 h 22 min
- PR mergées (30 j)
- 2
Guide de contribution
Aucun guide de contribution indexé pour ce dépôt
Par où commencer
- Lisez l'issue en entier, puis le guide de contribution du projet.
- Signalez en commentaire que vous la prenez — cela évite que deux personnes fassent le même travail.
- Forkez le dépôt et travaillez sur une branche.
- Ouvrez une pull request qui référence le numéro de l'issue.
Autres issues de boostorg/python
-
numpy::from_data calls vector::front and crashes (or has UB) when called with a scalar object Ouverte
Difficulté 1/5 Moins d'une heure Accessibilité débutants 84/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 64/100
-
BoostDetectToolset-1.90.0.cmake file not found in an include() call in boost_python-config.cmake Ouverte
Difficulté 3/5 1-2 jours Accessibilité débutants 48/100
-
Difficulté 4/5 3-5 jours Accessibilité débutants 25/100
Toutes les issues de boostorg/python
Issues similaires
-
AuTest Bug Tests
Difficulté 2/5 1-3 heures Accessibilité débutants 78/100
apache/trafficserver#13714 ·
-
bug build
Difficulté 2/5 1-3 heures Accessibilité débutants 88/100
facebookincubator/velox#19143 ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 82/100
-
Difficulté 2/5 1-3 heures Accessibilité débutants 68/100
tenstorrent/tt-metal#57393 · 1 commentaire ·
-
Difficulté 2/5 1-3 heures Accessibilité débutants 76/100
objectionary/eo-graphs#74 ·