What does an associative array look like after HipHop PHP converts it to C++?
I was hoping someone that already compiled HipHop can tell me what this would look like:
$myAssoc = array('key'=>'value');
$myAssoc = array();
$myAssoc['key'] = 'value';
What does an associative array look like after HipHop PHP converts it to C++?
I was hoping someone that already compiled HipHop can tell me what this would look like:
$myAssoc = array('key'=>'value');
$myAssoc = array();
$myAssoc['key'] = 'value';
std::unordered_map<std::string, std::string> myAssoc();
myAssoc["key"] = "value";
EDIT: Initialize with key-value pairs
I don't know if it made it into the standard library for C++11, but with you can accomplish this with boost::assign
std::unordered_map<string, string> myAssoc = boost::assign::map_list_of("key1", "value1")("key2", "value2");
EDIT 2: https://stackoverflow.com/a/340233/232574 shows map_list_of working on std::unordered_map