title: C++ same function parameters with different return type
body: <p>I need to find some way to mock an overload of a function return type in C++.</p>
  
  <p>I know that there isn't a way to do that directly, but I'm hoping there's some out-of-the-box way around it.
  We're creating an API for users to work under, and they'll be passing in a data string that retrieves a value based on the string information. Those values are different types. In essence, we would like to let them do:</p>
  
  <pre><code>int = RetrieveValue(dataString1);
  double = RetrieveValue(dataString2);
  // Obviously, since they don't know the type, they wouldn't use int =.... It would be:
  AnotherFunction(RetrieveValue(dataString1)); // param of type int
  AnotherFunction(RetrieveValue(dataString2)); // param of type double
  </code></pre>
  
  <p>But that doesn't work in C++ (obviously).
  Right now, we're having it set up so that they call:</p>
  
  <pre><code>int = RetrieveValueInt(dataString1);
  double = RetrieveValueDouble(dataString2);
  </code></pre>
  
  <p>However, we don't want them to need to know what the type of their data string is.</p>
  
  <p>Unfortunately, we're not allowed to use external libraries, so no using Boost.</p>
  
  <p>Are there any ways we can get around this?</p>
  
  <p>Just to clarify, I understand that C++ can't natively do it. But there must be some way to get around it. For example, I thought about doing RetrieveValue(dataString1, GetType(dataString1)). That doesn't really fix anything, because GetType also can only have one return type. But I need something like that.</p>
  
  <p>I understand that this question has been asked before, but in a different sense. I can't use any of the obvious answers. I need something completely out-of-the-box for it to be useful to me, which was not the case with any of the answers in the other question asked.</p>