-
Notifications
You must be signed in to change notification settings - Fork 1.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
Formatting thread::id
, stacktrace_entry
, and basic_stacktrace
#3861
Formatting thread::id
, stacktrace_entry
, and basic_stacktrace
#3861
Conversation
…e_entry` formatters
Could (Also, P2286R8 adds |
I agree, unifying those setters is necessary. I'd leave it for another PR though, since it would require editing another header ( |
struct _Fill_align_and_width_specs { // used by thread::id and stacktrace_entry formatters | ||
int _Width = -1; | ||
int _Dynamic_width_index = -1; | ||
_Fmt_align _Alignment = _Fmt_align::_None; | ||
uint8_t _Fill_length = 1; | ||
// At most one codepoint (so one char32_t or four utf-8 char8_t). | ||
_CharT _Fill[4 / sizeof(_CharT)] = {' '}; | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect this could be unified with _Basic_format_specs
and _Dynamic_format_specs
, I need to work out what that would actually look like though, and it probably requires nontrivial inheritance.
At first glance things look pretty good, I'll see if I can figure out how you might be able to eliminate all the duplicate specs setter code without changing a bunch of chrono stuff next week. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I'll validate and push changes...
tests/std/tests/VSO_0157762_feature_test_macros/test.compile.pass.cpp
Outdated
Show resolved
Hide resolved
thread::id
, stacktrace_entry
and basic_stacktrace
thread::id
, stacktrace_entry
, and basic_stacktrace
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In order to prevent the code duplication here we'd have to rearrange _Basic_format_specs
and _Dynamic_format_specs
, and I'm not sure we can do that without ABI impact.
If we want to unify things we could do something like:
template<class _CharT>
struct _Really_basic_format_specs {
int _Width = -1;
_Fmt_align _Alignment = _Fmt_align::_None;
uint8_t _Fill_length = 1;
// At most one codepoint (so one char32_t or four utf-8 char8_t).
_CharT _Fill[4 / sizeof(_CharT)] = {' '};
};
template <class _CharT>
struct _Basic_format_specs : _Really_basic_format_specs<_CharT> {
int _Precision = -1;
char _Type = '\0';
_Fmt_sign _Sgn = _Fmt_sign::_None;
bool _Alt = false;
bool _Localized = false;
bool _Leading_zero = false;
};
struct _Dynamic_width_format_specs {
int _Dynamic_width_index = -1;
};
// used by thread::id and stacktrace_entry formatters
template <class _CharT>
struct _Fill_align_and_width_specs : _Really_basic_format_specs<_CharT>, _Dynamic_width_format_specs { };
template <class _CharT>
struct _Dynamic_format_specs : _Basic_format_specs<_CharT>, _Dynamic_width_format_specs {
int _Dynamic_precision_index = -1;
};
The specs setter classes could be slightly refactored to use either CRTP or to just have a collection of static methods taking the specs to fill in as the first parameter (basically making the setter even closer to members of the specs classes).
Again, this changes the order of the specs members, and the spec class is included by-value as a member of all the formatters, which users are allowed to derive from. This is also a bigger refactor, so I'm comfortable leaving it for later.
That sounds like an unavoidably ABI-breaking change. Sounds like everyone's happy with a follow-up investigation; I suspect that no change will happen as a result. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
This comment was marked as resolved.
The failure appears to be consistently happening in |
I've pushed a defensive commit to use |
I'm mirroring this to the MSVC-internal repo - please notify me if any further changes are pushed. |
Thanks for implementing this feature! ⚙️ 😻 ✅ |
_Fill_align_and_width_specs
,_Fill_align_and_width_specs_setter
and_Fill_align_and_width_formatter
types. They are use by formatters that accept onlyfill-and-align
andwidth
fields (thread::id
andstacktrace_entry
in this PR).std::call_once
from<mutex>
to<xcall_once.h>
to avoid circular dependency. I hope this is OK.thread::id
,stacktrace_entry
andbasic_stacktrace
.operator<<(thread::id)
in all supported C++ modes. See LLVM-62073 for bug report and @mordante's rationale.thread::id
Andstacktrace
#3447.