Skip to content

Commit 6b60cc1

Browse files
Templatize parse, add missed _NODISCARD
1 parent 0277f64 commit 6b60cc1

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

stl/inc/__msvc_formatter.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,8 @@ _NODISCARD _FormatContext::iterator _Fill_align_and_width_formatter_format(_Form
421421
template <class _CharT>
422422
struct _Fill_align_and_width_formatter {
423423
public:
424-
_NODISCARD constexpr auto _Parse(basic_format_parse_context<_CharT>& _Parse_ctx) {
424+
template <class _ParseContext = basic_format_parse_context<_CharT>> // improves throughput, see GH-5003
425+
_NODISCARD constexpr _ParseContext::iterator _Parse(type_identity_t<_ParseContext&> _Parse_ctx) {
425426
return _STD _Fill_align_and_width_formatter_parse(_Specs, _Parse_ctx);
426427
}
427428

stl/inc/__msvc_ranges_tuple_formatter.hpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -898,12 +898,12 @@ struct _Range_specs : _Fill_align_and_width_specs<_CharT> {
898898

899899
// TRANSITION, VSO-1236041: Avoid declaring and defining member functions in different headers.
900900
template <class _Ty, class _CharT, class _ParseContext>
901-
constexpr _ParseContext::iterator _Range_formatter_parse(formatter<_Ty, _CharT>& _Underlying,
901+
_NODISCARD constexpr _ParseContext::iterator _Range_formatter_parse(formatter<_Ty, _CharT>& _Underlying,
902902
basic_string_view<_CharT>& _Separator, basic_string_view<_CharT>& _Opening_bracket,
903903
basic_string_view<_CharT>& _Closing_bracket, _Range_specs<_CharT>& _Specs, _ParseContext& _Ctx);
904904

905905
template <class _Ty, class _CharT, _RANGES input_range _Range, class _FormatContext>
906-
_FormatContext::iterator _Range_formatter_format(const formatter<_Ty, _CharT>& _Underlying,
906+
_NODISCARD _FormatContext::iterator _Range_formatter_format(const formatter<_Ty, _CharT>& _Underlying,
907907
basic_string_view<_CharT> _Separator, basic_string_view<_CharT> _Opening_bracket,
908908
basic_string_view<_CharT> _Closing_bracket, _Range&& _Rng, const _Range_specs<_CharT>& _Specs,
909909
_FormatContext& _Ctx);
@@ -1141,12 +1141,12 @@ struct _Adaptor_formatter_base {
11411141

11421142
// TRANSITION, VSO-1236041: Avoid declaring and defining member functions in different headers.
11431143
template <class... _Types, class _CharT, class _ParseContext>
1144-
constexpr _ParseContext::iterator _Tuple_formatter_parse(tuple<formatter<_Types, _CharT>...>& _Underlying,
1144+
_NODISCARD constexpr _ParseContext::iterator _Tuple_formatter_parse(tuple<formatter<_Types, _CharT>...>& _Underlying,
11451145
basic_string_view<_CharT>& _Separator, basic_string_view<_CharT>& _Opening_bracket,
11461146
basic_string_view<_CharT>& _Closing_bracket, _Fill_align_and_width_specs<_CharT>& _Specs, _ParseContext& _Ctx);
11471147

11481148
template <class... _Types, class _CharT, class _FormatContext, class... _ArgTypes>
1149-
_FormatContext::iterator _Tuple_formatter_format(const tuple<formatter<_Types, _CharT>...>& _Underlying,
1149+
_NODISCARD _FormatContext::iterator _Tuple_formatter_format(const tuple<formatter<_Types, _CharT>...>& _Underlying,
11501150
basic_string_view<_CharT> _Separator, basic_string_view<_CharT> _Opening_bracket,
11511151
basic_string_view<_CharT> _Closing_bracket, const _Fill_align_and_width_specs<_CharT>& _Specs,
11521152
_FormatContext& _Fmt_ctx, _ArgTypes&... _Args);

stl/inc/format

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3192,7 +3192,7 @@ _NODISCARD constexpr const _CharT* _Parse_range_specs(
31923192

31933193
// TRANSITION, VSO-1236041: Avoid declaring and defining member functions in different headers.
31943194
template <class _Ty, class _CharT, class _ParseContext>
3195-
constexpr _ParseContext::iterator _Range_formatter_parse(formatter<_Ty, _CharT>& _Underlying,
3195+
_NODISCARD constexpr _ParseContext::iterator _Range_formatter_parse(formatter<_Ty, _CharT>& _Underlying,
31963196
basic_string_view<_CharT>& _Separator, basic_string_view<_CharT>& _Opening_bracket,
31973197
basic_string_view<_CharT>& _Closing_bracket, _Range_specs<_CharT>& _Specs, _ParseContext& _Ctx) {
31983198
_Range_specs_setter<_CharT> _Callback{_Specs, _Ctx};
@@ -3308,7 +3308,7 @@ void _Range_formatter_format_as_string(_Range&& _Rng, _FormatContext& _Ctx, cons
33083308
}
33093309

33103310
template <class _Ty, class _CharT, _RANGES input_range _Range, class _FormatContext>
3311-
_FormatContext::iterator _Range_formatter_format(const formatter<_Ty, _CharT>& _Underlying,
3311+
_NODISCARD _FormatContext::iterator _Range_formatter_format(const formatter<_Ty, _CharT>& _Underlying,
33123312
const basic_string_view<_CharT> _Separator, const basic_string_view<_CharT> _Opening_bracket,
33133313
const basic_string_view<_CharT> _Closing_bracket, _Range&& _Rng, const _Range_specs<_CharT>& _Specs,
33143314
_FormatContext& _Ctx) {
@@ -3463,7 +3463,7 @@ constexpr void _Set_tuple_debug_format(_FormatterType& _Formatter, _ParseContext
34633463

34643464
// TRANSITION, VSO-1236041: Avoid declaring and defining member functions in different headers.
34653465
template <class... _Types, class _CharT, class _ParseContext>
3466-
constexpr _ParseContext::iterator _Tuple_formatter_parse(tuple<formatter<_Types, _CharT>...>& _Underlying,
3466+
_NODISCARD constexpr _ParseContext::iterator _Tuple_formatter_parse(tuple<formatter<_Types, _CharT>...>& _Underlying,
34673467
basic_string_view<_CharT>& _Separator, basic_string_view<_CharT>& _Opening_bracket,
34683468
basic_string_view<_CharT>& _Closing_bracket, _Fill_align_and_width_specs<_CharT>& _Specs, _ParseContext& _Ctx) {
34693469
_Fmt_tuple_type _Fmt_type = _Fmt_tuple_type::_None;
@@ -3508,7 +3508,7 @@ void _Tuple_formatter_format_to_context(const tuple<formatter<_Types, _CharT>...
35083508
}
35093509

35103510
template <class... _Types, class _CharT, class _FormatContext, class... _ArgTypes>
3511-
_FormatContext::iterator _Tuple_formatter_format(const tuple<formatter<_Types, _CharT>...>& _Underlying,
3511+
_NODISCARD _FormatContext::iterator _Tuple_formatter_format(const tuple<formatter<_Types, _CharT>...>& _Underlying,
35123512
const basic_string_view<_CharT> _Separator, const basic_string_view<_CharT> _Opening_bracket,
35133513
const basic_string_view<_CharT> _Closing_bracket, const _Fill_align_and_width_specs<_CharT>& _Specs,
35143514
_FormatContext& _Fmt_ctx, _ArgTypes&... _Args) {

stl/inc/stacktrace

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,8 @@ ostream& operator<<(ostream& _Os, const basic_stacktrace<_Alloc>& _St) {
341341

342342
template <>
343343
struct formatter<stacktrace_entry> {
344-
constexpr format_parse_context::iterator parse(format_parse_context& _Parse_ctx) {
344+
template <class _ParseContext = format_parse_context> // improves throughput, see GH-5003
345+
constexpr _ParseContext::iterator parse(type_identity_t<_ParseContext&> _Parse_ctx) {
345346
return _Impl._Parse(_Parse_ctx);
346347
}
347348

0 commit comments

Comments
 (0)