std::pair<MAP::iterator,bool>用法,可用来判断插入式否成功
2016-05-12 10:02
501 查看
最近在工作中遇到MAP和PAIR的新用法,将Map.Insert()方法的返回值放入PAIR中,可通过判断PAIR的成员值来判断插入是否成功。例:std::pair<Map_t::iterator, bool> add(map.insert(std::pair<type::String, type::Unsigned0to4294967294>(PeerAddressToString()+PwIdToString(),cnt)));
</pre><pre class="cpp" name="code">声明一个add的PAIR类型的类,调用PAIR的构造函数,参数是Map.insert()方法返回的迭代器,可通过盘点add.second判断插入是否成功
std::pair<Map_t::iterator, bool> add(map.insert(std::pair<type::String, type::Unsigned0to4294967294>(erpsPeVer.PeerAddressToString()+erpsPeVer.PwIdToString(),cnt))); if(false == add.second) return false;
</pre><pre class="cpp" name="code"><span id="_xhe_cursor"></span>
相关文章推荐
- impdp failed with ORA-39002, ORA-31694 and ORA-31644
- Undefined symbols for architecture x86_64: ( linker command failed with exit code 1)
- ARPG游戏中怪物AI实现
- SVN中 “containing working copy admin area is missing” 问题
- Determining IP information for eth0... failed
- 线程控制-sigwait函数和相关函数解释
- loadrunner:Action.c(4): Error -27796: Failed to connect to server "192.168.66.3:8080": [10060] Connection timed out
- eerTyraniBafonoitazilaireSredroerPyfireV.331
- public static void main(String[] args)
- Failed to start LSB:Bring up/down networking(已解决)
- RAID详细介绍
- RAID详细介绍
- leetcode 196. Delete Duplicate Emails delete
- HDU 4391 Paint The Wall
- ARPG游戏中怪物AI实现
- 第五届山东省ACM angry_birds_again_and_again(积分)
- 172. Factorial Trailing Zeroes
- flask-mai发送邮件503,553错误
- LeetCode Container With Most Water (Two Pointers)
- selenium---邮件模板