From 10df3c642f2649fc8ed40d0897a375975675c156 Mon Sep 17 00:00:00 2001 From: vitamin Date: Mon, 17 Jan 2022 22:06:45 +0100 Subject: [PATCH] move core.d --- src/basic_string/{internal => }/core.d | 4 ++-- src/basic_string/package.d | 22 ++++++++++++++++++---- 2 files changed, 20 insertions(+), 6 deletions(-) rename src/basic_string/{internal => }/core.d (99%) diff --git a/src/basic_string/internal/core.d b/src/basic_string/core.d similarity index 99% rename from src/basic_string/internal/core.d rename to src/basic_string/core.d index 11a54e7..081a9ed 100644 --- a/src/basic_string/internal/core.d +++ b/src/basic_string/core.d @@ -7,7 +7,7 @@ import basic_string.internal.encoding; import basic_string.internal.traits; -package struct Evoid{} +package struct Forward{} package template isBasicStringCore(T...) @@ -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 diff --git a/src/basic_string/package.d b/src/basic_string/package.d index c1bb874..caf1e01 100644 --- a/src/basic_string/package.d +++ b/src/basic_string/package.d @@ -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){ @@ -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); } @@ -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)); +}