[Issue 12024] [REG DMD2.065-b2] template instantiation for swap(SysTime, SysTime) fails

d-bugmail at puremagic.com d-bugmail at puremagic.com
Wed Jan 29 06:36:56 PST 2014


https://d.puremagic.com/issues/show_bug.cgi?id=12024



--- Comment #13 from Kenji Hara <k.hara.pg at gmail.com> 2014-01-29 06:36:51 PST ---
(In reply to comment #12)
> (In reply to comment #8)
> > It should be possibly by comparing .offsetof with other members.
> 
> Smart. Unfortunatly, for a "recursive" implementation, it is a bit difficult to
> exploit: More often than not, you want to know before hand that you are about
> to process an aggregate in an union.
> 
> (In reply to comment #9)
> > If a non-mutable field has one or more overlapped union _mutable_ fields, the
> > whole struct is treated as modifiable.
> > 
> > import std.traits : Unqual;
> > struct Rebindable(T)
> > {
> >     union
> >     {
> >         T origin;
> >         Unqual!T stripped;  // overlapped union mutable field of 'origin'
> >     }
> > }
> 
> Yes, absolutely. That's what I had in mind. But as I said, even detecting that
> you are in an (anonymous) union is a bit difficult. Do-able with your
> suggestion, just... difficult.

I think adding std.traits.isBlitAssignable(T) for the purpose would be good.
And you can refer the code in the compiler.

https://github.com/D-Programming-Language/dmd/blob/master/src/mtype.c#L8588
int TypeStruct::isAssignable()

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list