Non movable structs

Mathias Lang via Digitalmars-d digitalmars-d at puremagic.com
Sun Jun 19 03:16:22 PDT 2016


Normally, you would need to disable both identity opAssign and postblit and
it should work. At the moment, it works for the struct itself, however it
breaks when the struct is nested in another one.
There are a couple of issues I am currently looking into fixing (after an
IRC discussion with Eyal).

The gist of it is https://github.com/dlang/dmd/pull/5854 . However with the
current state of the specs / implementation that would make the language
more inconsistent, which is why I put it on hold.
First we need to make `opAssign` properly transitive. You expect that the
compiler-generated `opAssign` call its members `opAssign` if they have any.
This currently happens, but only if the struct has neither dtor nor
postblit.

There are probably a couple of other low-hanging fruits to harvest in the
process (one of them is that the compiler-generated `opAssign` takes its
argument by value, which result in the `struct` being copied and
postblited...)

2016-06-19 11:37 GMT+02:00 Adrian Matoga via Digitalmars-d <
digitalmars-d at puremagic.com>:

> On Sunday, 19 June 2016 at 02:06:59 UTC, deadalnix wrote:
>
>> Long story short, I need structs that do not move. I'm sure there are
>> many other use cases.
>>
>
> I needed that for a struct member function to be passed as delegate for a
> fiber.
> The easiest way I found was to malloc the struct.
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.puremagic.com/pipermail/digitalmars-d/attachments/20160619/af59c37f/attachment-0001.html>


More information about the Digitalmars-d mailing list