【发布时间】:2014-10-01 02:34:49
【问题描述】:
所以我构建了我的 boost::mpl::map 对象,其中包含一些键和类型的混合。我现在想实例化地图的一个实例,这样我就有了地图中每个type 的实例:
using namespace boost::mpl;
using MyMap = map<
pair<int, double>,
pair<double, double>,
pair<bool, int>>;
int main()
{
// create the map:
MyMap myMap;
// now I want a reference to the element indexed by "int"
using RefType = at<MyMap, int>::type&;
RefType myRef(myMap); // compile error!
}
我遇到的错误类似于:
错误:无法将 'MyMap {aka map<...>} 转换为 blarghh {aka int}
显然我应该得到某种“索引”值(也许是boost::mpl::map::order?)。那么如何实际访问(即获取引用)这些关联mpl 容器中的元素?另外,关于如何(具体地)完成此操作的文档在哪里?
【问题讨论】: