00001 /*************************************************************************** 00002 LibUFO - UI For OpenGL 00003 copyright : (C) 2001-2005 by Johannes Schmidt 00004 email : schmidtjf at users.sourceforge.net 00005 ------------------- 00006 00007 file : include/ufo/utrait.hpp 00008 begin : Thu Jul 25 2002 00009 $Id: utrait.hpp,v 1.8 2005/02/13 17:49:31 schmidtjf Exp $ 00010 ***************************************************************************/ 00011 00012 /*************************************************************************** 00013 * This library is free software; you can redistribute it and/or * 00014 * modify it under the terms of the GNU Lesser General Public * 00015 * License as published by the Free Software Foundation; either * 00016 * version 2.1 of the License, or (at your option) any later version. * 00017 * * 00018 * This library is distributed in the hope that it will be useful, * 00019 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00020 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU * 00021 * Lesser General Public License for more details. * 00022 * * 00023 * You should have received a copy of the GNU Lesser General Public * 00024 * License along with this library; if not, write to the Free Software * 00025 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA * 00026 ***************************************************************************/ 00027 00028 #ifndef UTRAIT_HPP 00029 #define UTRAIT_HPP 00030 00031 namespace ufo { 00032 00033 // thanks to libsigc++ (http://libsigc.sf.net) 00034 // gratefully taken from trait.h 00035 00036 #undef UFO_SPECIALIZE_REFERENCES 00037 // nock - 2002-10-06 00038 // Using non-const references does not accept temporarily created objects. 00039 // As all UFO signals use pointers or basic types 00040 // copying shouldn't be a problem 00041 00042 #ifdef UFO_SPECIALIZE_REFERENCES 00043 00044 template <typename T> 00045 struct UTrait { 00046 typedef T type; 00047 typedef T& ref; 00048 //typedef T* ptr; 00049 }; 00050 00051 // FIXME 00052 // this needs partial template specialization 00053 template <typename T> 00054 struct UTrait<T&> { 00055 typedef T& type; 00056 typedef T& ref; 00057 //typedef T* ptr; 00058 }; 00059 00060 template <typename T> 00061 struct UTrait<T*> { 00062 typedef T* type; 00063 typedef T* ref; 00064 //typedef T* ptr; 00065 }; 00066 00067 #else 00068 00069 // for really dumb compilers, we have to copy rather than reference 00070 template <class T> 00071 struct UTrait { 00072 typedef T type; 00073 typedef T ref; 00074 }; 00075 00076 #endif // UFO_SPECIALIZE_REFERENCES 00077 00078 } // namespace ufo 00079 00080 #endif // UTRAIT_HPP