2012-04-13 5 views
12

Ich benutze boost :: python, um eine C++ Klasse zu umhüllen. Diese Klasse erlaubt keine Kopierkonstruktoren, aber das Python-Modul möchte immer eine erstellen.boost :: python: Kompilierung schlägt fehl, weil Kopierkonstruktor privat ist

Die C++ Klasse sieht wie folgt aus (vereinfacht)

class Foo { 
    public: 
    Foo(const char *name); // constructor 

    private: 
    ByteArray m_bytearray; 
}; 

Die ByteArray-Klasse von boost :: vererbt wird noncopyable daher Foo nicht Kopierkonstruktoren hat.

Hier ist das Python-Modul-Stub:

BOOST_PYTHON_MODULE(Foo) 
{ 
    class_<Foo>("Foo", init<const char *>()) 
    ; 
} 

Wenn die boost :: Modul Python kompilieren, bekomme ich Fehler, dass eine Kopie Konstruktor für Foo kann nicht erstellt werden, weil ByteArray von boost :: erbt noncopyable.

Wie kann ich Kopierkonstruktoren in meinem Python-Modul deaktivieren?

Dank Christoph

Antwort

36

ich es gefunden. ich muss boost angeben :: nicht kopierbar:

BOOST_PYTHON_MODULE(Foo) 
{ 
    class_<Foo, boost::noncopyable>("Foo", init<const char *>()) 
    ; 
} 
Verwandte Themen