#include #include "AbsArgCast.h" #include "AbsArg.h" #include "AbsArgVal.h" #include "IfdTypeKeyIFace.h" using std::cout; using std::endl; void f( AbsArg& a ); void AbsArgTest(){ double d=3.1; int i=5; cout << "testing AbsArgs..."<< endl; cout << endl; //cout << "sizeof(AbsArg) =" << sizeof( AbsArg) << endl; //cout << "sizeof(AbsArgVal)=" << sizeof( AbsArgVal ) << endl; //cout << endl; cout << "Explicitly create typed-AbsArgVal's" << endl; AbsArgVal ad( &d ); AbsArgVal ai( &i ); cout << endl; cout << "Call f( AbsArg ) using AbsArgVal and AbsArgVal args.." << endl; cout << "Expect output of 'got a double' followed by 'not found'" <getTypeKey() == pi->getTypeKey() ) || ( pd->getTypeKey() != ad.getTypeKey() ) || ( pi->getTypeKey() != ai.getTypeKey() ) || ( AbsArgCast::value( pd ) != AbsArgCast::value( ad )) || ( AbsArgCast::value( pi ) != AbsArgCast::value( ai ) ) ) { cout << "Error: failed clone test." << endl; } else { cout << "Pass." << endl; } // the following converstion does not wok // //cout << "Test auto converstion of T to AbsArgVal for fn with" // << " signature of f( AbsArg)" // << endl; // //f( 4.2 ); //f( 1 ); exit(0); } void f( AbsArg& a ) { double *d = 0; d = AbsArgCast::value( a ); if ( 0 != d ) { cout << "f: got a double arg of " << *d << endl; } else { cout << "f: did not find a value" << endl; } }