Declare types without implicit conversion in C++
<p>I want to declare my own numeric types, exactly like unsigned int, but I do not want the types to be implicitly converted. I tried this first:
    typedef unsigned int firstID;
    typedef unsigned int secondID;</p>

<p>but this is no good as the two types are just synonyms for unsigned int, so are freely interchangable.</p>

<p>I'd like this to cause an error:</p>

<pre><code>firstID fid = 0;
secondID sid = fid; // no implicit conversion error
</code></pre>

<p>but this to be okay:</p>

<pre><code>firstID fid = 0;
secondID sid = static_cast&lt;secondID&gt;(fid); // no error
</code></pre>

<p>My reason is so that function arguments are strongly typed, eg:</p>

<pre><code>void f( firstID, secondID ); // instead of void f(unsigned int, unsigned int)
</code></pre>

<p>What is the mechanism I am looking for?</p>

<p>Thanks</p>

<p>Si</p>
