Boost logo

Boost Users :

Subject: Re: [Boost-users] How to use property_map?
From: Jeremiah Willcock (jewillco_at_[hidden])
Date: 2010-04-07 10:47:09


On Wed, 7 Apr 2010, Yaohua Xiong wrote:

> 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)'

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.

-- Jeremiah Willcock


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