|
Boost Users : |
Subject: Re: [Boost-users] How to use property_map?
From: Yaohua Xiong (xiongyaohua_at_[hidden])
Date: 2010-04-07 19:54:09
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;
}
-- Yaohua Xiong Traffic and Transportation Engineering College, Tongji Univ. Cao An Road 4800#, Jia Ding District, Shanghai, China
Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net