CUJ:标准库:Allocator能做什么?[17]

[入库:2005年8月18日] [更新:2007年3月24日]

本文简介:选择自 taodm 的 blog

 

  size_type max_size() const {

    return static_cast<size_type>(-1) / sizeof(t);

  }

 

  void construct(pointer p, const value_type& x) {

    new(p) value_type(x);

  }

  void destroy(pointer p) { p->~value_type(); }

 

private:

  void operator=(const malloc_allocator&);

};

 

template<> class malloc_allocator<void>

{

  typedef void        value_type;

  typedef void*       pointer;

  typedef const void* const_pointer;

 

  template <class u>

  struct rebind { typedef malloc_allocator<u> other; };

};

 

 

template <class t>

inline bool operator==(const malloc_allocator<t>&,

                       const malloc_allocator<t>&) {

  return true;

}

 

template <class t>

本文关键:CUJ、allocator、STL、Matt Austern
 

本站最佳浏览方式为 分辨率 1024x768 IE 6.0(或更高版本的 IE浏览器)

go top