Go to the documentation of this file.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 #ifndef EIGEN2_META_H
00026 #define EIGEN2_META_H
00027
00028 template<typename T>
00029 struct ei_traits : internal::traits<T>
00030 {};
00031
00032 struct ei_meta_true { enum { ret = 1 }; };
00033 struct ei_meta_false { enum { ret = 0 }; };
00034
00035 template<bool Condition, typename Then, typename Else>
00036 struct ei_meta_if { typedef Then ret; };
00037
00038 template<typename Then, typename Else>
00039 struct ei_meta_if <false, Then, Else> { typedef Else ret; };
00040
00041 template<typename T, typename U> struct ei_is_same_type { enum { ret = 0 }; };
00042 template<typename T> struct ei_is_same_type<T,T> { enum { ret = 1 }; };
00043
00044 template<typename T> struct ei_unref { typedef T type; };
00045 template<typename T> struct ei_unref<T&> { typedef T type; };
00046
00047 template<typename T> struct ei_unpointer { typedef T type; };
00048 template<typename T> struct ei_unpointer<T*> { typedef T type; };
00049 template<typename T> struct ei_unpointer<T*const> { typedef T type; };
00050
00051 template<typename T> struct ei_unconst { typedef T type; };
00052 template<typename T> struct ei_unconst<const T> { typedef T type; };
00053 template<typename T> struct ei_unconst<T const &> { typedef T & type; };
00054 template<typename T> struct ei_unconst<T const *> { typedef T * type; };
00055
00056 template<typename T> struct ei_cleantype { typedef T type; };
00057 template<typename T> struct ei_cleantype<const T> { typedef typename ei_cleantype<T>::type type; };
00058 template<typename T> struct ei_cleantype<const T&> { typedef typename ei_cleantype<T>::type type; };
00059 template<typename T> struct ei_cleantype<T&> { typedef typename ei_cleantype<T>::type type; };
00060 template<typename T> struct ei_cleantype<const T*> { typedef typename ei_cleantype<T>::type type; };
00061 template<typename T> struct ei_cleantype<T*> { typedef typename ei_cleantype<T>::type type; };
00062
00066 template<int Y,
00067 int InfX = 0,
00068 int SupX = ((Y==1) ? 1 : Y/2),
00069 bool Done = ((SupX-InfX)<=1 ? true : ((SupX*SupX <= Y) && ((SupX+1)*(SupX+1) > Y))) >
00070
00071 class ei_meta_sqrt
00072 {
00073 enum {
00074 MidX = (InfX+SupX)/2,
00075 TakeInf = MidX*MidX > Y ? 1 : 0,
00076 NewInf = int(TakeInf) ? InfX : int(MidX),
00077 NewSup = int(TakeInf) ? int(MidX) : SupX
00078 };
00079 public:
00080 enum { ret = ei_meta_sqrt<Y,NewInf,NewSup>::ret };
00081 };
00082
00083 template<int Y, int InfX, int SupX>
00084 class ei_meta_sqrt<Y, InfX, SupX, true> { public: enum { ret = (SupX*SupX <= Y) ? SupX : InfX }; };
00085
00086 #endif // EIGEN2_META_H