-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
ergonomics of zstring usage #1821
Comments
Editors call: In C++20, could this be done with a deduction guide instead of removing the parameter? |
No. That only works when initializing a variable. In the first example, it already needs void lower(zstring s)
{
for (int i = 0; i < strlen(s); ++i) s[i] = tolower(s[i]);
} |
@JohelEGP that was a limitation in C++17, but C++20 added support for deduction guides in type aliases: (Disclaimer: No worries, we had to look this up too! According to cppreference.com, GCC and MSVC have implemented this feature, but Clang has not yet. It's still pretty new.) So the question above was to verify with @JordanMaples whether this would solve the problem -- and even if the answer is yes, then next we would have to decide whether to accept the C++20 dependency since both the Guidelines and the Microsoft GSL implementation don't generally cover/depend on C++20 yet. |
It doesn't work: https://godbolt.org/z/esYe68Ysn. |
My understanding is that this is asking to make |
Editors call: Thanks. Do we have data about whether the extra parameter is used in the field? |
Relaying from the GSL repo, Jordan reports:
|
Editors call: Thanks. We agree that the convenience alias should be convenient and doesn't need the extra template parameter, and the Guidelines already show So please change this template <std::size_t Extent = dynamic_extent> to just this using zstring = basic_zstring; which conforms to the usage in the Guidelines. We understand that's a breaking change for your users to remove the |
microsoft/GSL#992
Microsoft's gsl::zstring requires and empty angle brackets for use due to the Extent template parameter in the definitions of basic_zstring
Examples of
zstring
and friends in the Core Guidelines implies that thezstring
should be able to be instantiated without needing trailing angle brackets. Should Microsoft/GSL's definitions ofbasic_zstring
and all derived definitions remove the Extent parameterThe text was updated successfully, but these errors were encountered: