2010-06-23 23:03:09 -05:00
|
|
|
obj buf[T](tup(T,T,T) data) {
|
|
|
|
fn get(int i) -> T {
|
|
|
|
if (i == 0) {
|
|
|
|
ret data._0;
|
|
|
|
} else {
|
|
|
|
if (i == 1) {
|
|
|
|
ret data._1;
|
|
|
|
} else {
|
|
|
|
ret data._2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2010-06-28 23:45:48 -05:00
|
|
|
|
2010-06-29 02:48:49 -05:00
|
|
|
fn take(&T t) {}
|
2011-01-26 13:39:48 -06:00
|
|
|
fn take2(&T t) {}
|
2010-06-23 23:03:09 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
let buf[int] b = buf[int](tup(1,2,3));
|
|
|
|
log "constructed object";
|
|
|
|
log b.get(0);
|
|
|
|
log b.get(1);
|
|
|
|
log b.get(2);
|
2011-05-02 18:24:09 -05:00
|
|
|
check (b.get(0) == 1);
|
|
|
|
check (b.get(1) == 2);
|
|
|
|
check (b.get(2) == 3);
|
2010-07-26 17:52:59 -05:00
|
|
|
b.take2(0);
|
2010-06-23 23:03:09 -05:00
|
|
|
}
|