C++ Logo

std-proposals

Advanced search

Re: Initialisers in ternary operators

From: Dmitry Dmitry <dimanne_at_[hidden]>
Date: Sun, 13 Sep 2020 10:43:40 +0100
>
> std::optional<std::string> FindUsersCity(bool non_default) {
> return GetOrOpenContactsServerConnection()
> .transform([](auto&& contacts) { return contacts->GetUserId(); })
> .and_then([](auto&& uid) {
> return GetOrOpenGeoServerConnection().transform(
> [&uid](auto&& geo) { return geo->GetLocation(*uid); });
> })
> .transform([](auto&& uloc) { return uloc->GetCityName(); });
> }
>

Isn't it too low-level? How well does it *capture intent* and *how readable
it is*? I do not think I want to *transform* anything (I just want to have
a couple of checks)...

-- 
Dmitry
*Sent from gmail*

Received on 2020-09-13 04:44:10