Main Page | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members

FloatCast.hpp

Go to the documentation of this file.
00001 /* ImLib3D
00002  * Copyright (c) 2001, ULP-IPB Strasbourg.
00003  *
00004  * This program is free software; you can redistribute it and/or modify
00005  * it under the terms of the GNU General Public License as published by
00006  * the Free Software Foundation; either version 2 of the License, or (at
00007  * your option) any later version.
00008  * 
00009  * This program is distributed in the hope that it will be useful, but
00010  * WITHOUT ANY WARRANTY; without even the implied warranty of
00011  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00012  * General Public License for more details.
00013  * 
00014  * You should have received a copy of the GNU General Public License
00015  * along with this program; if not, write to the Free Software
00016  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
00017  */
00019 #ifndef _FloatCast_hpp
00020 #define _FloatCast_hpp
00021 
00022 #include<ImLib3D/CppTools.hpp>
00023 #include<boost/type_traits/is_arithmetic.hpp>
00024 
00026 template<typename T,bool isArithmetic=boost::is_arithmetic<T>::value >
00027 struct FloatCast
00028 {
00029     static float Cast(const T &)
00030     {
00031         ThrowError("FloatCast type \"%s\" was not configured to be cast to float",TypeName<T>());
00032         return 0;
00033     }
00034 };
00035 template<typename T>
00036 struct FloatCast<T,true>
00037 {
00038     static float Cast(const T &value)
00039     {
00040         return (float)value;
00041     }
00042 };
00043 #endif // _FloatCast_hpp

Generated on Fri Jun 17 13:36:03 2005 for ImLib3D by  doxygen 1.4.2