Given the following program:

---------------------------------
import std.stdio;

template first(string s)
{
        string first(string par)
        {
                if (par == s)
                        return "true";
                else
                        return "false";
        }
}

template second(alias firstInstance)
{
        string second(string par)
        {
                // this line doesn't work
                static if (is(firstInstance : F!(str), alias F, string str))
                {
                        writeln("matched ", str);
                }
                
                enum s = "XXX"; // get s from firstInstance
                // without parsing strings and using mixins
                // something like second(alias C : F!(str), alias F, string str)
                
                import std.string : icmp;
                if (icmp(par, s) == 0)
                        return "true";
                else
                        return "false";
        }
}

void main()
{
        writeln(first!"str"("str"));
writeln(second!( first!"str" )("StR")); // should match string from first, but case insensetive
}

---------------------------------

How do I extract s parameter of first passed to second via alias parameter. It seems like it is not possible. Or is it?

Reply via email to