How would the following code be written correctly?
map< int, map< double, bool > > mymap;
mymap.insert( map< int, map< double, bool > >::value_type(50, map< double, bool >::value_type(0.1, false) ) );
How about this:
typedef map<double, bool> innerType;
map<int, innerType> outer;
innerType inner;
inner.insert(pair<double, bool>(1.0, false));
outer.insert(pair<int, innerType>(1, inner));
If C++11 is available to you (and your spacing indicates it is not):
mymap.insert({50, {{0.1,false}}});
Without C++11, typedef
is your friend, and see navono's answer. Personally, I would just use this:
mymap[50][0.1] = false;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.