00001 #ifndef PhysicsTools_Utilities_Sqrt_h 00002 #define PhysicsTools_Utilities_Sqrt_h 00003 #include <cmath> 00004 00005 namespace funct { 00006 00007 template<typename T> 00008 struct SqrtStruct { 00009 SqrtStruct(const T& t) : _(t) { } 00010 inline double operator()() const { return ::sqrt(_()); } 00011 inline operator double() const { return ::sqrt(_()); } 00012 T _; 00013 }; 00014 00015 template<typename T> 00016 struct Sqrt { 00017 typedef SqrtStruct<T> type; 00018 inline static type compose(const T& t) { return type(t); } 00019 }; 00020 00021 template<typename T> 00022 inline typename Sqrt<T>::type sqrt(const T & t) { 00023 return Sqrt<T>::compose(t); 00024 } 00025 00026 } 00027 00028 #endif