在下面的定义中:
template<class T, class A = allocator<T> >
    class vector {
                     ...
                 }class A = allocator<T> 是什么意思?

解决方案 »

  1.   

    default value of A is allocator<T>
      

  2.   

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