1

//I am reading data from file and storing data into structure.Here "obj" is a object of structure.

Also note that my file have outer map key multiple times means when i am reading from file then some field of structure has common value and i am using that common value as a key of outer loop.

If I have only single value of outer key then it works fine but when more than one value of key then it fails.

typedef std::map<double,Order_Msg,std::greater<double> >InnerMap; typedef std::map<int, InnerMap> OuterMap; InnerMap buy_detailsmap; OuterMap buy_tokenmap; //one way buy_tokenmap.insert(make_pair(obj.token,InnerMap())); buy_detailsmap.insert(make_pair(obj.orderId,obj)); //another way buy_detailsmap.insert (std::pair<double,Order_Msg>(obj.orderId,obj)); buy_tokenmap.insert(std::make_pair(obj.token,buy_detailsmap)); 

I tried both but its not working properly.

1
  • 1
    Define "its not working properly" Commented Jun 11, 2015 at 10:19

1 Answer 1

2

It isn't clear why you need buy_detailsmap, as it is de-coupled from buy_detailsmap. Unless you really need insert's semantics, you could simply use operator[]:

buy_tokenmap[obj.token][obj.orderId] = obj; 
Sign up to request clarification or add additional context in comments.

1 Comment

True. Didn't answer the question, though!

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.