Skip to content

Commit

Permalink
move core.d
Browse files Browse the repository at this point in the history
  • Loading branch information
vitamin committed Jan 17, 2022
1 parent 7146aa5 commit 10df3c6
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/basic_string/internal/core.d → src/basic_string/core.d
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import basic_string.internal.encoding;
import basic_string.internal.traits;


package struct Evoid{}
package struct Forward{}


package template isBasicStringCore(T...)
Expand Down Expand Up @@ -129,7 +129,7 @@ package template BasicStringCore(
this.allocator = forward!allocator;
}

public this(this This, Rhs)(auto ref scope const Rhs rhs, Evoid)scope
public this(this This, Rhs)(auto ref scope const Rhs rhs, Forward)scope
if(isBasicStringCore!Rhs && isConstructable!(rhs, This)){
static if(isMoveConstructable!(rhs, This)){ //TODO

Expand Down
22 changes: 18 additions & 4 deletions src/basic_string/package.d
Original file line number Diff line number Diff line change
Expand Up @@ -882,9 +882,17 @@ if(isSomeChar!_Char && is(Unqual!_Char == _Char)){
&& isConstructable!(rhs, This)
&& (isRef!rhs || !is(immutable This == immutable Rhs))
){
this(forward!rhs, Evoid.init);
this(forward!rhs, Forward.init);
}

/+public static auto opCall(Rhs)(scope Rhs rhs)scope
if( isBasicString!Rhs
&& isMoveConstructable!(rhs, typeof(this))
&& is(immutable This == immutable Rhs)
){
assert(0);
}+/

/// ditto
public this(this This, Rhs)(auto ref scope const Rhs rhs, Allocator allocator)scope
if(isBasicString!Rhs){
Expand All @@ -893,12 +901,12 @@ if(isSomeChar!_Char && is(Unqual!_Char == _Char)){
}

/// ditto
public this(this This, Rhs)(auto ref scope const Rhs rhs, Evoid)scope
public this(this This, Rhs)(auto ref scope const Rhs rhs, Forward)scope
if(isBasicString!Rhs && isConstructable!(rhs, This)){
static if(isRef!rhs)
this.core = Core(rhs.core, Evoid.init);
this.core = Core(rhs.core, Forward.init);
else
this.core = Core(move(rhs.core), Evoid.init);
this.core = Core(move(rhs.core), Forward.init);
}


Expand Down Expand Up @@ -2106,3 +2114,9 @@ version(unittest){
pure nothrow @safe @nogc unittest{

}
//opCall
pure nothrow @safe @nogc unittest{
import core.lifetime : move;
BasicString!char str;
//auto str2 = BasicString!char(move(str));
}

0 comments on commit 10df3c6

Please sign in to comment.