Offset from member pointer without temporary instance
<p>I would like to get the offset of a standard layout member variable when provided with a poiner to that variable. I cannot use <code>offsetof</code> since I have a pointer and not a name.  The current code I have looks something like this, and I am wondering if there is a standards compliant way to get rid of the <code>dummy</code> variable.</p>

<pre><code>template&lt;class T&gt;
struct {
  ptrdiff_t get_offset( int (T::*mem) )
  {
    T dummy;
    return reinterpret_cast&lt;char*&gt;(&amp;(dummy.*mem)) 
      - reinterpret_cast&lt;char*&gt;(&amp;dummy);
  }
};
</code></pre>

<p>This function should only be callable with <code>int</code> member variable points (this is intentional).</p>

<p>I am quite certain that the compiler doesn't actually create the <code>dummy</code> variable but it'd still be nice if I could get rid of it. I can't use a null pointer since dereferencing null is not defined (though it probably works on all common compilers). A C++03 solution would be good, or a C++11 solution is also of interest (but not usable by me now).</p>

<p><em>NOTE: I'm already aware this is only standards compliant is T is a standard layout type.</em></p>
