Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

> The problem with mandating this is that it doesn't really express anything - the semantics are the same as `b = a;`. And there's a cost because it's quite verbose.

Sure, but at least the problem is back to "should conversions/casts be implicit or explicit?", rather than "I cannot do what I want with explicit casts".

> If what you want to express is "I know b and a have different storage sizes"

You may not even know this (e.g., in generic code), and if you did want to ensure different storage sizes specifically, then you want a (static) assert.

> eg if you typo `b` for `a`, then `b = static_cast<decltype(b)>(b);` is still accepted.

That would also apply to the version with implicit casts/conversions, wouldn't it?



Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: