diff --git a/include/date/tz.h b/include/date/tz.h index b011696..1f7ed01 100644 --- a/include/date/tz.h +++ b/include/date/tz.h @@ -709,6 +709,18 @@ using zoned_seconds = zoned_time; #if HAS_DEDUCTION_GUIDES +namespace detail +{ + template + using time_zone_representation = + std::conditional_t + < + std::is_convertible::value, + time_zone const*, + std::remove_cv_t> + >; +} + zoned_time() -> zoned_time; @@ -717,44 +729,20 @@ zoned_time(sys_time) -> zoned_time>; template -zoned_time(TimeZonePtrOrName) - -> zoned_time::value, - time_zone const*, - TimeZonePtrOrName - >>; +zoned_time(TimeZonePtrOrName&&) + -> zoned_time>; template -zoned_time(TimeZonePtrOrName, sys_time) - -> zoned_time, - std::conditional_t - < - std::is_convertible::value, - time_zone const*, - TimeZonePtrOrName - >>; +zoned_time(TimeZonePtrOrName&&, sys_time) + -> zoned_time, detail::time_zone_representation>; template -zoned_time(TimeZonePtrOrName, local_time, choose = choose::earliest) - -> zoned_time, - std::conditional_t - < - std::is_convertible::value, - time_zone const*, - TimeZonePtrOrName - >>; +zoned_time(TimeZonePtrOrName&&, local_time, choose = choose::earliest) + -> zoned_time, detail::time_zone_representation>; template -zoned_time(TimeZonePtrOrName, zoned_time, choose = choose::earliest) - -> zoned_time, - std::conditional_t - < - std::is_convertible::value, - time_zone const*, - TimeZonePtrOrName - >>; +zoned_time(TimeZonePtrOrName&&, zoned_time, choose = choose::earliest) + -> zoned_time, detail::time_zone_representation>; #endif // HAS_DEDUCTION_GUIDES diff --git a/test/tz_test/zoned_time_deduction.pass.cpp b/test/tz_test/zoned_time_deduction.pass.cpp index 8cf4440..e62e11a 100644 --- a/test/tz_test/zoned_time_deduction.pass.cpp +++ b/test/tz_test/zoned_time_deduction.pass.cpp @@ -127,6 +127,15 @@ private: std::string ms; }; +struct OnlyLValueString +{ + OnlyLValueString(std::string s) : ms(std::move(s)) {} + + operator std::string_view() & { return ms; } + +private: + std::string ms; +}; #endif // HAS_DEDUCTION_GUIDES @@ -225,5 +234,13 @@ main() testDeductionFrom(std::move(tz)); } + // OnlyLValue + { + OnlyLValueString tz("Europe/Warsaw"); + testDeductionFrom(tz); + //testDeductionFrom(to_const(tz)); + //testDeductionFrom(std::move(tz)); + } + #endif // HAS_DEDUCTION_GUIDES }