comparison run/mini/vararg4.d @ 1628:c6ef09dfba4d

add mini test set from ldc project
author Moritz Warning <moritzwarning@web.de>
date Mon, 10 Jan 2011 19:47:18 +0100
parents
children
comparison
equal deleted inserted replaced
1627:e1b954780837 1628:c6ef09dfba4d
1 module vararg4;
2
3 version(Tango)
4 {
5 import tango.core.Vararg;
6 }
7 else
8 {
9 import std.c.stdarg;
10 }
11 extern(C) int printf(char*, ...);
12
13 void vafunc(...)
14 {
15 foreach(i,v; _arguments) {
16 if (typeid(byte) == v) {
17 printf("byte(%d)\n", va_arg!(byte)(_argptr));
18 }
19 else if (typeid(short) == v) {
20 printf("short(%d)\n", va_arg!(short)(_argptr));
21 }
22 else if (typeid(int) == v) {
23 printf("int(%d)\n", va_arg!(int)(_argptr));
24 }
25 else if (typeid(long) == v) {
26 printf("long(%ld)\n", va_arg!(long)(_argptr));
27 }
28 else if (typeid(float) == v) {
29 printf("float(%f)\n", va_arg!(float)(_argptr));
30 }
31 else if (typeid(double) == v) {
32 printf("double(%f)\n", va_arg!(double)(_argptr));
33 }
34 else if (typeid(real) == v) {
35 printf("real(%f)\n", va_arg!(real)(_argptr));
36 }
37 else
38 assert(0, "unsupported type");
39 }
40 }
41
42 void main()
43 {
44 vafunc(byte.max,short.max,1,2,3,4L,5.0f,6.0,cast(real)7);
45 }