boostorg / boostorg/python

boost::python fails to correctly handle constness of wrapped classes

Offen
#205 2 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen
Vorherrschende Sprache
C++
Sterne
537
Forks
223
Ø Merge
11 Std. 22 Min.
Gemergte PRs (30 T.)
2

Beschreibung

I want to wrap C++ code that only provides `const` access to a class `Foo`:

```cpp
struct Foo {};
std::shared_ptr producer();
```
Wrapping `Foo` as usual:
```cpp
BOOST_PYTHON_MODULE(foo) {
boost::python::class_, boost::noncopyable>("Foo", boost::python::no_init);
boost::python::def("producer", &producer);
}
```
compiles fine, but complains at runtime - obviously - about a missing type converter:
`No to_python (by-value) converter found for C++ type: std::shared_ptr`

Alternatively trying:
```cpp
BOOST_PYTHON_MODULE(foo) {
// const holder
boost::python::class_, boost::noncopyable>("Foo", boost::python::no_init);
// const class + holder
boost::python::class_, boost::noncopyable>("Foo", boost::python::no_init);
}
```
yields compile-time errors about constness issues. Isn't there a solution available that respects constness?

Beitragsleitfaden

Für dieses Repository ist kein Beitragsleitfaden indexiert

Bewertung

Dieses Issue wurde noch nicht bewertet.

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.