#include #include "tuple.h" #ifndef NO_STRING #include #endif int main(int argc, char** argv) { tuple p; int x=0, y=0; p = tuple(1,2); #ifndef NO_IO std::cout << p << std::endl; #endif p = tuple(3,4); #ifndef NO_IO std::cout << p << std::endl; std::cout << x << "," << y << std::endl; #endif assert(x==0); assert(y==0); tie(x,y) = p; #ifndef NO_IO std::cout << x << "," << y << std::endl; #endif assert(x==3); assert(y==4); p = tuple(5,6); #ifndef NO_IO std::cout << p << std::endl; std::cout << x << "," << y << std::endl; #endif assert(x==3); assert(y==4); x = 42; y = 69; #ifndef NO_IO std::cout << p << std::endl; std::cout << x << "," << y << std::endl; #endif assert(x==42); assert(y==69); tuple q; q = tuple(true,false); #ifndef NO_IO std::cout << q << std::endl; #endif bool foo, bar; tie(foo,bar) = q; #ifndef NO_IO std::cout << foo << " " << bar << std::endl; #endif assert(foo); assert(!bar); tuple one; one = 69; #ifndef NO_IO std::cout << one << std::endl; #endif tie(x) = one; #ifndef NO_IO std::cout << x << std::endl; #endif assert(x==69); #ifndef NO_STRING tuple three; three = tuple(42," does not equal ",69); #ifndef NO_IO std::cout << three << std::endl; #endif tuple four; four = tuple("and ", 42," is less than ",69); #ifndef NO_IO std::cout << four << std::endl; #endif tuple msg; msg = tuple("hello","world"); #ifndef NO_IO std::cout << msg << std::endl; #endif std::string xx,yy; tie(xx,yy) = tuple("hello","world"); #ifndef NO_IO std::cout << xx << " " << yy << std::endl; #endif assert(xx=="hello"); assert(yy=="world"); #endif }