eating inout dogfood
Michel Fortin
michel.fortin at michelf.com
Fri Oct 14 17:21:59 PDT 2011
On 2011-10-14 20:05:09 +0000, "Steven Schveighoffer"
<schveiguy at yahoo.com> said:
> I don't think the compiler will auto-convert someTemplate!(inout(V)) to
> e.g. someTemplate!(const(V)). Does that work? I know that for
> instance, I can't do this:
>
> struct S(T)
> {
> T * x;
> }
>
> S!(int) ptr;
> S!(const(int)) cptr = ptr;
>
> So I wouldn't expect the compiler to do the above translation either...
Perhaps you can add this to the struct:
void this(U)(in S!U other) if (__traits(compiles, this.x = other.x))
{
this.x = other.x;
}
If that works, maybe a similar approach could be used to solve the
problem with inout: if you can construct the requested type from the
provided one it get converted automatically at the call site.
--
Michel Fortin
michel.fortin at michelf.com
http://michelf.com/
More information about the Digitalmars-d
mailing list