Allow zoned_time conversion among different TimeZonePtr types

This commit is contained in:
Howard Hinnant 2017-10-28 18:18:42 -04:00
parent 4b73a42d02
commit fa6529a2fc

View File

@ -417,8 +417,21 @@ public:
#endif
zoned_time(TimeZonePtr z, const local_time<Duration>& tp, choose c);
zoned_time(TimeZonePtr z, const zoned_time& zt);
zoned_time(TimeZonePtr z, const zoned_time& zt, choose);
template <class Duration2, class TimeZonePtr2,
class = typename std::enable_if
<
std::is_convertible<sys_time<Duration2>,
sys_time<Duration>>::value
>::type>
zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& zt);
template <class Duration2, class TimeZonePtr2,
class = typename std::enable_if
<
std::is_convertible<sys_time<Duration2>,
sys_time<Duration>>::value
>::type>
zoned_time(TimeZonePtr z, const zoned_time<Duration2, TimeZonePtr2>& zt, choose);
#if HAS_STRING_VIEW
@ -718,6 +731,14 @@ template <class Duration>
zoned_time(const char*, local_time<Duration>, choose = choose::earliest)
-> zoned_time<std::common_type_t<Duration, std::chrono::seconds>>;
template <class Duration, class TimeZonePtr, class TimeZonePtr2>
zoned_time(TimeZonePtr, zoned_time<Duration, TimeZonePtr2>)
-> zoned_time<Duration, TimeZonePtr>;
template <class Duration, class TimeZonePtr, class TimeZonePtr2>
zoned_time(TimeZonePtr, zoned_time<Duration, TimeZonePtr2>, choose)
-> zoned_time<Duration, TimeZonePtr>;
#endif // HAS_DEDUCTION_GUIDES
template <class Duration1, class Duration2, class TimeZonePtr>
@ -1403,17 +1424,19 @@ zoned_time<Duration, TimeZonePtr>::zoned_time(TimeZonePtr z, const local_time<Du
{}
template <class Duration, class TimeZonePtr>
template <class Duration2, class TimeZonePtr2, class>
inline
zoned_time<Duration, TimeZonePtr>::zoned_time(TimeZonePtr z,
const zoned_time<Duration, TimeZonePtr>& zt)
const zoned_time<Duration2, TimeZonePtr2>& zt)
: zone_(std::move(z))
, tp_(zt.tp_)
{}
template <class Duration, class TimeZonePtr>
template <class Duration2, class TimeZonePtr2, class>
inline
zoned_time<Duration, TimeZonePtr>::zoned_time(TimeZonePtr z,
const zoned_time<Duration, TimeZonePtr>& zt, choose)
const zoned_time<Duration2, TimeZonePtr2>& zt, choose)
: zoned_time(std::move(z), zt)
{}