Movable resource handles

Era Scarecrow via Digitalmars-d digitalmars-d at puremagic.com
Wed Jan 27 19:38:32 PST 2016


On Thursday, 28 January 2016 at 03:02:34 UTC, Matt Elkins wrote:
> Thanks for the response! I learned more about D just from 
> studying this example.

  Hmmm you might read the free online book, i'm going through it 
and finding it useful so far as a refresher.

http://ddili.org/ders/d.en/index.html

> ///// Not sure how to tag this as a code block on the forum

  Since the forum is text only, i like to use bbcode as [code] 
blocks (if there's a preferred method, I haven't one). So:

[code]
  auto pi = 3.14159;
[/code]


> /////
> alias UR = UniqueRef!(int, theAllocator);
> auto a = UR(41);
> UR[] handles;
>
> // Both of the following lines yield:
> // Error: ... UniqueRef is not copyable because it is annotated 
> with @disable
> // handles ~= move(a);
> // handles ~= a;
> //// End code block ////
>
> This is essentially the same error I get on my attempts to 
> implement these semantics, as well.

  hmmm... You'd best be allocating the reference directly on the 
array, you should be able to add to it.

[code]
  handles ~= UR(41);
[/code]


More information about the Digitalmars-d mailing list