我是这种地图:
{'V', 'O'}
{'v', 'о'}
{'H', 'В'}
{'h', 'в'}
{'W', 'Ш'}
{'w', 'ш'}
但在VS 2005中,当我竞选
时const static std::map<char, wchar_t> mapDimLetters =
{
{'V', 'O'},
{'v', 'о'},
{'H', 'В'},
{'h', 'в'},
{'W', 'Ш'},
{'w', 'ш'},
}
测试
error C2552: 'mapDimLetters' : non-aggregates cannot be initialized with initializer list
1> 'std::map<_Kty,_Ty>' : Types with a base are not aggregate
1> with
1> [
1> _Kty=char,
1> _Ty=wchar_t
1> ]
error C2078: too many initializers
我该如何解决?或者,以最有效的方式定义具有常量已知预先值的地图的最佳方法是什么?
答案 0 :(得分:2)
为什么不使用boost assign?
#include <map>
#include "boost/assign.hpp"
using namespace boost::assign;
const std::map<char, wchar_t> mapDimLetters = map_list_of
('V','O')
('v','o')
('H','B')
('h','b');