tvaneerd / isocpp

a place for my ISO C++ committee stuff

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

assignment

tvaneerd opened this issue · comments

When is it OK for assignment to be implicit but construction explicit?
Howard and I both think "not usually, but sometimes", but have no hard rules.

eg. zoned_time = local_time sets the local-time portion of a zoned_time. Is that OK?

StringId isn't convertible from string (to avoid accidental passing a string when you want an ID)
but StringId = string seems like there is intent, and it is not accidental.

Whereas milliseconds = int is probably too dangerous.

For units like milliseconds, the int represents a measure in some unit - the question is "is it the right unit"

For StringId = string, there is only one meaning - set the internal string. Could the string be in the wrong "unit"? Less likely?

zoned_time = local_time still seems scary to me - there are two (equally) valid meanings - just set the time portion of zoned_time, or convert from that time in the local time zone into the simultaneous time in the zoned_time's time zone.