summaryrefslogtreecommitdiffhomepage
path: root/test/test_samples/ostream.ncpp
blob: f9b4d441c531315e46e3eb9a142a8f7055750748 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
export ncpp::ostream;
import printf, getchar, malloc;

struct iostream
{
    type <class Tp_>
    void consume(Tp_& val)
    {
        printf("%p", val);
    }

    void consume<long>(long& val)
    {
	printf("%uz", val);
    }

    void consume<bool>(bool& val)
    {
	printf("%b", val);
    }
    
    long read()
    {
        return getchar();
    }
};

let shared_io()
{
	let io = malloc(sizeof(iostream));
	return io;
}