Skip to content

Commit

Permalink
Templatize parse, add missed _NODISCARD
Browse files Browse the repository at this point in the history
  • Loading branch information
frederick-vs-ja committed Oct 5, 2024
1 parent 0277f64 commit 6b60cc1
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
3 changes: 2 additions & 1 deletion stl/inc/__msvc_formatter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,8 @@ _NODISCARD _FormatContext::iterator _Fill_align_and_width_formatter_format(_Form
template <class _CharT>
struct _Fill_align_and_width_formatter {
public:
_NODISCARD constexpr auto _Parse(basic_format_parse_context<_CharT>& _Parse_ctx) {
template <class _ParseContext = basic_format_parse_context<_CharT>> // improves throughput, see GH-5003
_NODISCARD constexpr _ParseContext::iterator _Parse(type_identity_t<_ParseContext&> _Parse_ctx) {
return _STD _Fill_align_and_width_formatter_parse(_Specs, _Parse_ctx);
}

Expand Down
8 changes: 4 additions & 4 deletions stl/inc/__msvc_ranges_tuple_formatter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -898,12 +898,12 @@ struct _Range_specs : _Fill_align_and_width_specs<_CharT> {

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

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

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

template <class... _Types, class _CharT, class _FormatContext, class... _ArgTypes>
_FormatContext::iterator _Tuple_formatter_format(const tuple<formatter<_Types, _CharT>...>& _Underlying,
_NODISCARD _FormatContext::iterator _Tuple_formatter_format(const tuple<formatter<_Types, _CharT>...>& _Underlying,
basic_string_view<_CharT> _Separator, basic_string_view<_CharT> _Opening_bracket,
basic_string_view<_CharT> _Closing_bracket, const _Fill_align_and_width_specs<_CharT>& _Specs,
_FormatContext& _Fmt_ctx, _ArgTypes&... _Args);
Expand Down
8 changes: 4 additions & 4 deletions stl/inc/format
Original file line number Diff line number Diff line change
Expand Up @@ -3192,7 +3192,7 @@ _NODISCARD constexpr const _CharT* _Parse_range_specs(

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

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

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

template <class... _Types, class _CharT, class _FormatContext, class... _ArgTypes>
_FormatContext::iterator _Tuple_formatter_format(const tuple<formatter<_Types, _CharT>...>& _Underlying,
_NODISCARD _FormatContext::iterator _Tuple_formatter_format(const tuple<formatter<_Types, _CharT>...>& _Underlying,
const basic_string_view<_CharT> _Separator, const basic_string_view<_CharT> _Opening_bracket,
const basic_string_view<_CharT> _Closing_bracket, const _Fill_align_and_width_specs<_CharT>& _Specs,
_FormatContext& _Fmt_ctx, _ArgTypes&... _Args) {
Expand Down
3 changes: 2 additions & 1 deletion stl/inc/stacktrace
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ ostream& operator<<(ostream& _Os, const basic_stacktrace<_Alloc>& _St) {

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

Expand Down

0 comments on commit 6b60cc1

Please sign in to comment.