Skip to content

Commit d61d9fb

Browse files
committed
change to private inheritance for month etc. and address other comments
1 parent 6a24da0 commit d61d9fb

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

Diff for: include/fmt/chrono.h

+8-8
Original file line numberDiff line numberDiff line change
@@ -2103,7 +2103,7 @@ class year_month_day {
21032103
#endif
21042104

21052105
template <typename Char>
2106-
struct formatter<weekday, Char> : formatter<std::tm, Char> {
2106+
struct formatter<weekday, Char> : private formatter<std::tm, Char> {
21072107
private:
21082108
bool localized_{false};
21092109
bool use_tm_formatter_{false};
@@ -2136,15 +2136,15 @@ struct formatter<weekday, Char> : formatter<std::tm, Char> {
21362136
};
21372137

21382138
template <typename Char>
2139-
struct formatter<day, Char> : formatter<std::tm, Char> {
2139+
struct formatter<day, Char> : private formatter<std::tm, Char> {
21402140
private:
21412141
bool use_tm_formatter_{false};
21422142

21432143
public:
21442144
FMT_CONSTEXPR auto parse(basic_format_parse_context<Char>& ctx)
21452145
-> decltype(ctx.begin()) {
21462146
auto it = ctx.begin(), end = ctx.end();
2147-
use_tm_formatter_ = !(it == end || *it == '}');
2147+
use_tm_formatter_ = (it != end && *it != '}');
21482148
return use_tm_formatter_ ? formatter<std::tm, Char>::parse(ctx) : it;
21492149
}
21502150

@@ -2163,7 +2163,7 @@ struct formatter<day, Char> : formatter<std::tm, Char> {
21632163
};
21642164

21652165
template <typename Char>
2166-
struct formatter<month, Char> : formatter<std::tm, Char> {
2166+
struct formatter<month, Char> : private formatter<std::tm, Char> {
21672167
private:
21682168
bool localized_{false};
21692169
bool use_tm_formatter_{false};
@@ -2196,15 +2196,15 @@ struct formatter<month, Char> : formatter<std::tm, Char> {
21962196
};
21972197

21982198
template <typename Char>
2199-
struct formatter<year, Char> : formatter<std::tm, Char> {
2199+
struct formatter<year, Char> : private formatter<std::tm, Char> {
22002200
private:
22012201
bool use_tm_formatter_{false};
22022202

22032203
public:
22042204
FMT_CONSTEXPR auto parse(basic_format_parse_context<Char>& ctx)
22052205
-> decltype(ctx.begin()) {
22062206
auto it = ctx.begin(), end = ctx.end();
2207-
use_tm_formatter_ = !(it == end || *it == '}');
2207+
use_tm_formatter_ = (it != end && *it != '}');
22082208
return use_tm_formatter_ ? formatter<std::tm, Char>::parse(ctx) : it;
22092209
}
22102210

@@ -2223,15 +2223,15 @@ struct formatter<year, Char> : formatter<std::tm, Char> {
22232223
};
22242224

22252225
template <typename Char>
2226-
struct formatter<year_month_day, Char> : formatter<std::tm, Char> {
2226+
struct formatter<year_month_day, Char> : private formatter<std::tm, Char> {
22272227
private:
22282228
bool use_tm_formatter_{false};
22292229

22302230
public:
22312231
FMT_CONSTEXPR auto parse(basic_format_parse_context<Char>& ctx)
22322232
-> decltype(ctx.begin()) {
22332233
auto it = ctx.begin(), end = ctx.end();
2234-
use_tm_formatter_ = !(it == end || *it == '}');
2234+
use_tm_formatter_ = (it != end && *it != '}');
22352235
return use_tm_formatter_ ? formatter<std::tm, Char>::parse(ctx) : it;
22362236
}
22372237

0 commit comments

Comments
 (0)