相关疑难解决方法(0)

"放置新"有什么用途?

有没有人曾经使用过C++的"贴牌新品"?如果是这样,那该怎么办?在我看来,它只对内存映射硬件有用.

c++ memory-management placement-new new-operator

385
推荐指数
18
解决办法
16万
查看次数

新(这)意味着什么?

我发现这个代码示例用于研究:

T & T::operator=(T const & x)
{
  if (this != &x)
  {
    this->~T(); // destroy in place
    new (this) T(x); // construct in place
  }
  return *this;
}
Run Code Online (Sandbox Code Playgroud)

当我查看文档时,new没有带指针的版本.从而:

  1. 新(这)意味着什么?
  2. 它是干什么用的?
  3. 如果未在文档中列出,如何调用它?

c++

11
推荐指数
1
解决办法
1519
查看次数