Skip to content

Commit 5462b27

Browse files
authored
[NFC][libc++][TZDB] Refactors argument order. (#85781)
Putting the output reference argument first looks more sensible.
1 parent 1c2afba commit 5462b27

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

libcxx/include/__chrono/formatter.h

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ namespace __formatter {
7979
// small). Therefore a duration uses its own conversion.
8080
template <class _CharT, class _Rep, class _Period>
8181
_LIBCPP_HIDE_FROM_ABI void
82-
__format_sub_seconds(const chrono::duration<_Rep, _Period>& __value, basic_stringstream<_CharT>& __sstr) {
82+
__format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::duration<_Rep, _Period>& __value) {
8383
__sstr << std::use_facet<numpunct<_CharT>>(__sstr.getloc()).decimal_point();
8484

8585
using __duration = chrono::duration<_Rep, _Period>;
@@ -110,13 +110,13 @@ __format_sub_seconds(const chrono::duration<_Rep, _Period>& __value, basic_strin
110110
}
111111

112112
template <class _CharT, __is_time_point _Tp>
113-
_LIBCPP_HIDE_FROM_ABI void __format_sub_seconds(const _Tp& __value, basic_stringstream<_CharT>& __sstr) {
114-
__formatter::__format_sub_seconds(__value.time_since_epoch(), __sstr);
113+
_LIBCPP_HIDE_FROM_ABI void __format_sub_seconds(basic_stringstream<_CharT>& __sstr, const _Tp& __value) {
114+
__formatter::__format_sub_seconds(__sstr, __value.time_since_epoch());
115115
}
116116

117117
template <class _CharT, class _Duration>
118118
_LIBCPP_HIDE_FROM_ABI void
119-
__format_sub_seconds(const chrono::hh_mm_ss<_Duration>& __value, basic_stringstream<_CharT>& __sstr) {
119+
__format_sub_seconds(basic_stringstream<_CharT>& __sstr, const chrono::hh_mm_ss<_Duration>& __value) {
120120
__sstr << std::use_facet<numpunct<_CharT>>(__sstr.getloc()).decimal_point();
121121
if constexpr (chrono::treat_as_floating_point_v<typename _Duration::rep>)
122122
std::format_to(std::ostreambuf_iterator<_CharT>{__sstr},
@@ -143,7 +143,7 @@ consteval bool __use_fraction() {
143143
}
144144

145145
template <class _CharT>
146-
_LIBCPP_HIDE_FROM_ABI void __format_year(int __year, basic_stringstream<_CharT>& __sstr) {
146+
_LIBCPP_HIDE_FROM_ABI void __format_year(basic_stringstream<_CharT>& __sstr, int __year) {
147147
if (__year < 0) {
148148
__sstr << _CharT('-');
149149
__year = -__year;
@@ -159,7 +159,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_year(int __year, basic_stringstream<_CharT>&
159159
}
160160

161161
template <class _CharT>
162-
_LIBCPP_HIDE_FROM_ABI void __format_century(int __year, basic_stringstream<_CharT>& __sstr) {
162+
_LIBCPP_HIDE_FROM_ABI void __format_century(basic_stringstream<_CharT>& __sstr, int __year) {
163163
// TODO FMT Write an issue
164164
// [tab:time.format.spec]
165165
// %C The year divided by 100 using floored division. If the result is a
@@ -172,7 +172,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_century(int __year, basic_stringstream<_Char
172172

173173
template <class _CharT, class _Tp>
174174
_LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
175-
const _Tp& __value, basic_stringstream<_CharT>& __sstr, basic_string_view<_CharT> __chrono_specs) {
175+
basic_stringstream<_CharT>& __sstr, const _Tp& __value, basic_string_view<_CharT> __chrono_specs) {
176176
tm __t = std::__convert_to_tm<tm>(__value);
177177
const auto& __facet = std::use_facet<time_put<_CharT>>(__sstr.getloc());
178178
for (auto __it = __chrono_specs.begin(); __it != __chrono_specs.end(); ++__it) {
@@ -196,7 +196,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
196196
// strftime's output is only defined in the range [00, 99].
197197
int __year = __t.tm_year + 1900;
198198
if (__year < 1000 || __year > 9999)
199-
__formatter::__format_century(__year, __sstr);
199+
__formatter::__format_century(__sstr, __year);
200200
else
201201
__facet.put(
202202
{__sstr}, __sstr, _CharT(' '), std::addressof(__t), std::to_address(__s), std::to_address(__it + 1));
@@ -242,7 +242,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
242242
__facet.put(
243243
{__sstr}, __sstr, _CharT(' '), std::addressof(__t), std::to_address(__s), std::to_address(__it + 1));
244244
if constexpr (__use_fraction<_Tp>())
245-
__formatter::__format_sub_seconds(__value, __sstr);
245+
__formatter::__format_sub_seconds(__sstr, __value);
246246
break;
247247

248248
// Unlike time_put and strftime the formatting library requires %Y
@@ -283,13 +283,13 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
283283
// Depending on the platform's libc the range of supported years is
284284
// limited. Intead of of testing all conditions use the internal
285285
// implementation unconditionally.
286-
__formatter::__format_year(__t.tm_year + 1900, __sstr);
286+
__formatter::__format_year(__sstr, __t.tm_year + 1900);
287287
break;
288288

289289
case _CharT('F'): {
290290
int __year = __t.tm_year + 1900;
291291
if (__year < 1000) {
292-
__formatter::__format_year(__year, __sstr);
292+
__formatter::__format_year(__sstr, __year);
293293
__sstr << std::format(_LIBCPP_STATICALLY_WIDEN(_CharT, "-{:02}-{:02}"), __t.tm_mon + 1, __t.tm_mday);
294294
} else
295295
__facet.put(
@@ -310,7 +310,7 @@ _LIBCPP_HIDE_FROM_ABI void __format_chrono_using_chrono_specs(
310310
++__it;
311311
__facet.put(
312312
{__sstr}, __sstr, _CharT(' '), std::addressof(__t), std::to_address(__s), std::to_address(__it + 1));
313-
__formatter::__format_sub_seconds(__value, __sstr);
313+
__formatter::__format_sub_seconds(__sstr, __value);
314314
break;
315315
}
316316
}
@@ -512,7 +512,7 @@ __format_chrono(const _Tp& __value,
512512
if constexpr (chrono::__is_duration<_Tp>::value) {
513513
if (__value < __value.zero())
514514
__sstr << _CharT('-');
515-
__formatter::__format_chrono_using_chrono_specs(chrono::abs(__value), __sstr, __chrono_specs);
515+
__formatter::__format_chrono_using_chrono_specs(__sstr, chrono::abs(__value), __chrono_specs);
516516
// TODO FMT When keeping the precision it will truncate the string.
517517
// Note that the behaviour what the precision does isn't specified.
518518
__specs.__precision_ = -1;
@@ -556,7 +556,7 @@ __format_chrono(const _Tp& __value,
556556
__sstr << _CharT('-');
557557
}
558558

559-
__formatter::__format_chrono_using_chrono_specs(__value, __sstr, __chrono_specs);
559+
__formatter::__format_chrono_using_chrono_specs(__sstr, __value, __chrono_specs);
560560
}
561561
}
562562

0 commit comments

Comments
 (0)