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<int> {
00086 
00087     static const bool hasMachineParameters = false;
00088     static inline int zero()                   {return(0);};
00089     static inline int one()                    {return(1);};
00090     static inline std::string name()           {return("int");};
00091   };
00092 
00093   template<>
00094   struct OrdinalTraits<long int> {
00095 
00096     static const bool hasMachineParameters = false;
00097     static inline long int zero()              {return(static_cast<long int>(0));};
00098     static inline long int one()               {return(static_cast<long int>(1));};
00099     static inline std::string name()           {return("long int");};
00100   };
00101 
00102 #endif
00103 
00104 } // namespace Teuchos
00105 
00106 #endif // _TEUCHOS_ORDINALTRAITS_HPP_

Generated on Thu Sep 18 12:39:10 2008 for Teuchos - Trilinos Tools Package by doxygen 1.3.9.1