C++ 基础 - 定位new(placement new)
前言复习一下STL源码,记录一下知识点。template <class T1, class T2>inline void construct(T1* p, const T2& value) { new (p) T1(value); // placement new}placement newC++的new operator主要做了两件事:分配内存在分配的内存中构造对象而定位new(placement new)只做了一件事:在已有的地址上构造对象。placeme
原创
2021-05-19 18:39:24 ·
495 阅读 ·
1 评论