Flexibly convert between string, int, double for C++ Variant Class
<p>I'm implementing a variant class (not using boost) and I'm wondering how you'd handle the case where you'd store any of string, integer, or double and automatically convert it accordingly to desired type through ToString(), ToInt(), or ToDouble().</p>

<p>For example,</p>

<pre><code>Variant a = 7;
cout &lt;&lt; "The answer is" + a.ToString() &lt;&lt; endl; // should print "The answer is 7"
a = "7.4";
double &amp;b = a.ToDouble();
b += 1;
cout &lt;&lt; a.ToString() &lt;&lt; endl; // should print 8.4
</code></pre>

<p><code>ToXXX</code> functions should return the reference of the type that you want to convert to. Right now, I have the code where it can return the same type as it was initially assigned to( <code>Variant a = Int(7); a.ToInt()</code> works) and raise exception when the assigned type is different from the one that you want to convert to.</p>

<p>Sorry using boost isn't an option.</p>
