Last active
December 28, 2015 11:08
-
-
Save bbhavsar/7490750 to your computer and use it in GitHub Desktop.
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
typedef int (*ProcessParamFuncPtr)(void); | |
typedef std::map< std::string, ProcessParamFuncPtr> ProcessFuncMap; | |
// Initialize map with appropriate functions for the datatype. | |
ProcessFuncMap map = boost::assign::map_list_of | |
("int64", process_param< UConfigParamInt, int >) | |
("bool", process_param< UConfigParamBool, bool >) | |
("float", process_param< UConfigParamFloat, float >) | |
("string", process_param< UConfigParamString, std::string>); | |
// Invoke function based on the datatype | |
std::string type = get_type(); | |
ProcessFuncMap::iterator it = map.find(type); | |
if (it != map.end()) { | |
ProcessParamFuncPtr fptr = (*it).second; | |
int ret = fptr(); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment