Last active
March 9, 2021 03:04
-
-
Save octavifs/5362297 to your computer and use it in GitHub Desktop.
Converts C++ std::map to boost::python::dict
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Converts a C++ map to a python dict | |
template <class K, class V> | |
boost::python::dict toPythonDict(std::map<K, V> map) { | |
typename std::map<K, V>::iterator iter; | |
boost::python::dict dictionary; | |
for (iter = map.begin(); iter != map.end(); ++iter) { | |
dictionary[iter->first] = iter->second; | |
} | |
return dictionary; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How to use this function?