what's wrong with my class?

Jonathan Villa via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Wed May 4 17:37:52 PDT 2016


On Thursday, 5 May 2016 at 00:03:34 UTC, Brian Schott wrote:
> On Wednesday, 4 May 2016 at 23:19:08 UTC, Jonathan Villa wrote:
>> What I'm doing wrong? :<
>
> All right. D's type system is marking the `Session` constructor 
> as `shared`. This makes the check `static if 
> (is(typeof(result.__ctor(args))))` in std.conv.emplace fail 
> because `result` is a non-shared `Session`. `emplace` is used 
> by `make` to actually initialize the memory returned by 
> `malloc`, which is why you care about it here. The solution to 
> this is to tell `make` that you want it to return a `shared 
> Session`. Once you do this the type checks should pass.
>
> tldr: `return Mallocator.instance.make!(shared 
> Session)(_parent, id_user);`

You're right! the error doesn't show anymore.
Just one question about 'shared':
That class has an ASI class, should I tag it as 'synchronized' 
too or it won't be necessary? (because is already inside in a 
synchronized class) I suppose I should tag it too as synchronized


More information about the Digitalmars-d-learn mailing list