我boost::bimap
用来将整数映射到字符串:
typedef boost::bimap<int, std::string> ParamIDStrings;
typedef ParamIDStrings::value_type id_pair;
extern const ParamIDStrings paramIDStrings;
我正在尝试创建引用变量,以便可以编写如下代码:
paramIDStringsByID.at(5);
// Instead of having to remember which side is which:
paramIDStrings.left.at(5);
但是我很难解释Boost 文档,以了解什么是类型bimap::left
。
我试过了:
// Compiler throws error: invalid use of template-name 'boost::bimaps::bimap' without an argument list
boost::bimaps::bimap::left ¶mIDStringsByID = paramIDStrings.left;
// Compiler throws error: 'paramIDStrings' does not name a type
paramIDStrings::left_map ¶mIDStringsByID = paramIDStrings.left;
// Compiler throws error: invalid initialization of reference of type boost::bimaps::bimap<int, std::__cxx11::basic_string<char> >::left_map
boost::bimaps::bimap<int,std::string>::left_map &cParamIDStringsByID = cParamIDStrings.left;