D compile time algorithms implementation

khurshid khurshid.normuradov at gmail.com
Wed Apr 24 01:46:03 PDT 2013


Is this code right?


template templateAnd(Preds...)
{
       template templateAnd(T...)
       {
           static if (Preds.length == 0)
           {
               enum  templateAnd = true;
           }
           else static if (Preds.length == 1)
           {
			enum  templateAnd = Instantiate!(Preds[0],T);
		}
		else
		{
			static if (Instantiate!(.templateAnd(Preds[0..$/2]),T))
			{
			   enum  templateAnd =
Instantiate!(.templateAnd(Preds[$/2..$]),T);
			}
			else
			{
				enum  templateAnd = false;
			}
		}
       }
}

here
    template Instantiate(alias P, T...)
    {
	 alias Instantiate = P!(T);
    }


More information about the Digitalmars-d mailing list