diff --git a/src/yu/container/cirularqueue.d b/src/yu/container/cirularqueue.d index 73c3fb5..54aa5c0 100644 --- a/src/yu/container/cirularqueue.d +++ b/src/yu/container/cirularqueue.d @@ -16,7 +16,7 @@ import yu.container.common; Allocator = which type Allocator will used */ -@trusted struct CirularQueue(T, Allocator = GCAllocator, bool autoExten = false, bool addInGC = true) { +@trusted struct CirularQueue(T, Allocator = GCAllocator, bool autoExten = false, bool addInGC = true) if(is(T == Unqual!T)) { enum TSize = T.sizeof; enum addToGC = addInGC && hasIndirections!T && !is(Unqual!Allocator == GCAllocator); static if (hasIndirections!T) diff --git a/src/yu/container/common.d b/src/yu/container/common.d index 720f643..4608a06 100644 --- a/src/yu/container/common.d +++ b/src/yu/container/common.d @@ -1,6 +1,7 @@ module yu.container.common; import core.atomic; +import std.traits : Unqual; import std.experimental.allocator; @@ -78,7 +79,7 @@ mixin template Refcount() } /// Array Cow Data -struct ArrayCOWData(T, Allocator,bool inGC = false) +struct ArrayCOWData(T, Allocator,bool inGC = false) if(is(T == Unqual!T)) { import core.memory : GC; import std.exception : enforce; diff --git a/src/yu/container/string.d b/src/yu/container/string.d index 2a06517..d606ec5 100644 --- a/src/yu/container/string.d +++ b/src/yu/container/string.d @@ -16,7 +16,8 @@ alias WString = IWString!(Mallocator); alias DString = IDString!(Mallocator); // The Cow String -@trusted struct StringImpl(Char, Allocator) +@trusted struct StringImpl(Char, Allocator) + if(is(Char == Unqual!Char) && isSomeChar!Char) { alias Data = ArrayCOWData!(Char, Allocator); static if (StaticAlloc!Allocator) diff --git a/src/yu/container/vector.d b/src/yu/container/vector.d index 045c424..f4c67cf 100644 --- a/src/yu/container/vector.d +++ b/src/yu/container/vector.d @@ -17,7 +17,7 @@ import yu.array; 2. 不允许copy: 对于引用类型 和 指针 */ -@trusted struct Vector(T, Allocator = Mallocator, bool addInGC = true) //if(!(hasIndirections!T)) +@trusted struct Vector(T, Allocator = Mallocator, bool addInGC = true) if(is(T == Unqual!T)) { enum addToGC = addInGC && hasIndirections!T && !is(Unqual!Allocator == GCAllocator); enum needDestroy = (is(T == struct) && hasElaborateDestructor!T); @@ -462,4 +462,6 @@ unittest { 1541515, 15415, 1545, 1545, 1545, 1545, 15454, 0, 54154]); vec22 ~= [0, 1, 2, 1, 212]; + + //Vector!(shared int) vec2; }