mirror of
https://github.com/dlang/phobos.git
synced 2025-04-27 05:30:33 +03:00
Fixes for -preview=rvaluerefparam
(#9092)
* Update `hasToString` for `-preview=rvaluerefparam` * Remove ref parameter test of parse()
This commit is contained in:
parent
6b666971bc
commit
600c721875
2 changed files with 19 additions and 17 deletions
|
@ -2560,9 +2560,6 @@ Lerr:
|
|||
string s1 = "123";
|
||||
auto a1 = parse!(int, string, Yes.doCount)(s1);
|
||||
assert(a1.data == 123 && a1.count == 3);
|
||||
|
||||
// parse only accepts lvalues
|
||||
static assert(!__traits(compiles, parse!int("123")));
|
||||
}
|
||||
|
||||
///
|
||||
|
|
|
@ -1839,24 +1839,26 @@ template hasToString(T, Char)
|
|||
else static if (is(typeof(
|
||||
(T val) {
|
||||
const FormatSpec!Char f;
|
||||
static struct S {void put(scope Char s){}}
|
||||
static struct S
|
||||
{
|
||||
@disable this(this);
|
||||
void put(scope Char s){}
|
||||
}
|
||||
S s;
|
||||
val.toString(s, f);
|
||||
static assert(!__traits(compiles, val.toString(s, FormatSpec!Char())),
|
||||
"force toString to take parameters by ref");
|
||||
static assert(!__traits(compiles, val.toString(S(), f)),
|
||||
"force toString to take parameters by ref");
|
||||
})))
|
||||
{
|
||||
enum hasToString = HasToStringResult.customPutWriterFormatSpec;
|
||||
}
|
||||
else static if (is(typeof(
|
||||
(T val) {
|
||||
static struct S {void put(scope Char s){}}
|
||||
static struct S
|
||||
{
|
||||
@disable this(this);
|
||||
void put(scope Char s){}
|
||||
}
|
||||
S s;
|
||||
val.toString(s);
|
||||
static assert(!__traits(compiles, val.toString(S())),
|
||||
"force toString to take parameters by ref");
|
||||
})))
|
||||
{
|
||||
enum hasToString = HasToStringResult.customPutWriter;
|
||||
|
@ -1996,9 +1998,10 @@ template hasToString(T, Char)
|
|||
static assert(hasToString!(G, char) == customPutWriter);
|
||||
static assert(hasToString!(H, char) == customPutWriterFormatSpec);
|
||||
static assert(hasToString!(I, char) == customPutWriterFormatSpec);
|
||||
static assert(hasToString!(J, char) == hasSomeToString);
|
||||
static assert(hasToString!(J, char) == hasSomeToString
|
||||
|| hasToString!(J, char) == constCharSinkFormatSpec); // depends on -preview=rvaluerefparam
|
||||
static assert(hasToString!(K, char) == constCharSinkFormatSpec);
|
||||
static assert(hasToString!(L, char) == none);
|
||||
static assert(hasToString!(L, char) == customPutWriterFormatSpec);
|
||||
static if (hasPreviewIn)
|
||||
{
|
||||
static assert(hasToString!(M, char) == inCharSinkFormatSpec);
|
||||
|
@ -2105,9 +2108,10 @@ template hasToString(T, Char)
|
|||
static assert(hasToString!(G, char) == customPutWriter);
|
||||
static assert(hasToString!(H, char) == customPutWriterFormatSpec);
|
||||
static assert(hasToString!(I, char) == customPutWriterFormatSpec);
|
||||
static assert(hasToString!(J, char) == hasSomeToString);
|
||||
static assert(hasToString!(J, char) == hasSomeToString
|
||||
|| hasToString!(J, char) == constCharSinkFormatSpec); // depends on -preview=rvaluerefparam
|
||||
static assert(hasToString!(K, char) == constCharSinkFormatSpec);
|
||||
static assert(hasToString!(L, char) == none);
|
||||
static assert(hasToString!(L, char) == HasToStringResult.customPutWriterFormatSpec);
|
||||
static if (hasPreviewIn)
|
||||
{
|
||||
static assert(hasToString!(M, char) == inCharSinkFormatSpec);
|
||||
|
@ -2125,9 +2129,10 @@ template hasToString(T, Char)
|
|||
static assert(hasToString!(inout(G), char) == customPutWriter);
|
||||
static assert(hasToString!(inout(H), char) == customPutWriterFormatSpec);
|
||||
static assert(hasToString!(inout(I), char) == customPutWriterFormatSpec);
|
||||
static assert(hasToString!(inout(J), char) == hasSomeToString);
|
||||
static assert(hasToString!(inout(J), char) == hasSomeToString
|
||||
|| hasToString!(inout(J), char) == constCharSinkFormatSpec); // depends on -preview=rvaluerefparam
|
||||
static assert(hasToString!(inout(K), char) == constCharSinkFormatSpec);
|
||||
static assert(hasToString!(inout(L), char) == none);
|
||||
static assert(hasToString!(inout(L), char) == customPutWriterFormatSpec);
|
||||
static if (hasPreviewIn)
|
||||
{
|
||||
static assert(hasToString!(inout(M), char) == inCharSinkFormatSpec);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue