【问题标题】:Boost::multi_index_container with disparate key and element typesBoost::multi_index_container 具有不同的键和元素类型
【发布时间】:2021-06-24 16:30:16
【问题描述】:

是否可以对 boost::multi_index_container 中的键和元素使用不同类型的数据结构? GCC 让我编译这样的东西:

struct StructA {
  std::string name;
};

struct StructB {
  int primary;
  int secondary;
};

using mic = 
multi_index_container<
  StructA,
  indexed_by<
    composite_key< 
      StructB,
      member< StructB, int, StructB::primary >,
      member< StructB, int, StructB::secondary >
>>>;

首先,我不确定上面的代码是否违反了任何类型的 multi_index_container 用法。它当然可以使用不同的元素 (StructA) 和复合索引键 (StructB) 进行编译。其次,我如何插入/放置到这样的容器中?三、如何访问这样一个容器中的元素?

【问题讨论】:

    标签: c++ boost-multi-index


    【解决方案1】:

    认为这应该如何工作?

    【讨论】:

      猜你喜欢
      • 2021-04-25
      • 1970-01-01
      • 1970-01-01
      • 2010-12-14
      • 1970-01-01
      • 2013-09-14
      • 2018-12-11
      • 1970-01-01
      • 2013-01-13
      相关资源
      最近更新 更多