Address of a static variable
<p>I am trying to do a simple class to unique ID conversion. I am thinking about adding a static method:</p>

<pre><code>class A {
  static int const *GetId() {
    static int const id;
    return &amp;id;
  }
};
</code></pre>

<p>Each class would then be identified by unique <code>int const *</code>. Is this guaranteed to work? Will the returned pointer really be unique? Is there any better simpler solution?</p>

<p>I have also thought about pointer to <code>std::type_info</code>:</p>

<pre><code>class A {
  static std::type_info const *GetId() {
    return &amp;typeid(A);
  }
};
</code></pre>

<p>Is that better?</p>

<p><strong>Edit:</strong></p>

<p>I don't need to use the id for serialization. I only want to identify a small set of base classes and I want all subclasses of some class to have the same id</p>
