Functions used only for testing should be restricted to test-only usages with the ForTesting suffix. This is checked at presubmit time to ensure these functions are only called by test files.
Test-only constructors cannot have the ForTesting suffix. Instead, they should be declared protected with a test-only subclass, or private with a test-only friend class. They should be commented as For testing only.
Test-only free functions should generally live within a test_support target.
#if defined(UNIT_TEST) is problematic and discouraged.
When you derive from a base class, group any overriding functions in your header file in one labeled section. Use the override specifier on all these functions.
Prefer putting delegate classes in their own header files. Implementors of the delegate interface will often be included elsewhere, which will often cause more coupling with the header of the main class.
Don't use else after return.
Use size_t directly in preference to std::string::size_type and similar.
Be aware that size_t (object sizes and indices), off_t (file offsets), ptrdiff_t (the difference between two pointer values), intptr_t (an integer type large enough to hold the value of a pointer), uint32_t, uint64_t, and so on are not necessarily the same. Use the right type for your purpose.
Do not use unsigned types to mean “this value should never be < 0”. For that, use assertions or run-time checks (as appropriate).
Don't use std::wstring. Use base::string16 or base::FilePath instead. (Windows-specific code interfacing with system APIs using wstring and wchar_t can still use string16 and char16; it is safe to assume that these are equivalent to the “wide” types.)
Follow Google C++ casting conventions to convert arithmetic types when you know the conversion is safe. Use checked_cast<>() (from base/numerics/safe_conversions.h) when you need to enforce via CHECK() that the source value is in-range for the destination type. Use saturated_cast<>() (from the same file) if you instead wish to clamp out-of-range values.
Functions used only for testing should be restricted to test-only usages with the ForTesting suffix. This is checked at presubmit time to ensure these functions are only called by test files.When you derive from a base class, group any overriding functions in your header file in one labeled section. Use the override specifier on all these functions.
Don't use else after return.
When you derive from a base class, group any overriding functions in your header file in one labeled section. Use the override specifier on all these functions.I like this, for methods of the same class. In Chromium, we have a bunch of classes that implement multiple interfaces (for better or worse), and it's helpful to see where each of those come from. Admittedly, this is also (typically, depending on platform) available by codesearch, but that's not always the case, and I think it's a) very low cost b) somewhat good practice to group similar overridden methods together in a single class.Note: I don't think we need all overridden methods in one section, but think we could rephrase this that each overridden method must be prefixed. That is, if Bar overrides Foo, Bar should have `// Foo:` comment over overridden function (groups).
Don't use else after return.I personally think this is always good advice, and makes code generally more readable.
--
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 post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAAHOzFDDR5S85DB26xPO45PpZKEZpJz7C8T%3D-%2B0wv2VDeQFGxA%40mail.gmail.com.
Style arbiters,As part of Chrome's diversity & inclusion efforts, I'm trying to make onboarding for new team members easier. One way to help this a bit is to simplify the Chromium style guide; the fewer rules new team members have to remember and follow, the easier it is to ramp up.Accordingly, I'd like to propose a lot of simplifications. I could split these into separate threads, but I'm hoping one thread is easier to handle. Let me know if I'm wrong :)(1) Remove "Test-only Code" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#test_only-code ), which contains this text:
Functions used only for testing should be restricted to test-only usages with the
ForTestingsuffix. This is checked at presubmit time to ensure these functions are only called by test files.Test-only constructors cannot have the
ForTestingsuffix. Instead, they should be declared protected with a test-only subclass, or private with a test-only friend class. They should be commented asFor testing only.Test-only free functions should generally live within a test_support target.
#if defined(UNIT_TEST)is problematic and discouraged.The first bullet has some value. The second is a combination of obvious and overly-pedantic. The third is obscure and unimportant. The fourth is rarely attempted and probably doesn't need to be stated.
I don't think the value of the first bullet is sufficient to keep this section.(2) Remove the following bullets from the "Code formatting" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#code-formatting ):
When you derive from a base class, group any overriding functions in your header file in one labeled section. Use the override specifier on all these functions.
Prefer putting delegate classes in their own header files. Implementors of the delegate interface will often be included elsewhere, which will often cause more coupling with the header of the main class.
Don't use else after return.
These are all pedantic (save the bit about using the override specifier, which I think our tools enforce). Their benefit doesn't justify forcing people to learn and abide by them.
(3) Move the "Exporting symbols" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#exporting-symbols ) to the "Dos and Don'ts" page....or elsewhere; this is more a "how to" than a style rule and doesn't belong in this file.
(4) Remove the following bullets from the "Types" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#types ):
Use
size_tdirectly in preference tostd::string::size_typeand similar.Be aware that
size_t(object sizes and indices),off_t(file offsets),ptrdiff_t(the difference between two pointer values),intptr_t(an integer type large enough to hold the value of a pointer),uint32_t,uint64_t, and so on are not necessarily the same. Use the right type for your purpose.Do not use unsigned types to mean “this value should never be < 0”. For that, use assertions or run-time checks (as appropriate).
Don't use
std::wstring. Usebase::string16orbase::FilePathinstead. (Windows-specific code interfacing with system APIs usingwstringandwchar_tcan still usestring16andchar16; it is safe to assume that these are equivalent to the “wide” types.)The first is implicit in common usage, and if people really violated it, fine. The second isn't really a style rule. The third is redundant with the Google style guide. The fourth is hopefully unnecessary at this point with wstring being rare across the codebase.(5) Move the following bullet from the "Types" section to the "Dos and Don'ts" page:
Follow Google C++ casting conventions to convert arithmetic types when you know the conversion is safe. Use
checked_cast<>()(frombase/numerics/safe_conversions.h) when you need to enforce viaCHECK()that the source value is in-range for the destination type. Usesaturated_cast<>()(from the same file) if you instead wish to clamp out-of-range values.The first sentence is redundant with the Google style guide. The rest is more "how to do this well" than "style rule".(6) Consider moving the "Object ownership and calling conventions" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#object-ownership-and-calling-conventions ) to the "Dos and Don'ts" page.I'm not convinced this is "style rule" as much as "good advice". I'm less sure of this recommendation.(7) In the "Dos and Don'ts" page, rewrite sections 2 and 3 to be brief and imperative.These are the oldest sections in the doc and are very rambly (or in some cases obvious).(8) In the "Dos and Don'ts" section on const ( https://www.chromium.org/developers/coding-style/cpp-dos-and-donts#TOC-Use-const-correctly ), move everything but the TLDR to a separate document.This may well be interesting, but it detracts from "what should I be doing".PK
--
Style arbiters,As part of Chrome's diversity & inclusion efforts, I'm trying to make onboarding for new team members easier. One way to help this a bit is to simplify the Chromium style guide; the fewer rules new team members have to remember and follow, the easier it is to ramp up.Accordingly, I'd like to propose a lot of simplifications. I could split these into separate threads, but I'm hoping one thread is easier to handle. Let me know if I'm wrong :)(1) Remove "Test-only Code" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#test_only-code ), which contains this text:
Functions used only for testing should be restricted to test-only usages with the
ForTestingsuffix. This is checked at presubmit time to ensure these functions are only called by test files.Test-only constructors cannot have the
ForTestingsuffix. Instead, they should be declared protected with a test-only subclass, or private with a test-only friend class. They should be commented asFor testing only.Test-only free functions should generally live within a test_support target.
#if defined(UNIT_TEST)is problematic and discouraged.The first bullet has some value. The second is a combination of obvious and overly-pedantic. The third is obscure and unimportant. The fourth is rarely attempted and probably doesn't need to be stated.I don't think the value of the first bullet is sufficient to keep this section.
(2) Remove the following bullets from the "Code formatting" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#code-formatting ):
When you derive from a base class, group any overriding functions in your header file in one labeled section. Use the override specifier on all these functions.
Prefer putting delegate classes in their own header files. Implementors of the delegate interface will often be included elsewhere, which will often cause more coupling with the header of the main class.
Don't use else after return.
These are all pedantic (save the bit about using the override specifier, which I think our tools enforce). Their benefit doesn't justify forcing people to learn and abide by them.(3) Move the "Exporting symbols" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#exporting-symbols ) to the "Dos and Don'ts" page....or elsewhere; this is more a "how to" than a style rule and doesn't belong in this file.(4) Remove the following bullets from the "Types" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#types ):
Use
size_tdirectly in preference tostd::string::size_typeand similar.Be aware that
size_t(object sizes and indices),off_t(file offsets),ptrdiff_t(the difference between two pointer values),intptr_t(an integer type large enough to hold the value of a pointer),uint32_t,uint64_t, and so on are not necessarily the same. Use the right type for your purpose.Do not use unsigned types to mean “this value should never be < 0”. For that, use assertions or run-time checks (as appropriate).
Don't use
std::wstring. Usebase::string16orbase::FilePathinstead. (Windows-specific code interfacing with system APIs usingwstringandwchar_tcan still usestring16andchar16; it is safe to assume that these are equivalent to the “wide” types.)The first is implicit in common usage, and if people really violated it, fine. The second isn't really a style rule. The third is redundant with the Google style guide. The fourth is hopefully unnecessary at this point with wstring being rare across the codebase.(5) Move the following bullet from the "Types" section to the "Dos and Don'ts" page:
Follow Google C++ casting conventions to convert arithmetic types when you know the conversion is safe. Use
checked_cast<>()(frombase/numerics/safe_conversions.h) when you need to enforce viaCHECK()that the source value is in-range for the destination type. Usesaturated_cast<>()(from the same file) if you instead wish to clamp out-of-range values.The first sentence is redundant with the Google style guide. The rest is more "how to do this well" than "style rule".(6) Consider moving the "Object ownership and calling conventions" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#object-ownership-and-calling-conventions ) to the "Dos and Don'ts" page.I'm not convinced this is "style rule" as much as "good advice". I'm less sure of this recommendation.
(7) In the "Dos and Don'ts" page, rewrite sections 2 and 3 to be brief and imperative.These are the oldest sections in the doc and are very rambly (or in some cases obvious).(8) In the "Dos and Don'ts" section on const ( https://www.chromium.org/developers/coding-style/cpp-dos-and-donts#TOC-Use-const-correctly ), move everything but the TLDR to a separate document.This may well be interesting, but it detracts from "what should I be doing".PK
--
Style arbiters,As part of Chrome's diversity & inclusion efforts, I'm trying to make onboarding for new team members easier. One way to help this a bit is to simplify the Chromium style guide; the fewer rules new team members have to remember and follow, the easier it is to ramp up.Accordingly, I'd like to propose a lot of simplifications. I could split these into separate threads, but I'm hoping one thread is easier to handle. Let me know if I'm wrong :)(1) Remove "Test-only Code" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#test_only-code ), which contains this text:
Functions used only for testing should be restricted to test-only usages with the
ForTestingsuffix. This is checked at presubmit time to ensure these functions are only called by test files.
Test-only constructors cannot have the
ForTestingsuffix. Instead, they should be declared protected with a test-only subclass, or private with a test-only friend class. They should be commented asFor testing only.
Test-only free functions should generally live within a test_support target.
#if defined(UNIT_TEST)is problematic and discouraged.
The first bullet has some value. The second is a combination of obvious and overly-pedantic. The third is obscure and unimportant. The fourth is rarely attempted and probably doesn't need to be stated.
I don't think the value of the first bullet is sufficient to keep this section.
(2) Remove the following bullets from the "Code formatting" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#code-formatting ):
When you derive from a base class, group any overriding functions in your header file in one labeled section. Use the override specifier on all these functions.
Prefer putting delegate classes in their own header files. Implementors of the delegate interface will often be included elsewhere, which will often cause more coupling with the header of the main class.
Don't use else after return.
These are all pedantic (save the bit about using the override specifier, which I think our tools enforce). Their benefit doesn't justify forcing people to learn and abide by them.
(3) Move the "Exporting symbols" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#exporting-symbols ) to the "Dos and Don'ts" page....or elsewhere; this is more a "how to" than a style rule and doesn't belong in this file.
(4) Remove the following bullets from the "Types" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#types ):
Use
size_tdirectly in preference tostd::string::size_typeand similar.
Be aware that
size_t(object sizes and indices),off_t(file offsets),ptrdiff_t(the difference between two pointer values),intptr_t(an integer type large enough to hold the value of a pointer),uint32_t,uint64_t, and so on are not necessarily the same. Use the right type for your purpose.
Do not use unsigned types to mean “this value should never be < 0”. For that, use assertions or run-time checks (as appropriate).
Don't use
std::wstring. Usebase::string16orbase::FilePathinstead. (Windows-specific code interfacing with system APIs usingwstringandwchar_tcan still usestring16andchar16; it is safe to assume that these are equivalent to the “wide” types.)
The first is implicit in common usage, and if people really violated it, fine. The second isn't really a style rule. The third is redundant with the Google style guide. The fourth is hopefully unnecessary at this point with wstring being rare across the codebase. Rules like this are important to keep things consistent, as a forcing function when it is violated to validate the effort to switch to back into conformance.
(5) Move the following bullet from the "Types" section to the "Dos and Don'ts" page:
Follow Google C++ casting conventions to convert arithmetic types when you know the conversion is safe. Use
checked_cast<>()(frombase/numerics/safe_conversions.h) when you need to enforce viaCHECK()that the source value is in-range for the destination type. Usesaturated_cast<>()(from the same file) if you instead wish to clamp out-of-range values.The first sentence is redundant with the Google style guide. The rest is more "how to do this well" than "style rule".
(6) Consider moving the "Object ownership and calling conventions" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#object-ownership-and-calling-conventions ) to the "Dos and Don'ts" page.I'm not convinced this is "style rule" as much as "good advice". I'm less sure of this recommendation.
(7) In the "Dos and Don'ts" page, rewrite sections 2 and 3 to be brief and imperative.These are the oldest sections in the doc and are very rambly (or in some cases obvious).
(8) In the "Dos and Don'ts" section on const ( https://www.chromium.org/developers/coding-style/cpp-dos-and-donts#TOC-Use-const-correctly ), move everything but the TLDR to a separate document.This may well be interesting, but it detracts from "what should I be doing".
size_t x = 1L << shift_amount;
I understand that off_t, uint32_t, and uint64_t will (necessarily) not always be the same size as size_t, but do we support any platforms where size_t, ptrdiff_t, and intptr_t are different sizes? Different signed/unsigned yes, but different sizes?A more common error that I see is the assumption that sizeof(long) == sizeof(void*). This is true on all platforms except 64-bit Windows and is a somewhat common source of errors there. In particular:size_t x = 1L << shift_amount;
is broken. 1LL works on all known platforms. static_cast<size_t>(1) is more precise but is painfully verbose.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/79a67719-dc00-4b65-a6c3-d9d0780c8d0e%40chromium.org.
| Karl Wiberg | Software Engineer | kwi...@google.com | +46 70 696 1024 |
(1) Remove "Test-only Code" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#test_only-code ), which contains this text:
Functions used only for testing should be restricted to test-only usages with the
ForTestingsuffix. This is checked at presubmit time to ensure these functions are only called by test files.
Test-only constructors cannot have the
ForTestingsuffix. Instead, they should be declared protected with a test-only subclass, or private with a test-only friend class. They should be commented asFor testing only.
Test-only free functions should generally live within a test_support target.
#if defined(UNIT_TEST)is problematic and discouraged.
(2) Remove the following bullets from the "Code formatting" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#code-formatting ):
When you derive from a base class, group any overriding functions in your header file in one labeled section. Use the override specifier on all these functions.
Prefer putting delegate classes in their own header files. Implementors of the delegate interface will often be included elsewhere, which will often cause more coupling with the header of the main class.
Don't use else after return.
(3) Move the "Exporting symbols" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#exporting-symbols ) to the "Dos and Don'ts" page.
(4) Remove the following bullets from the "Types" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#types ):
Use
size_tdirectly in preference tostd::string::size_typeand similar.Be aware that
size_t(object sizes and indices),off_t(file offsets),ptrdiff_t(the difference between two pointer values),intptr_t(an integer type large enough to hold the value of a pointer),uint32_t,uint64_t, and so on are not necessarily the same. Use the right type for your purpose.Do not use unsigned types to mean “this value should never be < 0”. For that, use assertions or run-time checks (as appropriate).
<stdint.h>, e.g. uint32_t.
- Don't use
std::wstring. Usebase::string16orbase::FilePathinstead. (Windows-specific code interfacing with system APIs usingwstringandwchar_tcan still usestring16andchar16; it is safe to assume that these are equivalent to the “wide” types.)
(5) Move the following bullet from the "Types" section to the "Dos and Don'ts" page:
Follow Google C++ casting conventions to convert arithmetic types when you know the conversion is safe. Use
checked_cast<>()(frombase/numerics/safe_conversions.h) when you need to enforce viaCHECK()that the source value is in-range for the destination type. Usesaturated_cast<>()(from the same file) if you instead wish to clamp out-of-range values.The first sentence is redundant with the Google style guide. The rest is more "how to do this well" than "style rule".
(6) Consider moving the "Object ownership and calling conventions" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#object-ownership-and-calling-conventions ) to the "Dos and Don'ts" page.I'm not convinced this is "style rule" as much as "good advice". I'm less sure of this recommendation.
(7) In the "Dos and Don'ts" page, rewrite sections 2 and 3 to be brief and imperative.These are the oldest sections in the doc and are very rambly (or in some cases obvious).(8) In the "Dos and Don'ts" section on const ( https://www.chromium.org/developers/coding-style/cpp-dos-and-donts#TOC-Use-const-correctly ), move everything but the TLDR to a separate document.This may well be interesting, but it detracts from "what should I be doing".
--
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 post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAAHOzFBGWAH1c8VqxOpxXPRs6tc3F9emO%3DWPa4uz-%3DLgv_a1Tg%40mail.gmail.com.
Jan Wilken Dörrie
Software Engineer
jdoe...@google.com
+49 89 839300973
Google Germany GmbH
Erika-Mann-Straße 33
80636 München
Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
Registergericht und -nummer: Hamburg, HRB 86891
Sitz der Gesellschaft: Hamburg
Diese E-Mail ist vertraulich. Falls sie diese fälschlicherweise erhalten haben sollten, leiten Sie diese bitte nicht an jemand anderes weiter, löschen Sie alle Kopien und Anhänge davon und lassen Sie mich bitte wissen, dass die E-Mail an die falsche Person gesendet wurde.
This e-mail is confidential. If you received this communication by mistake, please don't forward it to anyone else, please erase all copies and attachments, and please let me know that it has gone to the wrong person.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CALB5StZN1RzEPJAjWO61ZVc21WA7UZAcePD50icOb8WPhzV_%3Dw%40mail.gmail.com.
On Thu, Nov 22, 2018 at 3:46 AM Jan Wilken Dörrie <jdoe...@chromium.org> wrote:Early this year there was a discussion around this on chromium-dev, out of which the COMPONENT_EXPORT macro and base/component_export.h was born. This obsoletes the various FOO_EXPORT macros, which should be replaced by COMPONENT_EXPORT(FOO). All of this, including the deprecated method, is documented here: https://chromium.googlesource.com/chromium/src/+/master/docs/component_build.mdThus I vote to simply remove this section from the style guide, make an effort to replace the various FOO_EXPORTs we still have, and add a link to docs/component_build.md in base/component_export.h.This is is a bit of a thread derail, but the new component_export.h isn't universally loved, e.g. https://chromium-review.googlesource.com/c/chromium/src/+/1259242/3/ui/gfx/geometry_skia_export.h#1
(4) Remove the following bullets from the "Types" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#types ):
Use
size_tdirectly in preference tostd::string::size_typeand similar.Be aware that
size_t(object sizes and indices),off_t(file offsets),ptrdiff_t(the difference between two pointer values),intptr_t(an integer type large enough to hold the value of a pointer),uint32_t,uint64_t, and so on are not necessarily the same. Use the right type for your purpose.Do not use unsigned types to mean “this value should never be < 0”. For that, use assertions or run-time checks (as appropriate).
These didn't have a lot of support. Dana suggested the second should perhaps go in some tips somewhere, and there was a tangential discussion about constant initialization. I think this second bullet is more obvious than a lot of the existing stuff in the Dos and Don'ts page, so I think it's OK to just drop these. The other part of my reaction is cynicism: I've committed many dozens of CLs to fix incorrect size_t usage, and people still get it wrong all the time (including senior people who will defend their behavior if called on it), so I'm skeptical of the value of any of our existing wording :(
Plan: Drop these.Also (and sorry for throwing this in at a late stage), I think we should drop this bullet as redundant with the Google style guide:
- In cases where the exact size of the type matters (e.g. a 32-bit pixel value, a bitmask, or a counter that has to be a particular width), use one of the sized types from
<stdint.h>, e.g.uint32_t.Plan: Drop this, pending feedback.
- Don't use
std::wstring. Usebase::string16orbase::FilePathinstead. (Windows-specific code interfacing with system APIs usingwstringandwchar_tcan still usestring16andchar16; it is safe to assume that these are equivalent to the “wide” types.)Nico and Dana both suggested keeping this.Plan: Keep this.(5) Move the following bullet from the "Types" section to the "Dos and Don'ts" page:
Follow Google C++ casting conventions to convert arithmetic types when you know the conversion is safe. Use
checked_cast<>()(frombase/numerics/safe_conversions.h) when you need to enforce viaCHECK()that the source value is in-range for the destination type. Usesaturated_cast<>()(from the same file) if you instead wish to clamp out-of-range values.The first sentence is redundant with the Google style guide. The rest is more "how to do this well" than "style rule".Dana noted that as an extension to a style rule, this probably belongs in the style guide itself. Fair enough.Plan: Keep this.(6) Consider moving the "Object ownership and calling conventions" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#object-ownership-and-calling-conventions ) to the "Dos and Don'ts" page.I'm not convinced this is "style rule" as much as "good advice". I'm less sure of this recommendation.Gab and Dana both noted that the content here is valuable. I agree, I just worry that this is a ton of detail for the style guide.Plan: Keep this.(7) In the "Dos and Don'ts" page, rewrite sections 2 and 3 to be brief and imperative.These are the oldest sections in the doc and are very rambly (or in some cases obvious).(8) In the "Dos and Don'ts" section on const ( https://www.chromium.org/developers/coding-style/cpp-dos-and-donts#TOC-Use-const-correctly ), move everything but the TLDR to a separate document.This may well be interesting, but it detracts from "what should I be doing".+1s from Dana on these.Plan: Do these.PK
--
On Wed, Nov 21, 2018 at 7:06 PM 'Peter Kasting' via cxx <c...@chromium.org> wrote:(3) Move the "Exporting symbols" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#exporting-symbols ) to the "Dos and Don'ts" page.Dana noted that this is a Chrome-ism that can be hard to figure out. I agree, and I think we should document this. I still don't think that makes it a "style rule", however, more "something you may need to know to get your code working" (and Jeremy seems to agree). So I still think this should be moved. I don't love the Dos and Don'ts page as a destination, but I like it better than leaving it here. The other option would be to put this in markdown and link it from somewhere, maybe with a comment in the code on the various files that define the export macros?Plan: Move this, pending feedback.I think these are both interesting ideas but less discoverable for new folks. I'd still vote to keep this where it is until a better place could be found.
(4) Remove the following bullets from the "Types" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#types ):
Use
size_tdirectly in preference tostd::string::size_typeand similar.Be aware that
size_t(object sizes and indices),off_t(file offsets),ptrdiff_t(the difference between two pointer values),intptr_t(an integer type large enough to hold the value of a pointer),uint32_t,uint64_t, and so on are not necessarily the same. Use the right type for your purpose.Do not use unsigned types to mean “this value should never be < 0”. For that, use assertions or run-time checks (as appropriate).
These didn't have a lot of support. Dana suggested the second should perhaps go in some tips somewhere, and there was a tangential discussion about constant initialization. I think this second bullet is more obvious than a lot of the existing stuff in the Dos and Don'ts page, so I think it's OK to just drop these. The other part of my reaction is cynicism: I've committed many dozens of CLs to fix incorrect size_t usage, and people still get it wrong all the time (including senior people who will defend their behavior if called on it), so I'm skeptical of the value of any of our existing wording :(Perhaps the wording could be improved, or citations could be added to more details? If it's not useful enough to link to in situations where this comes up, then maybe it's worth investing in some better wording, since it sounds like it comes up often.
On Mon, Nov 26, 2018 at 8:03 AM <dan...@chromium.org> wrote:On Wed, Nov 21, 2018 at 7:06 PM 'Peter Kasting' via cxx <c...@chromium.org> wrote:(3) Move the "Exporting symbols" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#exporting-symbols ) to the "Dos and Don'ts" page.Dana noted that this is a Chrome-ism that can be hard to figure out. I agree, and I think we should document this. I still don't think that makes it a "style rule", however, more "something you may need to know to get your code working" (and Jeremy seems to agree). So I still think this should be moved. I don't love the Dos and Don'ts page as a destination, but I like it better than leaving it here. The other option would be to put this in markdown and link it from somewhere, maybe with a comment in the code on the various files that define the export macros?Plan: Move this, pending feedback.I think these are both interesting ideas but less discoverable for new folks. I'd still vote to keep this where it is until a better place could be found.My concern here is that this is one of many, many pieces of info you might need to know about the codebase during the course of your work, and by no means the most important. I've needed to add export macros to things maybe three times;
new people are unlikely to need it straight off, as it's only necessary when adding new classes/APIs to core headers,
and only undiscoverable when doing so in a brand new header file.
Those factors select against new team members running into this. Meanwhile, more important, widely-used, and needed-by-new folks stuff like "a guide to the geometry classes" or "all the different ways to do integral type conversions" or "what the heck are the various URL types, when do I use them, and how do I safely format them for use or display" are not in the style guide (rightfully so IMO).
To me the style guide should be "the stuff you really need to know before you write a single patch". It should be limited to issues of style, not issues of general documentation of how to write code in Chromium. And it should be short enough and widespread enough to be memorized by every author and reviewer in Chrome, because everyone is expected to uphold it in every review. So every word matters (and there are a lot of words in this section).
If those are reasonable limitations to place on the style guide, then I think this clearly should go elsewhere on dev.chromium.org, along with those other things I mentioned and many more. Having comprehensive, searchable, organized, up-to-date documentation would be a great boon (and a huge amount of work). But at least for starters, we could move this to a page linked from http://dev.chromium.org/developers/how-tos , or agree to deprecate the individual EXPORT macros in favor of the component export stuff and put this in markdown linked from that header file. I'm willing to do either of those. I just don't want to leave this here -- I think it has large cost and small benefit in this particular location.
Maybe I'm way off. Other people can feel free to weigh in.(4) Remove the following bullets from the "Types" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#types ):
Use
size_tdirectly in preference tostd::string::size_typeand similar.Be aware that
size_t(object sizes and indices),off_t(file offsets),ptrdiff_t(the difference between two pointer values),intptr_t(an integer type large enough to hold the value of a pointer),uint32_t,uint64_t, and so on are not necessarily the same. Use the right type for your purpose.Do not use unsigned types to mean “this value should never be < 0”. For that, use assertions or run-time checks (as appropriate).
These didn't have a lot of support. Dana suggested the second should perhaps go in some tips somewhere, and there was a tangential discussion about constant initialization. I think this second bullet is more obvious than a lot of the existing stuff in the Dos and Don'ts page, so I think it's OK to just drop these. The other part of my reaction is cynicism: I've committed many dozens of CLs to fix incorrect size_t usage, and people still get it wrong all the time (including senior people who will defend their behavior if called on it), so I'm skeptical of the value of any of our existing wording :(Perhaps the wording could be improved, or citations could be added to more details? If it's not useful enough to link to in situations where this comes up, then maybe it's worth investing in some better wording, since it sounds like it comes up often.We're still leaving a variety of other bullets; I think the value of these particular ones is very low. The only thing I'd occasionally want to tell people is that there's a semantic difference between e.g. size_t and uint64_t, but that's really already covered by the stuff we're leaving in.
On Mon, Nov 26, 2018 at 2:17 PM Peter Kasting <pkas...@google.com> wrote:On Mon, Nov 26, 2018 at 8:03 AM <dan...@chromium.org> wrote:On Wed, Nov 21, 2018 at 7:06 PM 'Peter Kasting' via cxx <c...@chromium.org> wrote:(3) Move the "Exporting symbols" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#exporting-symbols ) to the "Dos and Don'ts" page.Dana noted that this is a Chrome-ism that can be hard to figure out. I agree, and I think we should document this. I still don't think that makes it a "style rule", however, more "something you may need to know to get your code working" (and Jeremy seems to agree). So I still think this should be moved. I don't love the Dos and Don'ts page as a destination, but I like it better than leaving it here. The other option would be to put this in markdown and link it from somewhere, maybe with a comment in the code on the various files that define the export macros?Plan: Move this, pending feedback.I think these are both interesting ideas but less discoverable for new folks. I'd still vote to keep this where it is until a better place could be found.My concern here is that this is one of many, many pieces of info you might need to know about the codebase during the course of your work, and by no means the most important. I've needed to add export macros to things maybe three times;This was surprising but maybe related to the area of the code we each work in. Every class in most parts of chrome outside of content/ (and chrome/ ?) require export in order for the unit tests to use them. content/ does special build things in component build, though so avoids it FBOFW.
To me the style guide should be "the stuff you really need to know before you write a single patch". It should be limited to issues of style, not issues of general documentation of how to write code in Chromium. And it should be short enough and widespread enough to be memorized by every author and reviewer in Chrome, because everyone is expected to uphold it in every review. So every word matters (and there are a lot of words in this section).
Philosophically, I'm not sure this lines up with the Google Style Guide. It's a huge document that covers all corner cases of using C++. Many rules won't matter when you're writing your first CL, or 50th CL until you come across that scenario, similar to adding a new class, don't you think? For example https://google.github.io/styleguide/cppguide.html#Doing_Work_in_Constructors doesn't come up until writing a constructor.
On Mon, Nov 26, 2018 at 1:10 PM <dan...@chromium.org> wrote:On Mon, Nov 26, 2018 at 2:17 PM Peter Kasting <pkas...@google.com> wrote:On Mon, Nov 26, 2018 at 8:03 AM <dan...@chromium.org> wrote:On Wed, Nov 21, 2018 at 7:06 PM 'Peter Kasting' via cxx <c...@chromium.org> wrote:(3) Move the "Exporting symbols" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#exporting-symbols ) to the "Dos and Don'ts" page.Dana noted that this is a Chrome-ism that can be hard to figure out. I agree, and I think we should document this. I still don't think that makes it a "style rule", however, more "something you may need to know to get your code working" (and Jeremy seems to agree). So I still think this should be moved. I don't love the Dos and Don'ts page as a destination, but I like it better than leaving it here. The other option would be to put this in markdown and link it from somewhere, maybe with a comment in the code on the various files that define the export macros?Plan: Move this, pending feedback.I think these are both interesting ideas but less discoverable for new folks. I'd still vote to keep this where it is until a better place could be found.My concern here is that this is one of many, many pieces of info you might need to know about the codebase during the course of your work, and by no means the most important. I've needed to add export macros to things maybe three times;This was surprising but maybe related to the area of the code we each work in. Every class in most parts of chrome outside of content/ (and chrome/ ?) require export in order for the unit tests to use them. content/ does special build things in component build, though so avoids it FBOFW.I had no idea this was used so commonly outside content/ and chrome/. (I thought it wasn't needed for components/ unittests either but maybe I'm wrong.)That elevates the degree to which I think people should be told about this, but I still don't think this goes in the style guide. We have some onboarding docs, maybe this should go there?Seems like we have two different axes -- whether this is important for people to find out, and whether it's about style specifically. I'm claiming "not style and thus doesn't go here no matter how important", but it's not clear to me how much you (or others) agree. You've convinced me that there's a meaningful population for which "important" is true (though it's a subpopoulation rather than everyone -- the number of folks working on chrome/ and content/ is still pretty large).
To me the style guide should be "the stuff you really need to know before you write a single patch". It should be limited to issues of style, not issues of general documentation of how to write code in Chromium. And it should be short enough and widespread enough to be memorized by every author and reviewer in Chrome, because everyone is expected to uphold it in every review. So every word matters (and there are a lot of words in this section).Philosophically, I'm not sure this lines up with the Google Style Guide. It's a huge document that covers all corner cases of using C++. Many rules won't matter when you're writing your first CL, or 50th CL until you come across that scenario, similar to adding a new class, don't you think? For example https://google.github.io/styleguide/cppguide.html#Doing_Work_in_Constructors doesn't come up until writing a constructor.Here's the style guide's comment on its philosophy:"Style rules should pull their weightThe benefit of a style rule must be large enough to justify asking all of our engineers to remember it. The benefit is measured relative to the codebase we would get without the rule, so a rule against a very harmful practice may still have a small benefit if people are unlikely to do it anyway. This principle mostly explains the rules we don’t have, rather than the rules we do: for example, goto contravenes many of the following principles, but is already vanishingly rare, so the Style Guide doesn’t discuss it."I don't know whether the Google style guide manages to uphold this philosophy, but perhaps that helps guide us here?
--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 post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAAHOzFD0jgCJ2MpKFUQ9n0w2KhEWo-Q6dguXE_Ox9eM1ReKShg%40mail.gmail.com.
Style arbiters,As part of Chrome's diversity & inclusion efforts, I'm trying to make onboarding for new team members easier. One way to help this a bit is to simplify the Chromium style guide; the fewer rules new team members have to remember and follow, the easier it is to ramp up.Accordingly, I'd like to propose a lot of simplifications. I could split these into separate threads, but I'm hoping one thread is easier to handle. Let me know if I'm wrong :)(1) Remove "Test-only Code" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#test_only-code ), which contains this text:
Functions used only for testing should be restricted to test-only usages with the
ForTestingsuffix. This is checked at presubmit time to ensure these functions are only called by test files.Test-only constructors cannot have the
ForTestingsuffix. Instead, they should be declared protected with a test-only subclass, or private with a test-only friend class. They should be commented asFor testing only.Test-only free functions should generally live within a test_support target.
#if defined(UNIT_TEST)is problematic and discouraged.The first bullet has some value. The second is a combination of obvious and overly-pedantic. The third is obscure and unimportant. The fourth is rarely attempted and probably doesn't need to be stated.I don't think the value of the first bullet is sufficient to keep this section.(2) Remove the following bullets from the "Code formatting" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#code-formatting ):
When you derive from a base class, group any overriding functions in your header file in one labeled section. Use the override specifier on all these functions.
Prefer putting delegate classes in their own header files. Implementors of the delegate interface will often be included elsewhere, which will often cause more coupling with the header of the main class.
Don't use else after return.
These are all pedantic (save the bit about using the override specifier, which I think our tools enforce). Their benefit doesn't justify forcing people to learn and abide by them.(3) Move the "Exporting symbols" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#exporting-symbols ) to the "Dos and Don'ts" page....or elsewhere; this is more a "how to" than a style rule and doesn't belong in this file.(4) Remove the following bullets from the "Types" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#types ):
Use
size_tdirectly in preference tostd::string::size_typeand similar.Be aware that
size_t(object sizes and indices),off_t(file offsets),ptrdiff_t(the difference between two pointer values),intptr_t(an integer type large enough to hold the value of a pointer),uint32_t,uint64_t, and so on are not necessarily the same. Use the right type for your purpose.Do not use unsigned types to mean “this value should never be < 0”. For that, use assertions or run-time checks (as appropriate).
Don't use
std::wstring. Usebase::string16orbase::FilePathinstead. (Windows-specific code interfacing with system APIs usingwstringandwchar_tcan still usestring16andchar16; it is safe to assume that these are equivalent to the “wide” types.)The first is implicit in common usage, and if people really violated it, fine. The second isn't really a style rule. The third is redundant with the Google style guide. The fourth is hopefully unnecessary at this point with wstring being rare across the codebase.(5) Move the following bullet from the "Types" section to the "Dos and Don'ts" page:
Follow Google C++ casting conventions to convert arithmetic types when you know the conversion is safe. Use
checked_cast<>()(frombase/numerics/safe_conversions.h) when you need to enforce viaCHECK()that the source value is in-range for the destination type. Usesaturated_cast<>()(from the same file) if you instead wish to clamp out-of-range values.The first sentence is redundant with the Google style guide. The rest is more "how to do this well" than "style rule".(6) Consider moving the "Object ownership and calling conventions" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#object-ownership-and-calling-conventions ) to the "Dos and Don'ts" page.I'm not convinced this is "style rule" as much as "good advice". I'm less sure of this recommendation.(7) In the "Dos and Don'ts" page, rewrite sections 2 and 3 to be brief and imperative.These are the oldest sections in the doc and are very rambly (or in some cases obvious).(8) In the "Dos and Don'ts" section on const ( https://www.chromium.org/developers/coding-style/cpp-dos-and-donts#TOC-Use-const-correctly ), move everything but the TLDR to a separate document.This may well be interesting, but it detracts from "what should I be doing".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 post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAAHOzFDDR5S85DB26xPO45PpZKEZpJz7C8T%3D-%2B0wv2VDeQFGxA%40mail.gmail.com.
On Tue, Nov 27, 2018 at 7:39 PM 'Peter Kasting' via cxx <c...@chromium.org> wrote:I had no idea this was used so commonly outside content/ and chrome/. (I thought it wasn't needed for components/ unittests either but maybe I'm wrong.)That elevates the degree to which I think people should be told about this, but I still don't think this goes in the style guide. We have some onboarding docs, maybe this should go there?Seems like we have two different axes -- whether this is important for people to find out, and whether it's about style specifically. I'm claiming "not style and thus doesn't go here no matter how important", but it's not clear to me how much you (or others) agree. You've convinced me that there's a meaningful population for which "important" is true (though it's a subpopoulation rather than everyone -- the number of folks working on chrome/ and content/ is still pretty large).Yeah to me this feels like "style" in that it's a rule that must be followed and is part of how you write correct C++ for our project. In the Google style guide it even mentions similar under Windows Code, though says to use DLLIMPORT/DLLEXPORT. So I think you could argue this is an extension of the Google style guide even.
--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 post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAAHOzFAa%2B3zV6V49c6Mx0N1SmokMuoMqHzpsbJq6j3Q34YyXUQ%40mail.gmail.com.
On Tue, Dec 4, 2018 at 10:25 PM 'Peter Kasting' via cxx <c...@chromium.org> wrote:On Wed, Nov 28, 2018 at 10:08 AM <dan...@chromium.org> wrote:On Tue, Nov 27, 2018 at 7:39 PM 'Peter Kasting' via cxx <c...@chromium.org> wrote:I had no idea this was used so commonly outside content/ and chrome/. (I thought it wasn't needed for components/ unittests either but maybe I'm wrong.)That elevates the degree to which I think people should be told about this, but I still don't think this goes in the style guide. We have some onboarding docs, maybe this should go there?Seems like we have two different axes -- whether this is important for people to find out, and whether it's about style specifically. I'm claiming "not style and thus doesn't go here no matter how important", but it's not clear to me how much you (or others) agree. You've convinced me that there's a meaningful population for which "important" is true (though it's a subpopoulation rather than everyone -- the number of folks working on chrome/ and content/ is still pretty large).Yeah to me this feels like "style" in that it's a rule that must be followed and is part of how you write correct C++ for our project. In the Google style guide it even mentions similar under Windows Code, though says to use DLLIMPORT/DLLEXPORT. So I think you could argue this is an extension of the Google style guide even.Well... I read that section as giving this as a passing example of using macros to wrap nonstandard extensions rather than saying when or how you should actually use said extensions. So I don't really buy your argument there.But I still feel like I'd like to get more perspectives to triangulate between us. Does anyone else have an opinion? If not, I think I need to write up what it would look like to move this into some onboarding doc so as to have a concrete comparison proposal to discuss.
--This specific section seems to have two pieces of information:1. What exporting does, with examples of some functions being available outside of the dll and some not being available, and2. What to name the export macro and where to place the macro in the code (between class and ClassName, etc).My interpretation is that 2. belongs in style, but 1. does not. My bar for this judgment is the following: If my code does not compile or does not run, then I shouldn't need to look in a style guide for an explanation why. If my code works just fine but I'm unsure about the best way to name something or how to format it or where to place it, then I should read the style guide.It's possible to leave a small bit (2.) in the style guide and move the rest (1.) to the Dos and Don'ts... If that's not a good option, then I'd prefer to have this section somewhere outside of the style guide, naming and all.Thanks for reading,Vlad--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 post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CAAHOzFAa%2B3zV6V49c6Mx0N1SmokMuoMqHzpsbJq6j3Q34YyXUQ%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 post to this group, send email to c...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CADsXd2MMq6Dt%3DWyh0uK%2B7hs-5ZeyD-DGUT6MYwzkrDg8eA9DLw%40mail.gmail.com.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/cxx/CACuR13cMZqZb9MUrGB%2BB-DGDJ8gBb2XzewoT3LNTUY1Urkx-MA%40mail.gmail.com.
(Maybe the agreed-upon changes could be landed without blocking that on agreement on the export macros question. That way, we get (most of) the simplifications sooner :-) )
On Fri, Nov 9, 2018 at 5:04 PM Peter Kasting <pkas...@google.com> wrote:(1) Remove "Test-only Code" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#test_only-code ), which contains this text:
Functions used only for testing should be restricted to test-only usages with the
ForTestingsuffix. This is checked at presubmit time to ensure these functions are only called by test files.
Plan: Keep this bullet in the style guide.
Test-only constructors cannot have the
ForTestingsuffix. Instead, they should be declared protected with a test-only subclass, or private with a test-only friend class. They should be commented asFor testing only.
Plan: Drop this, pending feedback.
Test-only free functions should generally live within a test_support target.
Plan: Drop this.
#if defined(UNIT_TEST)is problematic and discouraged.
Plan: Drop this.
(2) Remove the following bullets from the "Code formatting" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#code-formatting ):
When you derive from a base class, group any overriding functions in your header file in one labeled section. Use the override specifier on all these functions.
"In class declarations, group all function overrides within each access control section, with one labeled group per parent class."
Plan: Replace with modified wording, pending feedback.
Prefer putting delegate classes in their own header files. Implementors of the delegate interface will often be included elsewhere, which will often cause more coupling with the header of the main class.
Don't use else after return.
These didn't have significant support.Plan: Drop these.
(3) Move the "Exporting symbols" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#exporting-symbols ) to the "Dos and Don'ts" page.Dana noted that this is a Chrome-ism that can be hard to figure out. I agree, and I think we should document this. I still don't think that makes it a "style rule", however, more "something you may need to know to get your code working" (and Jeremy seems to agree). So I still think this should be moved. I don't love the Dos and Don'ts page as a destination, but I like it better than leaving it here. The other option would be to put this in markdown and link it from somewhere, maybe with a comment in the code on the various files that define the export macros?Plan: Move this, pending feedback.
(4) Remove the following bullets from the "Types" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#types ):
Use
size_tdirectly in preference tostd::string::size_typeand similar.Be aware that
size_t(object sizes and indices),off_t(file offsets),ptrdiff_t(the difference between two pointer values),intptr_t(an integer type large enough to hold the value of a pointer),uint32_t,uint64_t, and so on are not necessarily the same. Use the right type for your purpose.Do not use unsigned types to mean “this value should never be < 0”. For that, use assertions or run-time checks (as appropriate).
Plan: Drop these.
- In cases where the exact size of the type matters (e.g. a 32-bit pixel value, a bitmask, or a counter that has to be a particular width), use one of the sized types from
<stdint.h>, e.g.uint32_t.Plan: Drop this, pending feedback.
- Don't use
std::wstring. Usebase::string16orbase::FilePathinstead. (Windows-specific code interfacing with system APIs usingwstringandwchar_tcan still usestring16andchar16; it is safe to assume that these are equivalent to the “wide” types.)
Plan: Keep this.
(5) Move the following bullet from the "Types" section to the "Dos and Don'ts" page:
Follow Google C++ casting conventions to convert arithmetic types when you know the conversion is safe. Use
checked_cast<>()(frombase/numerics/safe_conversions.h) when you need to enforce viaCHECK()that the source value is in-range for the destination type. Usesaturated_cast<>()(from the same file) if you instead wish to clamp out-of-range values.
Plan: Keep this.
(6) Consider moving the "Object ownership and calling conventions" section ( https://chromium.googlesource.com/chromium/src/+/master/styleguide/c++/c++.md#object-ownership-and-calling-conventions ) to the "Dos and Don'ts" page.
Plan: Keep this.
(7) In the "Dos and Don'ts" page, rewrite sections 2 and 3 to be brief and imperative.
(8) In the "Dos and Don'ts" section on const ( https://www.chromium.org/developers/coding-style/cpp-dos-and-donts#TOC-Use-const-correctly ), move everything but the TLDR to a separate document.
Plan: Do these.
--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/CAAHOzFDdHu%3DdRByd74vTTmG%3Drr1ONRjL39TbqRp%3Dww0FAyOj6A%40mail.gmail.com.