简体   繁体   English

HipHop PHP将其转换为C ++后,关联数组是什么样的?

[英]What does an associative array look like after HipHop PHP converts it to C++?

What does an associative array look like after HipHop PHP converts it to C++? HipHop PHP将其转换为C ++后,关联数组是什么样的?

I was hoping someone that already compiled HipHop can tell me what this would look like: 我希望已经编译过HipHop的人可以告诉我这是什么样子:

$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 我不知道它是否进入了C ++ 11的标准库,但是可以通过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 编辑2: https : map_list_of显示map_list_ofstd::unordered_map

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM