forked from HowardHinnant/date
Correct behavior for classes for which only lvalue is convertible to string_view.
Added OnlyLValueString test case that shows the problem with current impl. Implemented the change, that accept TimeZonePtrOrName by forwarding reference (to preserve value category), and merged time_zone selection into one trait.
This commit is contained in:
committed by
Howard Hinnant
parent
5345d135b7
commit
5a0057587d
@@ -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<OffsetZone>(std::move(tz));
|
||||
}
|
||||
|
||||
// OnlyLValue
|
||||
{
|
||||
OnlyLValueString tz("Europe/Warsaw");
|
||||
testDeductionFrom<time_zone const*>(tz);
|
||||
//testDeductionFrom<time_zone const*>(to_const(tz));
|
||||
//testDeductionFrom<time_zone const*>(std::move(tz));
|
||||
}
|
||||
|
||||
#endif // HAS_DEDUCTION_GUIDES
|
||||
}
|
||||
|
Reference in New Issue
Block a user