--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAP_mGKojW-XjiLBdavuh4iKx56S92-oqzvQB-nssa6u_-SWwBw%40mail.gmail.com.
+1PK
--
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAAHOzFDRhOrsD0Z170XaQxLFsQ%3DPBesJqP3_xM%3DLYGz5U8K_Ng%40mail.gmail.com.
+1--On Fri, Dec 24, 2021 at 3:42 PM 'Peter Kasting' via cxx <c...@chromium.org> wrote:+1--PK
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAAHOzFDRhOrsD0Z170XaQxLFsQ%3DPBesJqP3_xM%3DLYGz5U8K_Ng%40mail.gmail.com.
You received this message because you are subscribed to the Google Groups "cxx" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cxx+uns...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAHq1K7QxJacN4%2Bt3nan5Rx%3D%2B7ZsVjye7H4oqbxGDgJ9%3DGH77VA%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAF3XrKqZamjG7e5RnSxCk8hNOnMX5eu78cC%2B-%3DEhvL74i9wscQ%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAAHOzFA1Xs%3DrzuhTHNofZogbAYUeGGa3V5e8X8Zy-yNxfNCnmg%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAF3XrKoZycAjvcujgpk6O-apnuFZpY0QXqLLu6sgA2%2Brj5Vrig%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAHtyhaTc7io9hw2TGMmi%3DgJb2tzkzCnLTndD%3Dp2PGEN3mc4W3g%40mail.gmail.com.
I have two questions about the CL:1. It replacesFontEnumerationStatus status;
base::ReadOnlySharedMemoryRegion region;
std::tie(status, region) = manager_sync_->EnumerateLocalFonts();withauto [status, region] = manager_sync_->EnumerateLocalFonts();How does this interact with the guidance of spelling out the type unless it's obvious (https://google.github.io/styleguide/cppguide.html#Type_deduction)?
2. In the same function, a few lines further down, it replacesstd::tie(status, region) = manager_sync_->EnumerateLocalFonts();withauto [status2, region2] = manager_sync_->EnumerateLocalFonts();(and then it replaces status and region with status2 and region2 in the following code.)Is introducing two new variables with a trailing `2` preferable over just calling tie() here?
On Fri, Jan 7, 2022 at 11:20 AM Nico Weber <tha...@chromium.org> wrote:I have two questions about the CL:1. It replacesFontEnumerationStatus status;
base::ReadOnlySharedMemoryRegion region;
std::tie(status, region) = manager_sync_->EnumerateLocalFonts();withauto [status, region] = manager_sync_->EnumerateLocalFonts();How does this interact with the guidance of spelling out the type unless it's obvious (https://google.github.io/styleguide/cppguide.html#Type_deduction)?That guidance does go on to give specific guidance for structured bindings that say that they're often a net readability win, so my reading of the upstream guide is that it thinks usage of structured bindings is OK even though they sacrifice type names, and the precise usage at each location is "judgement call".
On Mon, Jan 10, 2022 at 11:55 AM Peter Kasting <pkas...@google.com> wrote:On Fri, Jan 7, 2022 at 11:20 AM Nico Weber <tha...@chromium.org> wrote:I have two questions about the CL:1. It replacesFontEnumerationStatus status;
base::ReadOnlySharedMemoryRegion region;
std::tie(status, region) = manager_sync_->EnumerateLocalFonts();withauto [status, region] = manager_sync_->EnumerateLocalFonts();How does this interact with the guidance of spelling out the type unless it's obvious (https://google.github.io/styleguide/cppguide.html#Type_deduction)?That guidance does go on to give specific guidance for structured bindings that say that they're often a net readability win, so my reading of the upstream guide is that it thinks usage of structured bindings is OK even though they sacrifice type names, and the precise usage at each location is "judgement call".That's not my reading of the style guide (but maybe I'm reading it wrong). As far as I can tell, the structure is (represented as a nested list):Type DeductionDefinition: Here are contexts in which type deduction can or must be usedList of examples that includes, among other things, structured bindings. The examples describe how the features work but don't give style advice on them.Decision: "Use type deduction only to make the code clearer or safer, and do not use it merely to avoid the inconvenience of writing an explicit type. [...] These principles apply to all forms of type deduction, but the details vary, as described in the following sections."
auto
would not. Structured bindings are especially beneficial when the object is a pair or tuple..."