-
-
Notifications
You must be signed in to change notification settings - Fork 768
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ICU-22920 Avoid CTAD in Formattable's constructor. NFC #3344
base: main
Are you sure you want to change the base?
Conversation
This line uses CTAD on `pair`, when every other place in the codebase uses a function call to `make_pair` (and no other place uses CTAD on any class template at all). Assume this was unintentional, and fix it. warning: class template argument deduction is incompatible with C++ standards before C++17; for compatibility, use explicit type name 'std::pair<const Formattable *, int>' (aka 'pair<const icu_77::message2::Formattable *, int>') [-Wctad] Formattable(const Formattable* arr, int32_t len) : contents(std::pair(arr, len)) {} ^~~~~~~~~
This does not seem to apply, since ICU requires C++17:
|
We recently moved to requiring C++17, so older code won’t use these features, but consistency with legacy code is not a goal. |
Right, but given that every other place uses In this specific line, there is no difference between using This kind of difference-in-behavior extends to other STL types as well; e.g. Basically I'm saying that there's light visible between the set of constructs that physically compile in C++17 mode, and the set of constructs that are a good idea to write in a C++17 codebase; and IMO CTAD falls into that gap: I agree that it physically does compile (just like the return-by-const in #3343 physically compiles), but its usage increases the maintenance burden rather than decreasing it. IMO the best style guideline re CTAD is "simply never use it." Adopting #3344 would cause ICU to adhere to that guideline, since this is ICU's solitary use of CTAD at the moment (and, like I said, I think it was basically a typo in this case). (FYI: I noticed this solitary use when compiling ICU locally, only because I have configured my compiler to warn-by-default on any use of CTAD.) |
That may be your strongly-held opinion, but not necessarily ICU-TC’s—nor for that matter that of all of your fellow WG 21 experts (looking through the references you give, I come across https://reviews.llvm.org/D54565#1339926). As you note, in this case (and most other practical cases), |
Oh, for sure, if this code had used |
I just found that internally to Google, we have a brand new C++ “Tip of the Week It recommends using |
This line uses CTAD on
pair
, when every other place in the codebase uses a function call tomake_pair
(and no other place uses CTAD on any class template at all). Assume this was unintentional, and fix it.Checklist