ttl::variant, placement new
<p>I'm using the variant type from the <a href="http://tinytl.sourceforge.net/" rel="nofollow">"Tiny Template Library"</a>. The Variant is defined as:</p>

<pre><code>template&lt; TTL_TPARAMS_DEF(TTL_MAX_TYPELIST_PARAMS, empty_type) &gt;
struct variant
{
    typedef variant this_t;
    typedef meta::typelist&lt; TTL_ARGS(TTL_MAX_TYPELIST_PARAMS) &gt; list;
    ...

    template&lt; typename T &gt;
    variant( const T&amp; r ) : which_(0), pnt_(0)
    {
        typedef meta::find_equivalent_type&lt;const T&amp;, list&gt; found;
        pnt_ = new(stor_.buf_) ttl::data_holder&lt;typename found::type&gt;(r);
        which_ = found::index;
    }
    ...
private:
    template&lt;int N&gt; 
    struct storage
    {
        union
        {
            ttl::data_holder_base dummy;  //hope to satisfy alignment settings
            char buf_[N];
        };
    };

    int which_;
    ttl::data_holder_base* pnt_;
    storage&lt; sizeof(ttl::data_holder&lt;typename list::largest_type&gt;) &gt; stor_;
    ....
};


struct data_holder_base {};

template&lt; typename T &gt;
struct data_holder : data_holder_base
{
    ...
    typedef const T&amp; param_type;

    T d;
    ...
    data_holder( param_type d_ ) : d(d_) {}
    ...
};
</code></pre>

<p>When I send an object of this type over the network and "reconstruct" it using "memcpy" it is obvious thet the pointer "pnt_" will point to Nirvana. Due to the fact that I know the type that is stored I try to rebuild the pointer "pnt_" using a cast:</p>

<pre><code>template&lt;typename T&gt;
inline void rebuild()
{
    pnt_ = reinterpret_cast&lt;ttl::data_holder&lt;T&gt;*&gt;(stor_.buf_); 
}
</code></pre>

<p>For the case I checked this example it works. But I don't know how the placement new (<code>pnt_ = new(stor_.buf_) ...</code>) is placing the object into <code>stor_.buf_</code>. 
Would it be required to store something like <code>std::distance(&amp;stor_.buf_[0], pnt_)</code> to find the object?</p>

<p>Or is there a different way to get <code>pnt_</code> back?</p>

<p>Thank you
  Mario</p>
