#ifndef __JMATH__JLIMITS__ #define __JMATH__JLIMITS__ #include /** * \file * * Definition of minimum and maximum values for any class. * \author mdejong */ namespace JMATH {} namespace JPP { using namespace JMATH; } namespace JMATH { /** * Auxiliary class for minimum and maximum values for any class. */ template::is_specialized> struct JLimits; /** * Template spacialisation of JMATH::JLimits for numerical values. */ template struct JLimits { /** * Get minimum possible value. * * \return minimum possible value */ static T min() { return std::numeric_limits::min(); } /** * Get maximum possible value. * * \return maximum possible value */ static T max() { return std::numeric_limits::max(); } static const bool is_specialized = true; }; /** * Template spacialisation of JMATH::JRandom for other data types. * * The given template class should provide for the methods: *
   *      static T %min();
   *      static T %max();
   * 
*/ template struct JLimits { /** * Get minimum possible value. * * \return minimum possible value */ static T min() { return T::min(); } /** * Get maximum possible value. * * \return maximum possible value */ static T max() { return T::max(); } static const bool is_specialized = false; }; /** * Get minimum possible value. * * \return minimum possible value */ template<> inline float JLimits::min() { return std::numeric_limits::lowest(); } /** * Get minimum possible value. * * \return minimum possible value */ template<> inline double JLimits::min() { return std::numeric_limits::lowest(); } /** * Get minimum possible value. * * \return minimum possible value */ template<> inline long double JLimits::min() { return std::numeric_limits::lowest(); } } #endif