title: C++ Return double or int from function
body: <p>I have a function that takes the exact same args, but sometimes I'd like for it to return a double and other times I'd like for it to return an int. What's the proper way to do that? </p>
  
  <p>I could do function overloading, but the declarations of overloaded functions must differ from each other by the types and/or the number of arguments in the argument list. These would be identical so function overloading would not apply (I don't think).</p>
  
  <pre><code>double calc( int value, int add, double mult )
  {
       // Sometimes I want this to return int. Sometimes double.
       return (value + add) * mult;
  }
  </code></pre>
  
  <p>I'd rather not cast to int when that's the type I expect or write two functions (one for ints, the other for doubles). Thanks for any advice.</p>