destroying pointed-to object explicitly with decltype
<p>I have:</p>

<pre><code>T* p;
</code></pre>

<p>and I'd like to do:</p>

<pre><code>p-&gt;~decltype(*p)();
</code></pre>

<p>However, it doesnt work.</p>

<pre><code>p-&gt;~T();
</code></pre>

<p>does work, but it like to do it with <code>decltype()</code>, if possible.</p>

<p>Error message:</p>

<pre><code>error: expected class-name before 'decltype'
</code></pre>

<p>EDIT: use case</p>

<p>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:</p>

<pre><code>using T = ::std::remove_reference_t&lt;decltype(*p)&gt;;
p-&gt;~T();
</code></pre>

<p>But, I'm puzzled why this is necessary.</p>