Reputation: 334
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) ) );
Upvotes: 1
Views: 121
Reputation: 103693
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;
Upvotes: 2
Reputation: 162
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));
Upvotes: 3