boost::associative_property_map() compile error

 ̄綄美尐妖づ 提交于 2019-12-02 08:17:19

This:

boost::const_associative_property_map< std::map<std::string, std::string> > address_map(name2address);

declares a variable and initialize it by calling the constructor with name2address. You cannot do it in a class declaration you have to do it in the class ctor :

class Test{

 std::map<std::string, std::string> name2address;
 boost::const_associative_property_map< std::map<std::string, std::string> >
                  address_map;
public:
 Test() : address_map(name2address) {}
};

This should solve the compilation issue, but I'm not sure it is the best possible layout depending on how you will use Test after that.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!