blob: c4838dfe43506cd4659935e4d9e34b0c1f7a889a (
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
using System;
class Foo {
static int t_count = 0, f_count = 0;
public static int Main ()
{
Console.WriteLine (t && f);
if (t_count != 1)
return 1;
if (f_count != 1)
return 2;
Console.WriteLine ();
Console.WriteLine (t && t);
if (t_count != 3)
return 3;
if (f_count != 1)
return 4;
Console.WriteLine ();
return 0;
}
static MyBool t { get { Console.WriteLine ("t"); t_count++; return new MyBool (true); }}
static MyBool f { get { Console.WriteLine ("f"); f_count++; return new MyBool (false); }}
}
public struct MyBool {
bool v;
public MyBool (bool v) { this.v = v; }
public static MyBool operator & (MyBool x, MyBool y) {
return new MyBool (x.v & y.v);
}
public static MyBool operator | (MyBool x, MyBool y) {
return new MyBool (x.v | y.v);
}
public static bool operator true (MyBool x) {
return x.v;
}
public static bool operator false (MyBool x) {
return ! x.v;
}
public override string ToString () { return v.ToString (); }
}
|