“析构函数中的 return 并不会直接返回调用者”,这句话您确定吗?我们可以显示调用析构函数来释放placement new构造的对象,在这种情况下不就是直接返回给用户了吗?[/quote]
不管是显示还是隐式调用,析构函数都是一样的,都不一定直接返回调用者,而是要先去析构成员和基类。
正因为如此它才是一个特殊的函数。
控制权回到析构函数的调用者的时候,所有的析构都已经结束。
12.4 Destructors
8 After executing the body of the destructor and destroying any automatic objects allocated within the body, a
destructor for class X calls the destructors for X’s direct non-variant non-static data members, the destructors
for X’s direct base classes and, if X is the type of the most derived class (12.6.2), its destructor calls the
destructors for X’s virtual base classes. All destructors are called as if they were referenced with a qualified
name, that is, ignoring any possible virtual overriding destructors in more derived classes. Bases and
members are destroyed in the reverse order of the completion of their constructor (see 12.6.2). A return
statement (6.6.3) in a destructor might not directly return to the caller; before transferring control to the
caller, the destructors for the members and bases are called. Destructors for elements of an array are called
in reverse order of their construction (see 12.6).