我无法实现boost的联想属性映射接口。
我有一个bimap,如下所示,我尝试为它定义一个boost::associative属性映射。我想为我的bimap使用Put和Get助手函数。守则如下:
typedef boost::bimaps::bimap< vertex_descriptor_t, size_t > vd_idx_bimap_t;
typedef boost::associative_property_map< vd_idx_bimap_t > asso_vd_idx_bimap_t;
// define bimap
vd_idx_bimap_t my_bimap;
asso_vd_idx_bimap_t my_asso_bimap(my_bimap);我得到一个编译错误,因为
error: no type named âsecond_typeâ in âboost::bimaps::container_adaptor::container_adaptor<boost::multi_index::detail::ordered_index<boost::m.... goes on long list. 我知道,通过属性映射支持bimaps。有关文档,请参见这里。只是想知道我该如何使用关联属性映射。如果我可以为我的关联属性映射定义左或右bimap,那也很好。请建议一下。
发布于 2014-02-09 14:55:58
您需要告诉它使用bimap的哪个端:
typedef boost::associative_property_map<vd_idx_bimap_t::left_map> asso_vd_idx_bimap_t;
// OR
typedef boost::associative_property_map<vd_idx_bimap_t::right_map> asso_vd_idx_bimap_t;所以,看看吧,住在Coliru
#include <boost/bimap.hpp>
#include <boost/property_map/property_map.hpp>
#include <iostream>
using namespace boost;
int main()
{
typedef int vertex_descriptor_t;
typedef boost::bimaps::bimap< vertex_descriptor_t, size_t > vd_idx_bimap_t;
typedef boost::associative_property_map<vd_idx_bimap_t::left_map> asso_vd_idx_bimap_t;
// define bimap
vd_idx_bimap_t my_bimap;
asso_vd_idx_bimap_t my_asso_bimap(my_bimap.left);
} https://stackoverflow.com/questions/21654594
复制相似问题