1 ///@nogc printing functions
2 module dgt.io;
3 import core.stdc.stdio;
4 
5 @nogc nothrow @trusted:
6 
7 ///Print the integer to stdout
8 void print(in int value)
9 {
10     printf("%d", value);
11 }
12 
13 ///Print the double to stdout
14 void print(in double value)
15 {
16     printf("%f", value);
17 }
18 
19 ///Call the print function of the object
20 void print(T)(in T obj)
21 {
22     obj.print();
23 }
24 
25 ///Print an array of items
26 void print(T)(in T[] items)
27 {
28     print(T.stringof, "[");
29     for(size_t i = 0; i < items.length; i++)
30     {
31         print(item);
32         if(i != items.length - 1)
33             print(", ");
34     }
35     print("]");
36 }
37 
38 ///Print a string (special case of an array)
39 void print(T:char)(in T[] items)
40 {
41     printf("%.*s", items.length, items.ptr);
42 }
43 
44 ////Print some number of objects
45 void print(T, A...)(in T obj, in A a)
46 {
47     print(obj);
48     foreach(val; a)
49         print(val);
50 }
51 
52 ///Print some number of objects followed by a newline
53 void println(A...)(in A values)
54 {
55     foreach(val; values)
56     {
57         print(val);
58     }
59     print("\n");
60 }