title: What is the correct way to return an 'Invalid Value' type in C++, without the use of pointers?
body: <p>I often use <code>-1</code> as the invalid value type when returning from a function, where the input yields incorrect output. For instance, writing an indexing function where the index is out of bounds, instead of throwing an exception, <code>-1</code> can be returned. But when writing a function that has negative values as possible return types, this technique does not work. What is the correct way to return an invalid type value in such instances?</p>
  
  <p>The technique I use mostly is to set the return type to be of type <code>*int</code>, and return a Pointer to <code>NULL</code>. But, that requires all return values to be of a pointer type, which seems like an extra overhead to the function. Is there an accepted standard for returning values in such cases?</p>