Main Page | Class Hierarchy | Compound List | File List | Compound Members | File Members

typename_test.cc

Go to the documentation of this file.
00001 /*--------------------------------------------------------------------
00002  *
00003  * (C) Copyright Koninklijke Philips Electronics NV 2006. 
00004  * All rights reserved. This software is licensed under the terms of
00005  * version 2.1 of the GNU Lesser General Public License as published 
00006  * by the Free Software Foundation. For licensing and warranty
00007  * information, see the file COPYING in the main directory.
00008  *
00009  *------------------------------------------------------------------*/
00010 
00011 #include "typename.h"
00012 #include <iostream>
00013 
00014 using std::cout;
00015 using std::cerr;
00016 using std::endl;
00017 
00018 class SmurfOrGargamel
00019 {
00020 public:
00021   //virtual produces memory fault
00022   //virtual char* valueTypeName() const { return typeName(*this); }
00023   char* valueTypeName() const { return typeName(*this); }
00024 };
00025 
00026 class Smurf : public SmurfOrGargamel
00027 {
00028 public:
00029 };
00030 
00031 template<class B, class C>
00032 class A
00033 {
00034   B x;
00035   C y;
00036 };
00037 
00038 template<class T>
00039 class X
00040 {
00041 public:
00042   X() {}
00043   char* valueTypeName() const { return typeName(t); }
00044 private:
00045   T t;
00046 };
00047 
00048 main()
00049 {
00050   bool b;
00051   cout << typeName(b) << endl;
00052 
00053   unsigned char c;
00054   cout << typeName(c) << endl;
00055 
00056   unsigned short h;
00057   cout << typeName(h) << endl;
00058 
00059   unsigned int* i;
00060   cout << typeName(i) << endl;
00061 
00062   SmurfOrGargamel* s;
00063   cout << typeName(s) << endl;
00064   cout << s->valueTypeName() << endl;
00065 
00066   const Smurf** r;
00067   cout << typeName(r) << endl;
00068   cout << (*r)->valueTypeName() << endl;
00069 
00070   A<int,float>* a;
00071   cout << typeName(a) << endl;
00072 
00073   X< A<unsigned int, SmurfOrGargamel>* > x;
00074   cout << typeName(x) << endl;
00075   cout << x.valueTypeName() << endl;
00076 }

Generated on Wed Feb 15 14:52:39 2006 for yapi by doxygen 1.3.2