Skip to content

Commit 616129f

Browse files
committed
More identities for hash<trivial>s
1 parent 152b3dc commit 616129f

File tree

3 files changed

+4
-8
lines changed

3 files changed

+4
-8
lines changed

libcxx/include/__chrono/month.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ inline constexpr month December{12};
115115
template <>
116116
struct hash<chrono::month> {
117117
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::month& __m) noexcept {
118-
return hash<unsigned>{}(static_cast<unsigned>(__m));
118+
return static_cast<unsigned>(__m);
119119
}
120120
};
121121

libcxx/include/__chrono/weekday.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,13 @@ inline constexpr weekday Saturday{6};
166166

167167
template <>
168168
struct hash<chrono::weekday> {
169-
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::weekday& __w) noexcept {
170-
return hash<unsigned>{}(__w.c_encoding());
171-
}
169+
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::weekday& __w) noexcept { return __w.c_encoding(); }
172170
};
173171

174172
template <>
175173
struct hash<chrono::weekday_indexed> {
176174
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::weekday_indexed& __wi) noexcept {
177-
return std::__hash_combine(hash<chrono::weekday>{}(__wi.weekday()), hash<unsigned>{}(__wi.index()));
175+
return std::__hash_combine(hash<chrono::weekday>{}(__wi.weekday()), __wi.index());
178176
}
179177
};
180178

libcxx/include/__chrono/year.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,9 +115,7 @@ _LIBCPP_HIDE_FROM_ABI constexpr bool year::ok() const noexcept {
115115

116116
template <>
117117
struct hash<chrono::year> {
118-
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year& __y) noexcept {
119-
return hash<int>{}(static_cast<int>(__y));
120-
}
118+
_LIBCPP_HIDE_FROM_ABI static size_t operator()(const chrono::year& __y) noexcept { return static_cast<int>(__y); }
121119
};
122120

123121
# endif // _LIBCPP_STD_VER >= 26

0 commit comments

Comments
 (0)