|
Boost Users : |
Subject: [Boost-users] How to use property_map?
From: Yaohua Xiong (xiongyaohua_at_[hidden])
Date: 2010-04-07 02:01:21
Hi,
I'm trying to figure out how to use property_map in boost graph, after
I reduce the problem to the minimal I still don't know what the
problem is. Can someone help with this? Thanks in advance.
Here is the simplified example:
#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;
PMap map;
put(map, string("acc"), 1);
get(map, string("acc"));
return EXIT_SUCCESS;
}
This version compiles OK with mingw 4.4, but crash when running. If I
make a change from "PMap map;" into "PMap map();" which I think is
equivalent, then this code fail to compile, and say
D:\myproject\test\boost_test\property_map\pp.cpp: In function 'int main()':
D:\myproject\test\boost_test\property_map\pp.cpp:15: error: no matching function
for call to 'put(main()::PMap (&)(), std::string, int)'
D:\myproject\test\boost_test\property_map\pp.cpp:16: error: no matching function
for call to 'get(main()::PMap (&)(), std::string)'
What's the problem is?
-- 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