change Str func
This commit is contained in:
parent
988270db0b
commit
53dbb8bf34
@ -475,7 +475,7 @@ ExecLocation(T)()
|
|||||||
}
|
}
|
||||||
|
|
||||||
auto
|
auto
|
||||||
Cwd(T)()
|
Cwd(T = string)()
|
||||||
{
|
{
|
||||||
static char[512] buf;
|
static char[512] buf;
|
||||||
|
|
||||||
@ -487,7 +487,7 @@ Cwd(T)()
|
|||||||
}
|
}
|
||||||
else static if(is(T: string))
|
else static if(is(T: string))
|
||||||
{
|
{
|
||||||
return ConvToStr(buf)[0 .. strlen(buf.ptr)];
|
return ConvToStr(buf[0 .. strlen(buf.ptr)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
4
util.d
4
util.d
@ -14,7 +14,7 @@ import std.traits;
|
|||||||
import core.stdc.string : memset;
|
import core.stdc.string : memset;
|
||||||
import core.simd;
|
import core.simd;
|
||||||
|
|
||||||
enum bool StringType(T) = (is(T: string) || is(T: u8[]) || is(T: char[]));
|
enum bool StringType(T) = (is(T: string) || is(T: u8[]) || is(T: char[]) || is(T: const(char)[]));
|
||||||
|
|
||||||
pragma(inline) void
|
pragma(inline) void
|
||||||
Int3()
|
Int3()
|
||||||
@ -45,7 +45,7 @@ Assert(T)(T cond, string msg)
|
|||||||
}
|
}
|
||||||
|
|
||||||
string
|
string
|
||||||
Str(T)(T[] arr)
|
Str(T)(T arr) if(StringType!(T))
|
||||||
{
|
{
|
||||||
return (cast(immutable(char)*)arr.ptr)[0 .. arr.length];
|
return (cast(immutable(char)*)arr.ptr)[0 .. arr.length];
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user