Yes, the trick with coroutines looks interesting and promising.
 
Bary's proposal I will study carefully, but here is mine completely different one

 template<typename T> struct valstat final {
        T* value;
        std::errc status;
    };
    valstat<const char> FindUsersCity() noexcept
    {
        if (auto [contacts, errc] = GetOrOpenContactsServerConnection(); contacts)
        {
            if (auto [uid, errc] = contacts->GetUserId(); uid) {
                if (auto [geo, errc] = GetOrOpenGeoServerConnection(); geo) {
                    if (auto [uloc, errc] = geo->GetLocation(uid); uloc) {
                        return uloc->GetCityName();
                    }
                    else {
                        return { {}, errc };
                    }
                }
                else {
                    return { {}, errc };
                }
            }
            else {
                return { {}, errc };
            }
        }
        else {
            return { {}, errc };
        }
    }

To be perfectly honest, it is opposite to the early-return pattern: 1, 2  :)

--
Dmitry
Sent from gmail