由买买提看人间百态

boards

本页内容为未名空间相应帖子的节选和存档,一周内的贴子最多显示50字,超过一周显示500字 访问原贴
Programming版 - STL里怎样得到map的某个键值对(pair)的指针?
相关主题
STL iterator的疑问stl的一个问题
C++11里list迭代器判空仍然知道具体的list对象吗?[合集] 如何得到一个指向STL元素的指针?
修改map的键值auto_ptr, algorithm 混用问题,大侠们救我。头疼死了!
讨论 找单链表倒数m的节点 (转载)容器里边放指针怎么办?
STL感觉实在太变态了interview question: (RB tree vs. hash table)
c++ template question:C++是给神仙用的语言
c++ interview: iterator 和 pointer区别?弱问c++ iterator 和 pointer区别
C++ vector 一边遍历一边删[新手]一直都把C++当Java写,有啥严重不妥?
相关话题的讨论汇总
话题: stl话题: pair话题: 指针话题: 键值话题: map
进入Programming版参与讨论
1 (共1页)
d******i
发帖数: 7160
1
好像所有的方法只能给出个迭代器,强制转为pair<>*是不行的。
那么是不是只要这个iterator不失效(在map里禁得住insert,delete的话),
就可以当做指针来用呢?
谢谢!
t****t
发帖数: 6806
2
&*iterator gives pointer. why do you need force conversion? and why do you
need pointer in the first place? (unless, of course, you are calling legacy
code --- but legacy code won't take pair<> anyway.)
when and how iterators are invalidated is clearly documented in STL.

【在 d******i 的大作中提到】
: 好像所有的方法只能给出个迭代器,强制转为pair<>*是不行的。
: 那么是不是只要这个iterator不失效(在map里禁得住insert,delete的话),
: 就可以当做指针来用呢?
: 谢谢!

1 (共1页)
进入Programming版参与讨论
相关主题
[新手]一直都把C++当Java写,有啥严重不妥?STL感觉实在太变态了
gprof和STL的问题c++ template question:
interview questionsc++ interview: iterator 和 pointer区别?
[合集] 很中肯的批评 STLC++ vector 一边遍历一边删
STL iterator的疑问stl的一个问题
C++11里list迭代器判空仍然知道具体的list对象吗?[合集] 如何得到一个指向STL元素的指针?
修改map的键值auto_ptr, algorithm 混用问题,大侠们救我。头疼死了!
讨论 找单链表倒数m的节点 (转载)容器里边放指针怎么办?
相关话题的讨论汇总
话题: stl话题: pair话题: 指针话题: 键值话题: map