Skip to content
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

<format>: Always enable compile-time format string checking for wchar_t #4459

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stl/inc/format
Original file line number Diff line number Diff line change
Expand Up @@ -3682,7 +3682,7 @@ public:
template <class _Ty>
requires convertible_to<const _Ty&, basic_string_view<_CharT>>
consteval basic_format_string(const _Ty& _Str_val) : _Str(_Str_val) {
if (_Is_execution_charset_self_synchronizing()) {
if constexpr (!is_same_v<_CharT, char> || _Is_execution_charset_self_synchronizing()) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not is_same_v<_CharT, wchar_t>? That seems more direct to me.

Copy link
Contributor Author

@frederick-vs-ja frederick-vs-ja Mar 15, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My opinion was that !is_same_v<_CharT, char> would "automatically" support charN_t if formatting for them gets supported in the future.

(or is not char, if formatting for charN_t is supported in the future)

But this reason may be not strong enough.

using _Context = basic_format_context<back_insert_iterator<_Fmt_buffer<_CharT>>, _CharT>;
constexpr size_t _Num_args = sizeof...(_Args);
constexpr _Basic_format_arg_type _Arg_types[_Num_args > 0 ? _Num_args : 1] = {
Expand Down