00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032 #ifndef _TEUCHOS_ORDINALTRAITS_HPP_
00033 #define _TEUCHOS_ORDINALTRAITS_HPP_
00034
00039 #include "Teuchos_ConfigDefs.hpp"
00040 #include <limits>
00041
00055
00056
00057
00058 namespace Teuchos {
00059
00060 template<class T>
00061 struct UndefinedOrdinalTraits
00062 {
00064 static inline T notDefined() { return T::this_type_is_missing_a_specialization(); }
00065 };
00066
00067 template<class T>
00068 struct OrdinalTraits {
00069
00071 static const bool hasMachineParameters = false;
00072
00074 static inline T zero() { return UndefinedOrdinalTraits<T>::notDefined(); }
00075
00077 static inline T one() { return UndefinedOrdinalTraits<T>::notDefined(); }
00078
00080
00083 static inline T max() { return UndefinedOrdinalTraits<T>::notDefined(); }
00084
00086 static inline T invalid() { return UndefinedOrdinalTraits<T>::notDefined(); }
00087
00089 static inline std::string name() { return UndefinedOrdinalTraits<T>::notDefined(); }
00090 };
00091
00092 #ifndef DOXYGEN_SHOULD_SKIP_THIS
00093
00094 template<>
00095 struct OrdinalTraits<char> {
00096 static const bool hasMachineParameters = false;
00097 static inline char zero() {return(0);}
00098 static inline char one() {return(1);}
00099 static inline char invalid() {return(-1);}
00100 static inline char max() {return(std::numeric_limits<char>::max());}
00101 static inline std::string name() {return("char");}
00102 };
00103
00104 template<>
00105 struct OrdinalTraits<short int> {
00106 static const bool hasMachineParameters = false;
00107 static inline short int zero() {return(0);}
00108 static inline short int one() {return(1);}
00109 static inline short int invalid() {return(-1);}
00110 static inline short int max() {return(std::numeric_limits<short int>::max());}
00111 static inline std::string name() {return("short int");}
00112 };
00113
00114 template<>
00115 struct OrdinalTraits<int> {
00116 static const bool hasMachineParameters = false;
00117 static inline int zero() {return(0);}
00118 static inline int one() {return(1);}
00119 static inline int invalid() {return(-1);}
00120 static inline int max() {return(std::numeric_limits<int>::max());}
00121 static inline std::string name() {return("int");}
00122 };
00123
00124 template<>
00125 struct OrdinalTraits<unsigned int> {
00126 static const bool hasMachineParameters = false;
00127 static inline unsigned int zero() {return(0);}
00128 static inline unsigned int one() {return(1);}
00129 static inline unsigned int invalid() {return(std::numeric_limits<unsigned int>::max());}
00130 static inline unsigned int max() {return(std::numeric_limits<unsigned int>::max()-1);}
00131 static inline std::string name() {return("unsigned int");}
00132 };
00133
00134 template<>
00135 struct OrdinalTraits<long int> {
00136 static const bool hasMachineParameters = false;
00137 static inline long int zero() {return(static_cast<long int>(0));}
00138 static inline long int one() {return(static_cast<long int>(1));}
00139 static inline long int invalid() {return(static_cast<long int>(-1));}
00140 static inline long int max() {return(std::numeric_limits<long int>::max());}
00141 static inline std::string name() {return("long int");}
00142 };
00143
00144 template<>
00145 struct OrdinalTraits<long unsigned int> {
00146 static const bool hasMachineParameters = false;
00147 static inline long unsigned int zero() {return(static_cast<long unsigned int>(0));}
00148 static inline long unsigned int one() {return(static_cast<long unsigned int>(1));}
00149 static inline long unsigned int invalid() {return(std::numeric_limits<long unsigned int>::max());}
00150 static inline long unsigned int max() {return(std::numeric_limits<long unsigned int>::max()-1);}
00151 static inline std::string name() {return("long unsigned int");}
00152 };
00153
00154 #ifdef HAVE_TEUCHOS_LONG_LONG_INT
00155 template<>
00156 struct OrdinalTraits<long long int> {
00157 static const bool hasMachineParameters = false;
00158 static inline long long int zero() {return(static_cast<long long int>(0));}
00159 static inline long long int one() {return(static_cast<long long int>(1));}
00160 static inline long long int invalid() {return(static_cast<long long int>(-1));}
00161 static inline long long int max() {return(LLONG_MAX);}
00162 static inline std::string name() {return("long long int");}
00163 };
00164 #endif // HAVE_TEUCHOS_LONG_LONG_INT
00165
00166 #endif // DOXYGEN_SHOULD_SKIP_THIS
00167
00168 }
00169
00170 #endif // _TEUCHOS_ORDINALTRAITS_HPP_