transform 转换大小写
摘要:首先看一下transform的原型template < class InputIterator, class OutputIterator, class UnaryOperator > OutputIterator transform ( InputIterator first1, InputIterator last1, OutputIterator result, UnaryOperator op );template < class InputIterator1, class InputIterator2, c...
阅读全文
访问者模式的一个简单应用
摘要:在实际项目中,需要对一个图像做很多次转换,此时就可能会频繁的增加或修改一部分代码,这个时候用访问者模式是一个较为简单的解决方案例如:#ifndef IMG_H#define IMG_Htemplate<class T>class Image{ typedef T _Color_Type; //... template<class RET,class TransformFun> RET Transform(Transform const & fun){//要多次调用此函数对本图像进行一些转换. return fun(*this); }}#endif而在另一个文件中
阅读全文