Fix Issue 20046 - Get make!T to compile when T is a shared value type

This commit is contained in:
Harry T. Vennik 2019-07-13 10:17:33 +02:00
parent 917d9ac332
commit c44b4717cf

View file

@ -1175,7 +1175,7 @@ auto make(T, Allocator, A...)(auto ref Allocator alloc, auto ref A args)
{ {
// Assume cast is safe as allocation succeeded for `stateSize!T` // Assume cast is safe as allocation succeeded for `stateSize!T`
auto p = () @trusted { return cast(T*) m.ptr; }(); auto p = () @trusted { return cast(T*) m.ptr; }();
emplaceRef(*p, args); emplaceRef!T(*p, args);
return p; return p;
} }
} }
@ -1472,6 +1472,14 @@ if (T.sizeof != 1)
assert(a == [ 42, 42, 42, 42, 42]); assert(a == [ 42, 42, 42, 42, 42]);
} }
//Make shared object
@system unittest
{
import core.atomic : atomicLoad;
auto psi = theAllocator.make!(shared(int))(10);
assert(10 == (*psi).atomicLoad());
}
private T[] uninitializedFillDefault(T)(T[] array) nothrow private T[] uninitializedFillDefault(T)(T[] array) nothrow
{ {
static if (__traits(isZeroInit, T)) static if (__traits(isZeroInit, T))