Exposing inherited static member variables as static property with the same name leads to exception
- Lenguaje dominante
- C++
- Estrellas
- 537
- Forks
- 223
- Merge medio
- 11 h 22 min
- PR fusionados (30 d)
- 2
Descripción
This bug has been reported by Luke Titley in 2009 on boost-build mailing list. It is still reproducible with the version of boost python 1.65 on Visual C++ 2017. I'm using the Luke's code snippet to show the problem.
There are two boost python classes, one inheriting from the other; each with a static member variable of the same name.
//---------------------------------------------------------------------------------------
// C++ Classes
//---------------------------------------------------------------------------------------
class Base
{
public:
static const wstring Name;
};
const wstring Base::Name(L"Base");
//---------------------------------------------------------------------------------------
class Derived : public Base
{
public:
static const wstring Name;
};
const wstring Derived ::Name(L"Derived");
//---------------------------------------------------------------------------------------
// Boost Python Bindings
//---------------------------------------------------------------------------------------
wstring getBaseName()
{
return Base::Name;
}
void exposeBase()
{
py::class_("Base")
.add_static_property("Name", &getBaseName) ;
}
//---------------------------------------------------------------------------------------
wstring getDerivedName()
{
return Derived::Name;
}
void exposeDerived()
{
py::class_ >("Derived")
.add_static_property("Name", &getDerivedName) ;
}
//---------------------------------------------------------------------------------------
BOOST_PYTHON_MODULE(nmx)
{
exposeBase();
exposeDerived();
}
The import of the module fails and it's caused by throwing exception in exposedDerived (add_static_property).
Best Regards,
Gabriel
Guía de contribución
No hay ninguna guía de contribución indexada para este repositorio
Evaluación
Este issue todavía no se ha evaluado.