hikyuu2/hikyuu_cpp/hikyuu/utilities/Null.h
2019-05-27 01:42:47 +08:00

114 lines
1.8 KiB
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/*
* Null.h
*
* Created on: 2012-8-23
* Author: fasiondog
*/
#ifndef NULL_H_
#define NULL_H_
#include <boost/limits.hpp>
#include <boost/type_traits.hpp>
namespace hku {
/**
* 提供指定给定类型的Null值
* @ingroup Common-Utilities
* @ingroup DataType
*/
template <typename T>
class Null {
public:
Null() {}
operator T() const {
return T();
}
};
/**
* 提供int的Null值
* @ingroup Common-Utilities
*/
template <>
class Null<int> {
public:
Null() {}
operator int() {
return (std::numeric_limits<int>::max)();
}
};
/**
* 提供unsigned int的Null值
* @ingroup Common-Utilities
*/
template <>
class Null<unsigned int> {
public:
Null() {}
operator unsigned int() {
return (std::numeric_limits<unsigned int>::max)();
}
};
/**
* 提供long long64位整型的Null值
* @ingroup Common-Utilities
*/
template <>
class Null<long long> {
public:
Null() {}
operator long long() {
return (std::numeric_limits<long long>::max)();
}
};
/**
* 提供unsigned long long无符号64位整型的Null值
* @ingroup Common-Utilities
*/
template <>
class Null<unsigned long long> {
public:
Null() {}
operator unsigned long long() {
return (std::numeric_limits<unsigned long long>::max)();
}
};
#if !defined(BOOST_MSVC)
/**
* 提供size_t的Null值
* @ingroup Common-Utilities
*/
template <>
class Null<size_t> {
public:
Null() {}
operator unsigned long long() {
return (std::numeric_limits<size_t>::max)();
}
};
#endif
/**
* 提供double的Null值
* @ingroup Common-Utilities
*/
template <>
class Null<double> {
public:
Null() {}
operator double() {
return (std::numeric_limits<double>::quiet_NaN)();
//return (std::numeric_limits<double>::max)();
}
};
} /* namesapce hku */
#endif /* NULL_H_ */