【发布时间】:2010-12-14 15:13:40
【问题描述】:
正如我刚刚在in my other question 中学到的,我可以将composite_key 用于结构,它有一个std::vector 和一个整数。现在我的问题是:我可以以某种方式使用它来处理 hashed_indecies 吗?
这里有一个类似于THIS的例子:
struct unique_property
{
//the pair of int and std::vector<int> shall be unique
int my_int;
std::vector<int> my_vec;
};
typedef multi_index_container<
unique_property,
indexed_by<
hashed_unique< // indexed by my_int and every entry of my_vec
composite_key<
street_entry,
member<unique_property,int,&unique_property::my_int>,
member<unique_property,std::vector<int>,&unique_property::my_vec>
>
>,
random_access< >
>
> property_locator;
问题是(当然)std::vector<int> 不是合适的哈希键。我可以把这段代码放在一个优雅的包装器中(或类似的东西),以从my_vec 的每个条目中生成一个哈希键吗?
【问题讨论】:
标签: c++ boost vector multi-index