It's possible to return multiple types from a function in C++ by using exceptions! Unfortunately, it turns out that C++ exceptions are very slow. How slow? Well…
variant
andunion
both run in about 7msexn
runs in about 1010ms
So using exceptions as control flow in C++ is about 140x slower.
C++ unions are much faster actually, see https://gist.github.com/artemkin/4bc3aab3d5901bf2d7d8603c3a7f8834