S
Stuart Golodetz
Hi all,
Just feeling curious -- I know the following is ill-advised, but is it
actually formally illegal?
#include <iostream>
struct X
{
~X()
{
std::cout << "~X()\n";
}
};
int main()
{
X *x = new X;
//delete x;
x->~X();
:perator delete(x);
return 0;
}
It would certainly be legal in the context of *placement* new, but is
there a requirement in the standard that all "new"s are matched by
"delete"s, rather than "operator delete"s?
Cheers,
Stu
Just feeling curious -- I know the following is ill-advised, but is it
actually formally illegal?
#include <iostream>
struct X
{
~X()
{
std::cout << "~X()\n";
}
};
int main()
{
X *x = new X;
//delete x;
x->~X();
:perator delete(x);
return 0;
}
It would certainly be legal in the context of *placement* new, but is
there a requirement in the standard that all "new"s are matched by
"delete"s, rather than "operator delete"s?
Cheers,
Stu