How to convert a sorted std::list of std::pair to a std::map

前端 未结 3 1202
南方客
南方客 2021-01-12 09:27

I have got a std::list< std::pair >, which I know is sorted according to the std::string element.

Since I

3条回答
  •  孤街浪徒
    2021-01-12 09:33

    I would just iterate on the list and insert every pair into a map or use the neat method Luther Blissett has described.
    The fact that I don't get what are you trying to do means it will either result in unreadable code or that you are way off.
    Why are you doing it this way?
    Can you change the code to return a map to you instead of a list in the first place?

提交回复
热议问题