Does std::map::iterator return a copy of value or a value itself?

前端 未结 4 588
生来不讨喜
生来不讨喜 2021-02-03 23:25

I\'m trying to create a map inside a map:

typedef map inner_map;
typedef map outer_map;

Will I be ab

4条回答
  •  [愿得一人]
    2021-02-03 23:37

    The comment in stl_pair.h is misleading in this specific case.

    There will be no copy, since the map::iterator actually refers to the original data inside the map (the value_type, which itself is a pair), it’s not a copy. Thus iterator::second also refers to the original data.

提交回复
热议问题