x
Yes
No
Do you want to visit DriveHQ English website?
首页
产品服务
价格
免费试用
下载客户端
关于我们
云文件服务
|
云备份服务
|
FTP服务
|
企业邮箱服务
|
网站托管
|
客户端软件
云文件服务
云备份服务
FTP服务
企业级邮箱服务
网站托管
客户端软件
std_real_concept.hpp - Hosted on DriveHQ Cloud IT Platform
返回上层目录
上传
下载
共享
发布
新建文件夹
新建文件
复制
剪切
删除
粘贴
评论
升级服务
路径: \\game3dprogramming\materials\GameFactory\GameFactoryDemo\references\boost_1_35_0\boost\math\concepts\std_real_concept.hpp
旋转
特效
属性
历史版本
// Copyright John Maddock 2006. // Use, modification and distribution are subject to the // Boost Software License, Version 1.0. (See accompanying file // LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) // std_real_concept is an archetype for built-in Real types. // The main purpose in providing this type is to verify // that std lib functions are found via a using declaration // bringing those functions into the current scope, and not // just because they happen to be in global scope. // // If ::pow is found rather than std::pow say, then the code // will silently compile, but truncation of long doubles to // double will cause a significant loss of precision. // A template instantiated with std_real_concept will *only* // compile if it std::whatever is in scope. #include
#include
#include
#include
#include
#include
#include
#include
#include
// fmodl #ifndef BOOST_MATH_STD_REAL_CONCEPT_HPP #define BOOST_MATH_STD_REAL_CONCEPT_HPP namespace boost{ namespace math{ namespace concepts { class std_real_concept { public: // Constructors: std_real_concept() : m_value(0){} std_real_concept(char c) : m_value(c){} #ifndef BOOST_NO_INTRINSIC_WCHAR_T std_real_concept(wchar_t c) : m_value(c){} #endif std_real_concept(unsigned char c) : m_value(c){} std_real_concept(signed char c) : m_value(c){} std_real_concept(unsigned short c) : m_value(c){} std_real_concept(short c) : m_value(c){} std_real_concept(unsigned int c) : m_value(c){} std_real_concept(int c) : m_value(c){} std_real_concept(unsigned long c) : m_value(c){} std_real_concept(long c) : m_value(c){} #if defined(BOOST_HAS_LONG_LONG) || defined(__DECCXX) || defined(__SUNPRO_CC) std_real_concept(unsigned long long c) : m_value(static_cast
(c)){} std_real_concept(long long c) : m_value(static_cast
(c)){} #endif std_real_concept(float c) : m_value(c){} std_real_concept(double c) : m_value(c){} std_real_concept(long double c) : m_value(c){} // Assignment: std_real_concept& operator=(char c) { m_value = c; return *this; } std_real_concept& operator=(unsigned char c) { m_value = c; return *this; } std_real_concept& operator=(signed char c) { m_value = c; return *this; } #ifndef BOOST_NO_INTRINSIC_WCHAR_T std_real_concept& operator=(wchar_t c) { m_value = c; return *this; } #endif std_real_concept& operator=(short c) { m_value = c; return *this; } std_real_concept& operator=(unsigned short c) { m_value = c; return *this; } std_real_concept& operator=(int c) { m_value = c; return *this; } std_real_concept& operator=(unsigned int c) { m_value = c; return *this; } std_real_concept& operator=(long c) { m_value = c; return *this; } std_real_concept& operator=(unsigned long c) { m_value = c; return *this; } #if defined(BOOST_HAS_LONG_LONG) || defined(__DECCXX) || defined(__SUNPRO_CC) std_real_concept& operator=(long long c) { m_value = static_cast
(c); return *this; } std_real_concept& operator=(unsigned long long c) { m_value = static_cast
(c); return *this; } #endif std_real_concept& operator=(float c) { m_value = c; return *this; } std_real_concept& operator=(double c) { m_value = c; return *this; } std_real_concept& operator=(long double c) { m_value = c; return *this; } // Access: long double value()const{ return m_value; } // Member arithmetic: std_real_concept& operator+=(const std_real_concept& other) { m_value += other.value(); return *this; } std_real_concept& operator-=(const std_real_concept& other) { m_value -= other.value(); return *this; } std_real_concept& operator*=(const std_real_concept& other) { m_value *= other.value(); return *this; } std_real_concept& operator/=(const std_real_concept& other) { m_value /= other.value(); return *this; } std_real_concept operator-()const { return -m_value; } std_real_concept const& operator+()const { return *this; } private: long double m_value; }; // Non-member arithmetic: inline std_real_concept operator+(const std_real_concept& a, const std_real_concept& b) { std_real_concept result(a); result += b; return result; } inline std_real_concept operator-(const std_real_concept& a, const std_real_concept& b) { std_real_concept result(a); result -= b; return result; } inline std_real_concept operator*(const std_real_concept& a, const std_real_concept& b) { std_real_concept result(a); result *= b; return result; } inline std_real_concept operator/(const std_real_concept& a, const std_real_concept& b) { std_real_concept result(a); result /= b; return result; } // Comparison: inline bool operator == (const std_real_concept& a, const std_real_concept& b) { return a.value() == b.value(); } inline bool operator != (const std_real_concept& a, const std_real_concept& b) { return a.value() != b.value();} inline bool operator < (const std_real_concept& a, const std_real_concept& b) { return a.value() < b.value(); } inline bool operator <= (const std_real_concept& a, const std_real_concept& b) { return a.value() <= b.value(); } inline bool operator > (const std_real_concept& a, const std_real_concept& b) { return a.value() > b.value(); } inline bool operator >= (const std_real_concept& a, const std_real_concept& b) { return a.value() >= b.value(); } #if 0 // Non-member mixed compare: template
inline bool operator == (const T& a, const std_real_concept& b) { return a == b.value(); } template
inline bool operator != (const T& a, const std_real_concept& b) { return a != b.value(); } template
inline bool operator < (const T& a, const std_real_concept& b) { return a < b.value(); } template
inline bool operator > (const T& a, const std_real_concept& b) { return a > b.value(); } template
inline bool operator <= (const T& a, const std_real_concept& b) { return a <= b.value(); } template
inline bool operator >= (const T& a, const std_real_concept& b) { return a >= b.value(); } #endif // Non-member mixed compare: } // namespace concepts } // namespace math } // namespace boost namespace std{ // Non-member functions: inline boost::math::concepts::std_real_concept acos(boost::math::concepts::std_real_concept a) { return std::acos(a.value()); } inline boost::math::concepts::std_real_concept cos(boost::math::concepts::std_real_concept a) { return std::cos(a.value()); } inline boost::math::concepts::std_real_concept asin(boost::math::concepts::std_real_concept a) { return std::asin(a.value()); } inline boost::math::concepts::std_real_concept atan(boost::math::concepts::std_real_concept a) { return std::atan(a.value()); } inline boost::math::concepts::std_real_concept atan2(boost::math::concepts::std_real_concept a, boost::math::concepts::std_real_concept b) { return std::atan2(a.value(), b.value()); } inline boost::math::concepts::std_real_concept ceil(boost::math::concepts::std_real_concept a) { return std::ceil(a.value()); } #ifndef BOOST_MATH_NO_LONG_DOUBLE_MATH_FUNCTIONS inline boost::math::concepts::std_real_concept fmod(boost::math::concepts::std_real_concept a, boost::math::concepts::std_real_concept b) { return fmodl(a.value(), b.value()); } #else inline boost::math::concepts::std_real_concept fmod(boost::math::concepts::std_real_concept a, boost::math::concepts::std_real_concept b) { return std::fmod(a.value(), b.value()); } #endif inline boost::math::concepts::std_real_concept cosh(boost::math::concepts::std_real_concept a) { return std::cosh(a.value()); } inline boost::math::concepts::std_real_concept exp(boost::math::concepts::std_real_concept a) { return std::exp(a.value()); } inline boost::math::concepts::std_real_concept fabs(boost::math::concepts::std_real_concept a) { return std::fabs(a.value()); } inline boost::math::concepts::std_real_concept abs(boost::math::concepts::std_real_concept a) { return std::abs(a.value()); } inline boost::math::concepts::std_real_concept floor(boost::math::concepts::std_real_concept a) { return std::floor(a.value()); } inline boost::math::concepts::std_real_concept modf(boost::math::concepts::std_real_concept a, boost::math::concepts::std_real_concept* ipart) { long double ip; long double result = std::modf(a.value(), &ip); *ipart = ip; return result; } inline boost::math::concepts::std_real_concept frexp(boost::math::concepts::std_real_concept a, int* expon) { return std::frexp(a.value(), expon); } inline boost::math::concepts::std_real_concept ldexp(boost::math::concepts::std_real_concept a, int expon) { return std::ldexp(a.value(), expon); } inline boost::math::concepts::std_real_concept log(boost::math::concepts::std_real_concept a) { return std::log(a.value()); } inline boost::math::concepts::std_real_concept log10(boost::math::concepts::std_real_concept a) { return std::log10(a.value()); } inline boost::math::concepts::std_real_concept tan(boost::math::concepts::std_real_concept a) { return std::tan(a.value()); } inline boost::math::concepts::std_real_concept pow(boost::math::concepts::std_real_concept a, boost::math::concepts::std_real_concept b) { return std::pow(a.value(), b.value()); } #if !defined(__SUNPRO_CC) inline boost::math::concepts::std_real_concept pow(boost::math::concepts::std_real_concept a, int b) { return std::pow(a.value(), b); } #else inline boost::math::concepts::std_real_concept pow(boost::math::concepts::std_real_concept a, int b) { return std::pow(a.value(), static_cast
(b)); } #endif inline boost::math::concepts::std_real_concept sin(boost::math::concepts::std_real_concept a) { return std::sin(a.value()); } inline boost::math::concepts::std_real_concept sinh(boost::math::concepts::std_real_concept a) { return std::sinh(a.value()); } inline boost::math::concepts::std_real_concept sqrt(boost::math::concepts::std_real_concept a) { return std::sqrt(a.value()); } inline boost::math::concepts::std_real_concept tanh(boost::math::concepts::std_real_concept a) { return std::tanh(a.value()); } } // namespace std namespace boost{ namespace math{ namespace concepts{ // Streaming: template
inline std::basic_ostream
& operator<<(std::basic_ostream
& os, const std_real_concept& a) { return os << a.value(); } template
inline std::basic_istream
& operator>>(std::basic_istream
& is, std_real_concept& a) { long double v; is >> v; a = v; return is; } } // namespace concepts namespace tools { // real_cast converts from T to integer and narrower floating-point types. // Convert from T to integer types. template <> inline unsigned int real_cast
(concepts::std_real_concept r) { return static_cast
(r.value()); } template <> inline int real_cast
(concepts::std_real_concept r) { return static_cast
(r.value()); } template <> inline long real_cast
(concepts::std_real_concept r) { return static_cast
(r.value()); } // Converts from T to narrower floating-point types, float, double & long double. template <> inline float real_cast
(concepts::std_real_concept r) { return static_cast
(r.value()); } template <> inline double real_cast
(concepts::std_real_concept r) { return static_cast
(r.value()); } template <> inline long double real_cast
(concepts::std_real_concept r) { return r.value(); } template <> inline concepts::std_real_concept max_value
(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept)) { return max_value
(); } template <> inline concepts::std_real_concept min_value
(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept)) { return min_value
(); } template <> inline concepts::std_real_concept log_max_value
(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept)) { return log_max_value
(); } template <> inline concepts::std_real_concept log_min_value
(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept)) { return log_min_value
(); } template <> inline concepts::std_real_concept epsilon
(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept)) { return tools::epsilon
(); } template <> inline int digits
(BOOST_MATH_EXPLICIT_TEMPLATE_TYPE_SPEC(concepts::std_real_concept)) { // Assume number of significand bits is same as long double, // unless std::numeric_limits
::is_specialized to provide digits. return digits
(); } } // namespace tools } // namespace math } // namespace boost #endif // BOOST_MATH_STD_REAL_CONCEPT_HPP
std_real_concept.hpp
网页地址
文件地址
上一页
3/3 下一页
下载
( 13 KB )
Comments
Total ratings:
0
Average rating:
无评论
of 10
Would you like to comment?
Join now
, or
Logon
if you are already a member.