Re: [cpp] for_each中delete函数的适配问题
Chen Shuo
giantchen at gmail.com
Wed Dec 6 15:11:42 CST 2006
可以玩玩 lambda 表达式啥的。
On 12/6/06, li guojian <guojianlee at gmail.com> wrote:
> On 12/6/06, 苏亚 <su1981ya at 163.com> wrote:
> > 语句:
> > vector<CFuzzyShapeRule<T1>*> m_cpfsPosition;
> > 。。。。。。
> > for_each(m_cpfsPosition.begin(),m_cpfsPosition.end(), delete ); //(1) 或者
> > for_each(m_cpfsPosition.begin(),m_cpfsPosition.end(),ptr_fun( delete )
> > ); // (2)
> >
> > 错误:
> > no matching function for call to `ptr_fun(<type error>)'
> >
> > 这里delete不是一个函数,而是一个语句,所以没有办法适配。 那么请问,除了
> > 重新写一个函数来调用delete,如
> >
> > void delptr( T1* ptr )
> > {
> > delete ptr;
> > }
> > 还有没有什么方法直接使用这一类c++关键字,或对其进行适配?除了delete,还
> > 有很多如sizeof等?
> >
> > 请指教
> >
> > _______________________________________________
> > Cpp mailing list
> > Cpp at codingnow.com
> > http://codingnow.com/mailman/listinfo/cpp
> >
> 应该只有写函数的办法了,c++里没有匿名函数或匿名类的概念。相似的问题在
> java中可以使用内锨匿名的类的方法!
>
> _______________________________________________
> Cpp mailing list
> Cpp at codingnow.com
> http://codingnow.com/mailman/listinfo/cpp
>
More information about the Cpp
mailing list