#ifndef __JMATH__JZERO__ #define __JMATH__JZERO__ /** * \file * * Definition of zero value for any class. * \author mdejong */ namespace JMATH {} namespace JPP { using namespace JMATH; } namespace JMATH { /** * Get zero value for a given data type. * * The default implementation of this method returns an object which * is created with the default constructor. * This method should be specialised if this value does not correspond * to the equivalent of a zero result. * * \return zero */ template inline T getZero() { return T(); } /** * Get zero value for bool. * * \return false */ template<> inline bool getZero() { return false; } /** * Get zero value for float. * * \return zero */ template<> inline float getZero() { return float(0.0); } /** * Get zero value for double. * * \return zero */ template<> inline double getZero() { return double(0.0); } /** * Get zero value for long double. * * \return zero */ template<> inline long double getZero() { return (long double)(0.0); } /** * Auxiliary class to assign zero value. */ struct JZero { /** * Default constructor. */ JZero() {} /** * Type conversion operator. * * \return zero */ template operator T() const { return getZero(); } }; /** * Function object to assign zero value. */ static const JZero zero; } #endif