2

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';
BoltClock
  • 700,868
  • 160
  • 1,392
  • 1,356
joels
  • 7,249
  • 11
  • 53
  • 94

1 Answers1

1
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

Community
  • 1
  • 1
Nick Strupat
  • 4,928
  • 4
  • 44
  • 56