在下面的定义中:
template<class T, class A = allocator<T> >
class vector {
...
}
class A = allocator<T> 是什么意思?
default value of A is allocator<T>
在STL中,有一个专门用于处理各种内存分配细节的部分,叫allocator,而它也是一个template class。在
这个定义中,type A就代表了allocator<T>。
我正在分析STL的source code,如果你有什么疑问,可以和我一起讨论。noproblem_jyb@263.net
另外,我在china-pub上有一篇关于STL的文章,你有兴趣的话也可以看一下。
http://www.china-pub.com/computers/emook/1564/info.htm