Originally Posted by jlou
Some ideas:
- Change the return type to a pointer so that you can return null.
- Add a parameter to the function in which the found item will be placed, and return a bool indicating whether the find was successful.
- Throw an exception if a failed search is an exceptional situation.
- Identify a value for the type that acts as a not found (e.g. -1 or 0 for integers). This isn't so easy if you return a template type. This can also be done like the STL does it - the user can check the returned position against the position one past the end of the list.
I like the second or fourth idea best.