使用boost ::结合性地图的boost :: BIMAP接口 [英] Using boost::associative property map with boost::BIMAP interface
问题描述
我不能够实现升压关联属性映射接口,用于提振bimap的。
I am not able to implement associative property map interface of boost for a boost bimap.
我有一个bimap的如下,我尝试定义一个boost ::关联属性映射它。我想使用PUT和GET辅助功能为我的bimap的..在code是如下:
I have a bimap as follows and I try to define a boost::associative property map for it. I want to use Put and Get helper functions for my bimap.. the code is as follows:
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);
我得到一个编译错误为
I get a compile error as
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是通过属性映射支持。看<一个href=\"http://www.boost.org/doc/libs/1_55_0/libs/bimap/doc/html/boost_bimap/bimap_and_boost/boost_libraries_that_work_well_with_boost_bimap.html#boost_bimap.bimap_and_boost.boost_libraries_that_work_well_with_boost_bimap.boost_property_map\"相对=nofollow>这里文档。只是不知道如何将我使用关联属性映射它..如果我能为我的关联属性映射定义向左或向右bimap的,这也将被罚款。请建议。
I am aware, bimaps are supported through property maps. see here for documentation. Just wondering how would i use associative property map for it.. if i can define left or right bimap for my associative property map, that would also be fine. please suggest.
推荐答案
您需要告诉它的哪边的bimap的使用方法:
You need to tell it which side of the bimap to use:
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
So, see it Live on 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);
}
这篇关于使用boost ::结合性地图的boost :: BIMAP接口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!