1 /*! ========================================================================
2 ** Extended Template and Library Test Suite
6 ** Copyright (c) 2002 Adrian Bentley
8 ** This package is free software; you can redistribute it and/or
9 ** modify it under the terms of the GNU General Public License as
10 ** published by the Free Software Foundation; either version 2 of
11 ** the License, or (at your option) any later version.
13 ** This package is distributed in the hope that it will be useful,
14 ** but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 ** General Public License for more details.
18 ** === N O T E S ===========================================================
20 ** ========================================================================= */
22 /* === H E A D E R S ======================================================= */
27 /* === M A C R O S ========================================================= */
31 /* === C L A S S E S ======================================================= */
33 /* === P R O C E D U R E S ================================================= */
35 /* === E N T R Y P O I N T ================================================= */
41 stupidv(float xin=0, float yin=0) :x(xin),y(yin) {}
44 printf("(x=%f,y=%f)\n",x,y);
52 stupidp(float zin=0, float win=0) :z(zin),w(win) {}
56 printf("(z=%f,w=%f)\n",z,w);
61 class etl::value_store_type<stupidp>
63 typedef stupidv value_type;
70 value v(10.0); //construction
71 value v2; //default construct...
74 printf("type of 10.0: %s\n", v.type().name());
77 printf("type of 1: %s\n", v2.type().name());
81 int *pi = value_cast<int>(&v2);
82 printf("v2 is an int(%p)\n", pi);
83 printf(" %d\n", value_cast<int>(v2));
85 printf(" const version: %d\n", value_cast<int>(value(5)));
87 v = 'c'; //assignment again...
88 printf("type of c: %s\n", v.type().name());
90 v2 = v; //value assignment
91 printf("type of v2 , v: %s , %s\n", v2.type().name(), v.type().name());
95 printf("type of vec: %s\n", v.type().name());
97 //type cast with binary change test
98 value_cast<stupidp>(&v)->print();
99 value_cast<stupidv>(stupidp(5,10)).print(); //copy test
101 printf("type of v: %s\n", v.type().name());
102 printf("type of v2: %s\n", v2.type().name());
104 printf("type of v: %s\n", v.type().name());
105 printf("type of v2: %s\n", v2.type().name());
107 // test the exception throwing...
108 value_cast<int>(stupidp(6,66));
110 }catch(const etl::bad_value_cast &e)
112 printf(" Exploded: %s\n",e.what());
115 printf(" Exploded\n");