On Wednesday, 22 July 2015 at 05:02:59 UTC, Timon Gehr wrote:
template Uks(T){
    T query(string q){
        T result;
        static if(is(T==S[],S)){
            ulong test=result.length;
            // append
            S newResult;
            result~=newResult;
        }else{
            // assign
        }
        return result;
    }
}

void main(){
    struct U_Struct{}
    auto res1=Uks!(U_Struct).query("email");
    auto res2=Uks!(U_Struct[]).query("email");
}

Oh that's phenomenal. Thanks!

For reference, the is() function can accept template parameters. More here, under isExpression
http://dlang.org/expression.html

Reply via email to