Skip to content

Commit b401d04

Browse files
committed
[NFC][libc++][chrono] Removes dead code.
For certain time_points there are specializations of __convert_to_tm. This means the non-specialized version is never called. This means some of the `if constexpr` will never be true. These are removed. Since there is a `static_assert` accidental removal of the specialization will make the code ill-formed.
1 parent 0668bb2 commit b401d04

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

libcxx/include/__chrono/convert_to_tm.h

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -143,21 +143,14 @@ _LIBCPP_HIDE_FROM_ABI _Tm __convert_to_tm(const _ChronoT& __value) {
143143
# endif
144144

145145
if constexpr (__is_time_point<_ChronoT>) {
146-
if constexpr (same_as<typename _ChronoT::clock, chrono::system_clock>)
147-
return std::__convert_to_tm<_Tm>(__value);
148-
# if _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
149-
# if _LIBCPP_HAS_EXPERIMENTAL_TZDB
150-
else if constexpr (same_as<typename _ChronoT::clock, chrono::utc_clock>)
151-
return std::__convert_to_tm<_Tm>(__value);
152-
else if constexpr (same_as<typename _ChronoT::clock, chrono::tai_clock>)
153-
return std::__convert_to_tm<_Tm>(__value);
154-
# endif // _LIBCPP_HAS_EXPERIMENTAL_TZDB
155-
# endif // _LIBCPP_HAS_TIME_ZONE_DATABASE && _LIBCPP_HAS_FILESYSTEM && _LIBCPP_HAS_LOCALIZATION
156-
else if constexpr (same_as<typename _ChronoT::clock, chrono::file_clock>)
146+
if constexpr (same_as<typename _ChronoT::clock, chrono::file_clock>)
157147
return std::__convert_to_tm<_Tm>(_ChronoT::clock::to_sys(__value));
158148
else if constexpr (same_as<typename _ChronoT::clock, chrono::local_t>)
159149
return std::__convert_to_tm<_Tm>(chrono::sys_time<typename _ChronoT::duration>{__value.time_since_epoch()});
160150
else
151+
// Note that some clocks have specializations __convert_to_tm for their
152+
// time_point. These don't need to be added here. They do not trigger
153+
// this assert.
161154
static_assert(sizeof(_ChronoT) == 0, "TODO: Add the missing clock specialization");
162155
} else if constexpr (chrono::__is_duration_v<_ChronoT>) {
163156
// [time.format]/6

0 commit comments

Comments
 (0)