Skip to content

Commit 2ad85fd

Browse files
committed
std::formatter refactoring
1 parent 15e2358 commit 2ad85fd

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

examples/format_output.hxx

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -21,18 +21,18 @@ struct std::formatter<dsga::vector_base<Writable, T, Count, Derived>, CharT> : s
2121
template <typename FormatContext>
2222
auto format(const dsga::vector_base<Writable, T, Count, Derived> &v, FormatContext &ctx) const
2323
{
24-
std::vformat_to(ctx.out(), "{{ ", std::make_format_args());
24+
std::format_to(ctx.out(), "{{ ");
2525
std::formatter<T, CharT>::format(v[0], ctx);
2626

2727
if constexpr (Count > 1)
2828
{
2929
[&] <std::size_t ...Is>(std::index_sequence<Is...>)
3030
{
31-
((std::vformat_to(ctx.out(), ", ", std::make_format_args()), std::formatter<T, CharT>::format(v[Is], ctx)), ...);
31+
((std::format_to(ctx.out(), ", "), std::formatter<T, CharT>::format(v[Is], ctx)), ...);
3232
}(dsga::make_index_range<1, Count>{});
3333
}
3434

35-
std::vformat_to(ctx.out(), " }}", std::make_format_args());
35+
std::format_to(ctx.out(), " }}");
3636

3737
return ctx.out();
3838
}
@@ -44,18 +44,18 @@ struct std::formatter<dsga::indexed_vector<T, Size, Count, Is...>, CharT> : std:
4444
template <typename FormatContext>
4545
auto format(const dsga::indexed_vector<T, Size, Count, Is...> &v, FormatContext &ctx) const
4646
{
47-
std::vformat_to(ctx.out(), "{{ ", std::make_format_args());
47+
std::format_to(ctx.out(), "{{ ");
4848
std::formatter<T, CharT>::format(v[0], ctx);
4949

5050
if constexpr (Count > 1)
5151
{
5252
[&] <std::size_t ...Js>(std::index_sequence<Js...>)
5353
{
54-
((std::vformat_to(ctx.out(), ", ", std::make_format_args()), std::formatter<T, CharT>::format(v[Js], ctx)), ...);
54+
((std::format_to(ctx.out(), ", "), std::formatter<T, CharT>::format(v[Js], ctx)), ...);
5555
}(dsga::make_index_range<1, Count>{});
5656
}
5757

58-
std::vformat_to(ctx.out(), " }}", std::make_format_args());
58+
std::format_to(ctx.out(), " }}");
5959

6060
return ctx.out();
6161
}
@@ -73,18 +73,18 @@ struct std::formatter<std::array<T, N>, CharT> : std::formatter<T, CharT>
7373
}
7474
else
7575
{
76-
std::vformat_to(ctx.out(), "{{ ", std::make_format_args());
76+
std::format_to(ctx.out(), "{{ ");
7777
std::formatter<T, CharT>::format(arr[0], ctx);
7878

7979
if constexpr (N > 1)
8080
{
8181
[&] <std::size_t ...Is>(std::index_sequence<Is...>)
8282
{
83-
((std::vformat_to(ctx.out(), ", ", std::make_format_args()), std::formatter<T, CharT>::format(arr[Is], ctx)), ...);
83+
((std::format_to(ctx.out(), ", "), std::formatter<T, CharT>::format(arr[Is], ctx)), ...);
8484
}(dsga::make_index_range<1, N>{});
8585
}
8686

87-
std::vformat_to(ctx.out(), " }}", std::make_format_args());
87+
std::format_to(ctx.out(), " }}");
8888

8989
return ctx.out();
9090
}
@@ -97,18 +97,18 @@ struct std::formatter<dsga::basic_vector<T, Size>, CharT> : std::formatter<T, Ch
9797
template <typename FormatContext>
9898
auto format(const dsga::basic_vector<T, Size> &v, FormatContext &ctx) const
9999
{
100-
std::vformat_to(ctx.out(), "{{ ", std::make_format_args());
100+
std::format_to(ctx.out(), "{{ ");
101101
std::formatter<T, CharT>::format(v[0], ctx);
102102

103103
if constexpr (Size > 1)
104104
{
105105
[&] <std::size_t ...Is>(std::index_sequence<Is...>)
106106
{
107-
((std::vformat_to(ctx.out(), ", ", std::make_format_args()), std::formatter<T, CharT>::format(v[Is], ctx)), ...);
107+
((std::format_to(ctx.out(), ", "), std::formatter<T, CharT>::format(v[Is], ctx)), ...);
108108
}(dsga::make_index_range<1, Size>{});
109109
}
110110

111-
std::vformat_to(ctx.out(), " }}", std::make_format_args());
111+
std::format_to(ctx.out(), " }}");
112112

113113
return ctx.out();
114114
}
@@ -120,18 +120,18 @@ struct std::formatter<dsga::basic_matrix<T, C, R>, CharT> : std::formatter<dsga:
120120
template <typename FormatContext>
121121
auto format(const dsga::basic_matrix<T, C, R> &m, FormatContext &ctx) const
122122
{
123-
std::vformat_to(ctx.out(), "[ ", std::make_format_args());
123+
std::format_to(ctx.out(), "[ ");
124124
std::formatter<dsga::basic_vector<T, R>, CharT>::format(m[0], ctx);
125125

126126
if constexpr (C > 1)
127127
{
128128
[&] <std::size_t ...Is>(std::index_sequence<Is...>)
129129
{
130-
((std::vformat_to(ctx.out(), ", ", std::make_format_args()), std::formatter<dsga::basic_vector<T, R>, CharT>::format(m[Is], ctx)), ...);
130+
((std::format_to(ctx.out(), ", "), std::formatter<dsga::basic_vector<T, R>, CharT>::format(m[Is], ctx)), ...);
131131
}(dsga::make_index_range<1, C>{});
132132
}
133133

134-
std::vformat_to(ctx.out(), " ]", std::make_format_args());
134+
std::format_to(ctx.out(), " ]");
135135

136136
return ctx.out();
137137
}

0 commit comments

Comments
 (0)