【发布时间】:2018-08-21 22:53:04
【问题描述】:
我有一个模板类(CrMultiIndex),它接收一个模板参数,一个 boost 多索引(GlobalHash)的定义。我使用 c++14
我需要一种将索引转换为标签(n_to_tag)的方法吗?并循环 CrMultiIndex ctor 或 Init 函数中的索引? 我最初的目的是循环索引并在初始化时使用 typeid(T).name() 生成标签名称字符串。所以我可以根据标签名称显示统计信息
我有模板类
template <typename KeysType, typename MultiIndexType>
class CrMultiIndex
{
std::vector<SrStatisticsByIndex> m_StatsByIndex;
public:
MultiIndexType *m_pMultiIndex=NULL;
CrMultiIndex()
{
m_pMultiIndex = new MultiIndexType(typename
MultiIndexType::ctor_args_list());
}
这里是boost多索引容器的定义:
typedef boost::multi_index::multi_index_container<
CrUsersKeys,
UsersKey_hash_indices/*,
bip::allocator<CrUsersKeys,bip::managed_shared_memory::segment_manager>*/
> GlobalHash;
代码在http://coliru.stacked-crooked.com/a/d97195a6e4bb7ad4
我在Find boost multi index Tag to index and number of indices问了一个类似的问题
【问题讨论】:
标签: c++ boost-mpl boost-multi-index