Teuchos_OrdinalTraits.hpp

Go to the documentation of this file.
00001 // @HEADER
00002 // ***********************************************************************
00003 // 
00004 //                    Teuchos: Common Tools Package
00005 //                 Copyright (2004) Sandia Corporation
00006 // 
00007 // Under terms of Contract DE-AC04-94AL85000, there is a non-exclusive
00008 // license for use of this work by or on behalf of the U.S. Government.
00009 // 
00010 // This library is free software; you can redistribute it and/or modify
00011 // it under the terms of the GNU Lesser General Public License as
00012 // published by the Free Software Foundation; either version 2.1 of the
00013 // License, or (at your option) any later version.
00014 //  
00015 // This library is distributed in the hope that it will be useful, but
00016 // WITHOUT ANY WARRANTY; without even the implied warranty of
00017 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00018 // Lesser General Public License for more details.
00019 //  
00020 // You should have received a copy of the GNU Lesser General Public
00021 // License along with this library; if not, write to the Free Software
00022 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
00023 // USA
00024 // Questions? Contact Michael A. Heroux (maherou@sandia.gov) 
00025 // 
00026 // ***********************************************************************
00027 // @HEADER
00028 
00029 // Kris
00030 // 07.08.03 -- Move into Teuchos package/namespace
00031 
00032 #ifndef _TEUCHOS_ORDINALTRAITS_HPP_
00033 #define _TEUCHOS_ORDINALTRAITS_HPP_
00034 
00039 #include "Teuchos_ConfigDefs.hpp"
00040 
00054 /* This is the default structure used by OrdinalTraits<T> to produce a compile time
00055    error when the specialization does not exist for type <tt>T</tt>.
00056 */
00057 namespace Teuchos {
00058 
00059 template<class T>
00060 struct UndefinedOrdinalTraits
00061 {
00063   static inline T notDefined() { return T::this_type_is_missing_a_specialization(); }
00064 };
00065   
00066 template<class T>
00067 struct OrdinalTraits {
00068 
00070   static const bool hasMachineParameters = false;
00071     
00073   static inline T zero()                     { return UndefinedOrdinalTraits<T>::notDefined(); }
00074 
00076   static inline T one()                      { return UndefinedOrdinalTraits<T>::notDefined(); }
00077 
00079   static inline std::string name()           { return UndefinedOrdinalTraits<T>::notDefined(); }
00080 };
00081   
00082 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00083 
00084 template<>
00085 struct OrdinalTraits<char> {
00086   static const bool hasMachineParameters = false;
00087   static inline char zero()                   {return(0);}
00088   static inline char one()                    {return(1);}
00089   static inline std::string name()           {return("char");}
00090 };
00091 
00092 template<>
00093 struct OrdinalTraits<short int> {
00094   static const bool hasMachineParameters = false;
00095   static inline short int zero()                   {return(0);}
00096   static inline short int one()                    {return(1);}
00097   static inline std::string name()           {return("short int");}
00098 };
00099 
00100 template<>
00101 struct OrdinalTraits<int> {
00102   static const bool hasMachineParameters = false;
00103   static inline int zero()                   {return(0);}
00104   static inline int one()                    {return(1);}
00105   static inline std::string name()           {return("int");}
00106 };
00107 
00108 template<>
00109 struct OrdinalTraits<long int> {
00110   static const bool hasMachineParameters = false;
00111   static inline long int zero()              {return(static_cast<long int>(0));}
00112   static inline long int one()               {return(static_cast<long int>(1));}
00113   static inline std::string name()           {return("long int");}
00114 };
00115 
00116 #ifdef HAVE_TEUCHOS_LONG_LONG_INT
00117 
00118 template<>
00119 struct OrdinalTraits<long long int> {
00120   static const bool hasMachineParameters = false;
00121   static inline long long int zero() {return(static_cast<long long int>(0));}
00122   static inline long long int one() {return(static_cast<long long int>(1));}
00123   static inline std::string name() {return("long long int");}
00124 };
00125 
00126 #endif // HAVE_TEUCHOS_LONG_LONG_INT
00127 
00128 #endif // DOXYGEN_SHOULD_SKIP_THIS
00129 
00130 } // namespace Teuchos
00131 
00132 #endif // _TEUCHOS_ORDINALTRAITS_HPP_

Generated on Wed May 12 21:40:32 2010 for Teuchos - Trilinos Tools Package by  doxygen 1.4.7