2 import core.stdc.stdio;
4 /*********************************************************/
8 static if (is(T : int))
11 static if (T.sizeof == 4)
14 static if (is(T U : int))
17 static if (is(T* V : V*))
25 static if (is(T* X : X*))
33 assert(typeid(typeof(x1)) == typeid(int));
36 assert(typeid(typeof(x2)) == typeid(int));
39 assert(typeid(typeof(x3)) == typeid(int));
42 assert(typeid(typeof(x4)) == typeid(int*));
45 assert(typeid(typeof(x5)) == typeid(int));
48 assert(typeid(typeof(x6)) == typeid(int));
51 /*********************************************************/
58 static if (is(T : int))
61 static if (T.sizeof == 4)
64 static if (is(T U : int))
67 static if (is(T* V : V*))
75 static if (is(T* X : X*))
80 assert(typeid(typeof(x1)) == typeid(int));
83 assert(typeid(typeof(x2)) == typeid(int));
86 assert(typeid(typeof(x3)) == typeid(int));
89 assert(typeid(typeof(x4)) == typeid(int));
92 assert(typeid(typeof(x5)) == typeid(int));
95 assert(typeid(typeof(x6)) == typeid(int));
98 /*********************************************************/
102 static if (is(short : int))
107 static if (is(short == int))
109 static if (is(int == int))
116 /*********************************************************/
118 template TValue(int i:1)
120 pragma(msg,"last instantiation!!!");
121 const int TValue = 1;
124 template TValue(int i)
126 pragma(msg,"instantiating...");
127 const int TValue = i * TValue!(i-1);
132 assert(TValue!(3) == 6);
135 /*********************************************************/
137 template Reverse(string s: "") {
138 const char[] Reverse = "";
141 template Reverse(string s) {
142 const char[] Reverse = Reverse!(s[1..$]) ~ s[0];
147 assert(Reverse!("Recursive string template") == "etalpmet gnirts evisruceR");
150 /*********************************************************/
152 template foo6(alias V)
178 bar6!(j) b = new bar6!(j);
184 /*********************************************************/
186 template Bind7(alias dg)
199 void foo(char c) { v ~= c; }
201 alias Bind7!(foo) intv;
206 /*********************************************************/
208 template sum8(real x)
210 static if (x <= 1.0L){
213 const real sum8 = x + sum8!(x - 1.0L);
219 real x = sum8!(3.0L);
226 /*********************************************************/