首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用boost::关联属性映射和boost::BIMAP接口

使用boost::关联属性映射和boost::BIMAP接口
EN

Stack Overflow用户
提问于 2014-02-09 02:47:03
回答 1查看 262关注 0票数 2

我无法实现boost的联想属性映射接口。

我有一个bimap,如下所示,我尝试为它定义一个boost::associative属性映射。我想为我的bimap使用Put和Get助手函数。守则如下:

代码语言:javascript
复制
 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);

我得到一个编译错误,因为

代码语言:javascript
复制
  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,那也很好。请建议一下。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-09 14:55:58

您需要告诉它使用bimap的哪个端

代码语言:javascript
复制
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

代码语言:javascript
复制
#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);
} 
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/21654594

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档