automem icon indicating copy to clipboard operation
automem copied to clipboard

UniqueArray can't be used with classes

Open atilaneves opened this issue 7 years ago • 4 comments

atilaneves avatar Jun 06 '17 08:06 atilaneves

You mean actually creating arrays of class instances, as opposed to class references? It's doable, although IMHO there wouldn't be much benefit to it. Do you have a practical use case for it?

radcapricorn avatar Jun 08 '17 01:06 radcapricorn

I was just updating Unique and RefCounted to work with classes and thought UniqueArray should be able to do that too.

atilaneves avatar Jun 08 '17 14:06 atilaneves

@atilaneves There are also no class unittests for Unique as well. I noticed when the following failed when I tried to run it:

import stdx.allocator.mallocator: Mallocator;
import automem : Unique;

class Point
{
    int x;
    int y;
}

void main()
{
    auto u1 = Unique!(Point, Mallocator)(2, 3);
}

jmh530 avatar Jan 30 '19 20:01 jmh530

@atilaneves Hmm, well I was incorrect that there are no unittests for this keep. You just keep them in a separate folder. I'm still not really sure why it fails though...

jmh530 avatar Jan 30 '19 22:01 jmh530