mirror of
https://github.com/dlang/phobos.git
synced 2025-04-30 15:10:46 +03:00
Fix Issue 20046 - Get make!T to compile when T is a shared value type
This commit is contained in:
parent
917d9ac332
commit
c44b4717cf
1 changed files with 9 additions and 1 deletions
|
@ -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))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue