我有以下代码:find()方法以提升bimap的问题
wxString getColorName(const wxColour& color)
{
typedef ColorComboBox::ColorMap::right_const_iterator ConstColorIterator;
ColorComboBox::ColorMap colorMap = ColorComboBox::getDefaultChoices();
ConstColorIterator it = colorMap.right.find(color);
return it != colorMap.right.end() ? it->second :
ColorComboBox::CUSTOM_COLOR;
}
其中颜色表定义
typedef boost::bimaps::bimap \
<wxString, boost::bimaps::vector_of<wxColour> > \
ColorMap;
和我不断收到长模板的错误,基本上说的查找功能不存在。但是
ColorMap::left_const_iterator it = choices_.left.find(GetValue());
编译得很好。
我有一个预感find函数只在某些集合类型的bimap中定义。我无法使用set_of wxColours,因为wxColour不具有可比性。 (这甚至意味着什么?)我也尝试将集合类型更改为list_of,但这也不起作用。我在使用bimap时的整个观点是,我可以以任何方式找到价值。我使用了错误的容器吗?是否有另一种可用于wxColour的集合类型,它允许我使用find函数?
编辑: 我最终创建了自己的容器类。
谢谢!你的回答很好,所以我提出了你的提议,即使我采用了另一种解决方案。 – Eva 2012-02-06 15:26:36