[Issue 3567] std.traits: Unqual doesn't handle arrays well
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Jul 12 08:56:15 UTC 2018
https://issues.dlang.org/show_bug.cgi?id=3567
Timoses <timosesu at gmail.com> changed:
What |Removed |Added
----------------------------------------------------------------------------
CC| |timosesu at gmail.com
--- Comment #5 from Timoses <timosesu at gmail.com> ---
The fact the Unqual only "shallowly" unqualifies a type can be pretty annoying
when dealing with templates and inout functions.
struct S
{
int[] vals;
}
template Temp(T)
{
class Temp
{
T t;
this(T t)
{ this.t = t; }
auto get() inout
{
static if (is(T == S))
{
import std.traits : Unqual;
alias tType = Unqual!(typeof(t.vals));
pragma(msg, tType); // inout(int)[]
return new inout Temp!tType(t.vals); // ERROR: Can't create
class Temp!(inout(int)[])
}
}
}
}
unittest
{
auto t = Temp!S;
t.get();
}
Error: variable `onlineapp.Temp!(inout(int)[]).Temp.t` only parameters or stack
based variables can be inout
Error: template instance `onlineapp.Temp!(inout(int)[])` error instantiating
In this case a complete stripping of qualifiers is required!
Related discussion:
https://forum.dlang.org/post/enwkjtdqivjldqpzzqrw@forum.dlang.org
--
More information about the Digitalmars-d-bugs
mailing list