0

C++ styleguide: allow designated initializer.

They are allowed by the Google style guide, and used in Chrome.
https://groups.google.com/a/chromium.org/g/cxx/c/YTuYWSNOpS8/m/eyMr3XxrAgAJ

Nevertheless, it is a bit ambiguous, because of the chromium coding
style. Indeed, some developers interpret the sentence "C++20: Not yet
supported in Chromium" as an ban of the feature.

This patch make it explicit the Chromium coding style do not contradict
the Google coding style here.

Bug: None
Change-Id: I8571c9d74e1e22525574c9609c6d07d022c3592e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4301374
Reviewed-by: Peter Kasting <pkasting@chromium.org>
Reviewed-by: danakj <danakj@chromium.org>
Commit-Queue: Arthur Sonzogni <arthursonzogni@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1112689}
This commit is contained in:
Arthur Sonzogni
2023-03-03 09:41:45 +00:00
committed by Chromium LUCI CQ
parent 04e4120362
commit d8517c959b

@@ -32,7 +32,8 @@ The current status of existing standards and Abseil features is:
* **C++14:** _Default allowed_
* **C++17:** Initially supported December 23, 2021; see allowed/banned/TBD
features below
* **C++20:** _Not yet supported in Chromium_
* **C++20:** _Not yet supported in Chromium_, with the exception of
[designated initializers](https://google.github.io/styleguide/cppguide.html#Designated_initializers)
* **C++23:** _Not yet standardized_
* **Abseil:** _Default allowed; see banned/TBD features below_
* absl::AnyInvocable: Initially supported June 20, 2022
@@ -1506,6 +1507,26 @@ contexts.
None
***
## C++20 Allowed Language Features {#core-allowlist-20}
### Designated initializers <sup>[allowed]</sup>
```c++
struct S { int x = 1; int y = 2; }
S s{ .y = 3 }; // OK, s.x == 1, s.y == 3
```
**Description:** Allows explicit initialization of subsets of aggregate members
at construction.
**Documentation:**
[Designated initializers](https://en.cppreference.com/w/cpp/language/aggregate_initialization#Designated_initializers)
**Notes:**
*** promo
None
***
## Abseil Banned Library Features {#absl-blocklist}
The following Abseil library features are not allowed in the Chromium codebase.