摘要:
template<class ForwIter, class Predicate>ForwIter std::remove_if(ForwIter beg, ForwIter end, Predicate op){ beg=find_if(beg,end,op); if(beg==end){ return beg; } else { ForwIter next=beg; return remove_copy_if(++next,end,beg,op);}调用find_if时,op创建一个副本给find_if,在find_if函数内部不管怎么变,在... 阅读全文
posted @ 2010-08-21 14:03
xiazdong
阅读(276)
评论(0)
推荐(0)
摘要:
1.node-based container such as <lists><sets><multisets><maps><multimaps> 如果节点构造失败,则不变2.关联式容器插入多个元素时,失败无法恢复原状3.erase操作肯定成功4.以array为基础的如vector,deque,安插失败,不恢复原状。 阅读全文
posted @ 2010-08-21 11:25
xiazdong
阅读(140)
评论(0)
推荐(0)
摘要:
当将一个数A插入容器,只是将A的副本插入容器,因此不能在不同容器内管理同一个对象。 //value语义解决方法:插入的是指针(尽量是智能型指针)即可 //reference语义 阅读全文
posted @ 2010-08-21 11:03
xiazdong
阅读(198)
评论(0)
推荐(0)
摘要:
仿函数保存状态方法:1.reference 【显式声明】(略)2.for_eachfor_each 返回op的现在状态namespace std{ template<class Iterator,class Operation> Operation for_each(Iterator act, Iterator end,Operation op) { while(act!=end){ op(*act); ++act; } return op; ... 阅读全文
posted @ 2010-08-21 10:48
xiazdong
阅读(228)
评论(0)
推荐(0)