support strongly typed enum

This commit is contained in:
Wenzel Jakob 2015-08-29 02:08:32 +02:00
parent bce10fae38
commit a750031795

View File

@ -742,7 +742,7 @@ public:
: class_<Type>(scope, name, doc), m_parent(scope) { : class_<Type>(scope, name, doc), m_parent(scope) {
auto entries = new std::unordered_map<int, const char *>(); auto entries = new std::unordered_map<int, const char *>();
this->def("__str__", [name, entries](Type value) -> std::string { this->def("__str__", [name, entries](Type value) -> std::string {
auto it = entries->find(value); auto it = entries->find((int) value);
return std::string(name) + "." + return std::string(name) + "." +
((it == entries->end()) ? std::string("???") ((it == entries->end()) ? std::string("???")
: std::string(it->second)); : std::string(it->second));