I have:
T* p;
and I'd like to do:
p->~decltype(*p)();
However, it doesnt work.
p->~T();
does work, but it like to do it with decltype()
, if possible.
Error message:
error: expected class-name before 'decltype'
EDIT: use case
I'm trying to avoid the use of VLA for an array allocated on the stack using alloca + placement new of the array. After the placement new, the objects in the stack array need to be explicitly destroyed. I know how to solve the problem, I can do:
using T = ::std::remove_reference_t<decltype(*p)>;
p->~T();
But, I'm puzzled why this is necessary.
Aucun commentaire:
Enregistrer un commentaire