
On Thu, 8 Apr 2010, Yaohua Xiong wrote:
Hi, Jeremiah. Thanks for your reply.
The declaration "PMap map();" declares a function named "map" that returns an object of type "PMap". Just use the original form "PMap map;" if you want to declare an actual map.
You are right. What a stupid mistake I make, probably I've been writing Python for too long time :-). As for the original form do you have some speculation on why it's crashing?
After I surf on the Internet for a while, I found a solution to the crashing problem by change the program into:
#include <iostream> #include <map> #include <string> #include <boost/property_map/property_map.hpp> using std::string; using boost::put; using boost::get;
int main() { typedef std::map<std::string, int> Map; typedef boost::associative_property_map<Map> PMap;
Map tmp; PMap map(tmp); put(map, string("acc"), 1); get(map, string("acc"));
return EXIT_SUCCESS; }
The associative_property_map just contains a reference to a container, not an actual container. Look at <URL:http://www.boost.org/doc/libs/1_42_0/libs/property_map/doc/associative_property_map.html> for more information (see the top paragraph). -- Jeremiah Willcock