Decent way to disallow virtual functions due to placement new usage
<p>What would be a decent approach to check at compile/run-time that a particular struct/class does not have any virtual functions. This check is required in order to ensure the proper byte alignment when doing <strong>placement new</strong>.</p>

<p>Having so much as a single virtual function will shift the entire data by a <em>vtable</em> pointer size, which will completely mess things up in conjunction with the placement new operator.</p>

<hr>

<p><strong>Some more details:</strong> I need something that works across all major compiler and platforms, e.g. VS2005, VC++10, GCC 4.5, and Sun Studio 12.1 on top of Windows, Linux, and Solaris.</p>

<p>Something that <em>is guaranteed to work</em> with the following scenario should suffice:</p>

<pre><code>struct A { char c; void m(); };
struct B : A { void m(); };
</code></pre>

<p>Should someone decide to make this change:</p>

<pre><code>struct A { char c; virtual void m(); };
struct B : A { void m(); };
</code></pre>

<p>It would be great to see a compile-time error that says <code>struct A must not contain virtual functions.</code></p>
