Getting a class/struct object from the member pointer
<p>I have C++ structure as</p>

<pre><code>struct myStruct {
    int a;
    int b;
    int c;
}; 

myStruct b;
int *ptr = &amp;b.c;
</code></pre>

<p>How can I get myStruct object back from ptr?</p>

<p>(I know I can do this using pointer arithmatic like container_Of() in C. Basically something like </p>

<pre><code>reinterpret_cast&lt;myStruct*&gt;(reinterpret_cast&lt;char *&gt;(ptr) - offsetof(myStruct, c));
</code></pre>

<p>I am asking if there is any recommended/elegant way?)</p>
