https://issues.dlang.org/show_bug.cgi?id=3567

Timoses <timos...@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |timos...@gmail.com

--- Comment #5 from Timoses <timos...@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/enwkjtdqivjldqpzz...@forum.dlang.org

--

Reply via email to