relax disabled Final!T unary operators

H. S. Teoh via Digitalmars-d digitalmars-d at puremagic.com
Wed Mar 29 10:59:10 PDT 2017


On Fri, Mar 24, 2017 at 11:00:20AM -0700, H. S. Teoh via Digitalmars-d wrote:
> (Just wait till I try it on a union... that's gonna throw things off,
> I'm almost certain.)
[...]

And just as I predicted:

	https://issues.dlang.org/show_bug.cgi?id=17284

In a nutshell: the compiler rejects assigning to pointer fields in a
union when in @safe code (for obvious reasons), but to work around that,
just write Final!U instead, and you can freely assign overlapping
pointers in @safe code willy-nilly.

I think Final should be modified so that it outright rejects PODs and
unions, at the minimum, if not structs as well.

I think it's a bad idea to have it accept structs and then allow
modifying struct members.  This would prohibit things like
Final!(RefCounted!T), for example; but if anybody wants to use Final on
a RefCounted object, they should perhaps use RefCounted!(Final!T)
instead.


T

-- 
Without outlines, life would be pointless.


More information about the Digitalmars-d mailing list