h**o 发帖数: 548 | 1 知道可以这样:
typedef map mapType;
mapType data;
data["FontSize"] = 10;
怎样实现这个那?
data["type1"]["FontSize"] = 10;
data["type2"]["FontSize"] = 4; |
k**f 发帖数: 372 | 2
map
【在 h**o 的大作中提到】 : 知道可以这样: : typedef map mapType; : mapType data; : data["FontSize"] = 10; : 怎样实现这个那? : data["type1"]["FontSize"] = 10; : data["type2"]["FontSize"] = 4;
|
h**o 发帖数: 548 | 3 Thanks.
or
typedef pair key;
map;
【在 k**f 的大作中提到】 : : map
|
k**f 发帖数: 372 | 4
This does not support the usage you asked in the first post:
data["type1"]["FontSize"] = 10;
you may have to use
data[make_pair("type1", "FontSize")] = 10;
On top of this, you have to define operator "<" for pair.
【在 h**o 的大作中提到】 : Thanks. : or : typedef pair key; : map;
|
t****t 发帖数: 6806 | 5 there is default operator "<" for pair given T::operator< and U::
operator<
【在 k**f 的大作中提到】 : : This does not support the usage you asked in the first post: : data["type1"]["FontSize"] = 10; : you may have to use : data[make_pair("type1", "FontSize")] = 10; : On top of this, you have to define operator "<" for pair.
|
k**f 发帖数: 372 | 6
Good to know this. Thanks.
【在 t****t 的大作中提到】 : there is default operator "<" for pair given T::operator< and U:: : operator<
|