How can I have a C++ function that returns different types depending on what the caller wants?
https://devblogs.microsoft.com/oldnewthing/20191106-00/?p=103066 [devblogs.microsoft.com]
2019-11-07 03:12
This is not allowed in C++. The return type of a function cannot be overloaded.
But Kenny Kerr taught me how to fake it. What you do is return an object that doesn’t yet know whether it’s a widget or doodad.
Related: https://devblogs.microsoft.com/oldnewthing/20191107-00/?p=103071