摘要
本文讨论了C++中泛型编程(generic programming)与面向对象设计(object-oriented design)原则的冲突问题,并用实例——any_iterator,一个类型安全、适用于任何类型的C++遍历器——说明了类型擦除(type erasure)技术对此问题的解决办法。
The author discusses how the generic programming paradigm in C++ can lead to conflicts with object-oriented design principles.To address this problem,the author depicts a technique called'type erasure'which could be used to alleviate these conflicts.An in-depth example is presented,in which it covers any iterator,a type-safe,heterogeneous C++ iterator.
出处
《程序员》
2008年第3期88-92,8,共5页
Programmer