亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? safeint.hpp

?? 自定義HttpClient類
?? HPP
?? 第 1 頁 / 共 5 頁
字號:
	SafeInt<T>& operator ^=(SafeInt<U> rhs)
	{
		*this = *this ^ rhs.Value();
		return *this;
	}

	//bitwise OR
	SafeInt<T> operator |(SafeInt<T> rhs)
	{
		return SafeInt<T>((T)(m_int | rhs.m_int));
	}

	template <typename U>
	SafeInt<T> operator |(U rhs)
	{
		//if U can fit into T without truncating, force U to T
		if(sizeof(U) <= sizeof(T))
			return SafeInt<T>(m_int | (T)rhs);
		
		if( (U)((T)rhs) == rhs)
			return SafeInt<T>(m_int | (T)rhs);

		throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);

	}

	//bitwise OR assignment
	SafeInt<T>& operator |=(SafeInt<T> i)
	{
		m_int |= i.m_int;
		return *this;
	}

	template <typename U> 
	SafeInt<T>& operator |=(U rhs)
	{
		*this = *this | rhs;
		return *this;
	}

	template <typename U> 
	SafeInt<T>& operator |=(SafeInt<U> rhs)
	{
		*this = *this | rhs.Value();
		return *this;
	}

	//logical operators
	//logical operators are like comparison operators
	//because the return value is the same regardless of 
	//what type is on the RHS or the LHS

	//and as it turns out, we need some overloads
	//bool constructor has a little overhead
	//possible combinations:
	// SafeInt<T>, SafeInt<T> - internal
	// SafeInt<T>, U          - internal
	// SafeInt<T>, bool       - internal
	// bool, SafeInt<T>       - external
	// U, SafeInt<T>          - external
	// SafeInt<U>, SafeInt<T> - external

	//logical OR
	bool operator ||(SafeInt<T> rhs)
	{
		return m_int || rhs.Value();
	}

	template <typename U>
	bool operator ||(U rhs)
	{
		return m_int || rhs;
	}

	bool operator ||(bool rhs) 
	{
		return m_int || rhs;
	}

	//logical &&
	bool operator &&(SafeInt<T> rhs)
	{
		return m_int && rhs.Value();
	}

	template <typename U>
	bool operator &&(U rhs)
	{
		return m_int && rhs;
	}

	bool operator &&(bool rhs) 
	{
		return m_int && rhs;
	}

	//miscellaneous helper functions
	SafeInt<T> Min(SafeInt<T> test, SafeInt<T> floor = SafeInt<T>::MinInt()) const
	{
		T tmp = test.Value() < m_int ? test.Value() : m_int;
		return tmp < floor ? floor : tmp;
	}

	SafeInt<T> Max(SafeInt<T> test, SafeInt<T> upper = SafeInt<T>::MaxInt()) const 
	{
		T tmp = test.Value() > m_int ? test.Value() : m_int;
		return tmp > upper ? upper : tmp;
	}

	void Swap( SafeInt<T>& with )
	{
		T temp( m_int );
		m_int = with.m_int;
		with.m_int = temp;
	}

	static SafeInt<T> SafeAtoI(const char* input)
	{
		return SafeTtoI(input);
	}

	static SafeInt<T> SafeWtoI(const wchar_t* input)
	{
		return SafeTtoI(input);
	}

private:
	//note - this looks complex, but most of the conditionals 
	//are constant and optimize away
	//for example, a signed 64-bit check collapses to:
/*
	if(lhs == 0 || rhs == 0)
		return 0;

	if(MaxInt()/+lhs < +rhs)
	{
		//overflow
		throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
	}
	//ok
	return lhs * rhs;

	Which ought to inline nicely
*/
	static T multiply(T lhs, T rhs)
	{
		if(Is64Bit())
		{
			//fast track this one - and avoid DIV_0 below
			if(lhs == 0 || rhs == 0)
				return 0;

			//we're 64 bit - slow, but the only way to do it
			if(IsSigned())
			{
				if(!IsMixedSign(lhs, rhs))
				{
					//both positive or both negative
					//result will be positive, check for lhs * rhs > MaxInt
					if(lhs > 0)
					{
						//both positive
						if(MaxInt()/lhs < rhs)
						{
							//overflow
							throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
						}
					}
					else
					{
						//both negative

						//comparison gets tricky unless we force it to positive
						//EXCEPT that -MinInt is undefined - can't be done
						//And MinInt always has a greater magnitude than MaxInt
						if(lhs == MinInt() || rhs == MinInt())
						{
							//overflow
							throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
						}

						if(MaxInt()/(-lhs) < (-rhs) )
						{
							//overflow
							throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
						}
					}
				}
				else
				{
					//mixed sign - this case is difficult
					//test case is lhs * rhs < MinInt => overflow
					//if lhs < 0 (implies rhs > 0), 
					//lhs < MinInt/rhs is the correct test
					//else if lhs > 0 
					//rhs < MinInt/lhs is the correct test
					//avoid dividing MinInt by a negative number, 
					//because MinInt/-1 is a corner case

					if(lhs < 0)
					{
						if(lhs < MinInt()/rhs)
						{
							//overflow
							throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
						}
					}
					else
					{
						if(rhs < MinInt()/lhs)
						{
							//overflow
							throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
						}
					}
				}

				//ok
				return lhs * rhs;
			}
			else
			{
				//unsigned, easy case
				if(MaxInt()/lhs < rhs)
				{
					//overflow
					throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
				}
				//ok
				return lhs * rhs;
			}
		}
		else if(Is32Bit())
		{
			//we're 32-bit
			if(IsSigned())
			{
				signed _int64 tmp = (signed _int64)lhs * (signed _int64)rhs;

				//upper 33 bits must be the same
				//most common case is likely that both are positive - test first
				if( (tmp & 0xffffffff80000000LL) == 0 || 
					(tmp & 0xffffffff80000000LL) == 0xffffffff80000000LL)
				{
					//this is OK
					return (T)tmp;
				}

				//overflow
				throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
				
			}
			else
			{
				unsigned _int64 tmp = (unsigned _int64)lhs * (unsigned _int64)rhs;
				if (tmp & 0xffffffff00000000ULL) //overflow
				{
					//overflow
					throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
				}
				return (T)tmp;
			}
		}
		else if(Is16Bit())
		{
			//16-bit
			if(IsSigned())
			{
				signed _int32 tmp = (signed _int32)lhs * (signed _int32)rhs;
				//upper 17 bits must be the same
				//most common case is likely that both are positive - test first
				if( (tmp & 0xffff8000) == 0 || (tmp & 0xffff8000) == 0xffff8000)
				{
					//this is OK
					return (T)tmp;
				}

				//overflow
				throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
			}
			else
			{
				unsigned _int32 tmp = (unsigned _int32)lhs * (unsigned _int32)rhs;
				if (tmp & 0xffff0000) //overflow
				{
					throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
				}
				return (T)tmp;
			}
		}
		else //8-bit
		{
			assert(Is8Bit());

			if(IsSigned())
			{
				signed _int16 tmp = (signed _int16)lhs * (signed _int16)rhs;
				//upper 9 bits must be the same
				//most common case is likely that both are positive - test first
				if( (tmp & 0xff80) == 0 || (tmp & 0xff80) == 0xff80)
				{
					//this is OK
					return (T)tmp;
				}

				//overflow
				throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
			}
			else
			{
				unsigned _int16 tmp = ((unsigned _int16)lhs) * ((unsigned _int16)rhs);

				if (tmp & 0xff00) //overflow
				{
					throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
				}
				return (T)tmp;
			}
		}
	}

	static inline T addition(T lhs, T rhs)
	{
		if(IsSigned())
		{
			//test for +/- combo
			if(!IsMixedSign(lhs, rhs)) 
			{
				//either two negatives, or 2 positives
				if(rhs < 0)
				{
					//two negatives
					if(lhs < (T)(MinInt() - rhs)) //remember rhs < 0
					{
						throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
					}
					//ok
				}
				else
				{
					//two positives
					if((T)(MaxInt() - lhs) < rhs)
					{
						throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
					}
					//OK
				}
			}
			//else overflow not possible
			return lhs + rhs;
		}
		else //unsigned
		{
			if((T)(MaxInt() - lhs) < rhs)
			{
				throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
				
			}
			return (lhs + rhs);
		}
	}

	static T subtraction(T lhs, T rhs)
	{
		if(IsSigned())
		{
			if(IsMixedSign(lhs, rhs)) //test for +/- combo
			{
				//mixed positive and negative
				//two cases - +X - -Y => X + Y - check for overflow against MaxInt()
				//            -X - +Y - check for overflow against MinInt()

				if(lhs >= 0) //first case
				{
					//test is X - -Y > MaxInt()
					//equivalent to X > MaxInt() - |Y|
					//Y == MinInt() creates special case
					//Even 0 - MinInt() can't be done
					//note that the special case collapses into the general case, due to the fact
					//MaxInt() - MinInt() == -1, and lhs is non-negative
					if(lhs > (T)(MaxInt() + rhs)) //remember that rhs is negative
					{
						throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
					}
					//fall through to return value
				}
				else
				{
					//second case
					//test is -X - Y < MinInt()
					//or      -X < MinInt() + Y
					//we do not have the same issues because abs(MinInt()) > MaxInt()
					if(lhs < (T)(MinInt() + rhs))
					{
						throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
					}
					//fall through to return value
				}
			}
			// else 
			//both negative, or both positive
			//no possible overflow
			return (lhs - rhs);
		}
		else
		{
			//easy unsigned case
			if(lhs < rhs)
			{
				throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
			}
			return (lhs - rhs);
		}
	}

	template <typename U>
	static SafeInt<T> MixedSizeModulus(SafeInt<T> lhs, U rhs)
	{
		//this is a simpler case than other arithmetic operations
		//first, sign of return must be same as sign of lhs
		//next, magnitude of return can never be larger than lhs

		//always test this:
		if(rhs == 0)
			throw SafeIntException(EXCEPTION_INT_DIVIDE_BY_ZERO);

		//problem cases are:
		//either T or U 32 or 64-bit unsigned, other is signed
		//signed value must be negative to create problem

		//first problem case
		//T unsigned 32-bit, U signed
		if(sizeof(T) == 4 && !SafeInt<T>::IsSigned() && 
				sizeof(U) <= 4 && SafeInt<U>::IsSigned()) 
		{
			if(rhs < 0)
				return SafeInt<T>((_int64)lhs.Value() % (_int64)rhs);
		}

		//second problem case
		//T signed <=32-bit, U unsigned 32-bit
		if(sizeof(U) == 4 && !SafeInt<U>::IsSigned() && 
				sizeof(T) <= 4 && SafeInt<T>::IsSigned())
		{
			if(lhs.Value() < 0)
				return SafeInt<T>((_int64)lhs.Value() % (_int64)rhs);
		}

		//third problem case
		//T unsigned 64-bit, U signed
		if(sizeof(T) == 8 && !SafeInt<T>::IsSigned() && 
			SafeInt<U>::IsSigned())
		{
			if(rhs < 0)
			{
				//return must be positive
				return SafeInt<T>((T)lhs.Value() % (T)(-rhs));
			}

			//else it must be safe to cast U to T
			return SafeInt<T>((T)lhs.Value() % (T)rhs);
		}

		//fourth problem case
		//T signed, U unsigned 64-bit
		if(sizeof(U) == 8 && !SafeInt<U>::IsSigned() && 
			SafeInt<T>::IsSigned())
		{
			if(lhs.Value() < 0)
			{
				//first cast -lhs to U - must fit
				//modulus operation returns type U, must fit into T (2nd cast to T)
				//negation forces to int, re-cast to T
				return SafeInt<T>((T)-(T)( ((U)(-lhs.Value())) % (U)rhs));
			}

			return SafeInt<T>((U)lhs.Value() % rhs);
		}

		//else no problem
		return SafeInt<T>(lhs.Value() % rhs);
	}

	template <typename U>
	static SafeInt<T> MixedSizeDivision(SafeInt<T> lhs, U rhs)
	{
		//first test corner cases

		if(rhs == 0)
			throw SafeIntException(EXCEPTION_INT_DIVIDE_BY_ZERO);

		//only if both are signed, check corner case
		if(SafeInt<U>::IsSigned() && SafeInt<T>::IsSigned())
		{
			//corner case where lhs = MinInt and rhs = -1
			if(lhs == SafeInt<T>::MinInt() && rhs == -1)
				throw SafeIntException(ERROR_ARITHMETIC_OVERFLOW);
		}

		//it is safe to divide lhs by an arbitrary larger number
		//unless T is unsigned and U is signed

		//if both have the same sign, there is no problem
		if(SafeInt<U>::IsSigned() == SafeInt<T>::IsSigned())
		{

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
自拍偷拍欧美精品| 久久久国产综合精品女国产盗摄| 亚洲色图欧美偷拍| 91丝袜呻吟高潮美腿白嫩在线观看| 亚洲国产经典视频| 不卡视频在线看| 国产乱码字幕精品高清av| 欧美大白屁股肥臀xxxxxx| 久久成人免费网| 欧美国产精品一区二区| 91麻豆免费观看| 婷婷久久综合九色综合绿巨人| 欧美一区二区三级| 国产乱色国产精品免费视频| 中文字幕亚洲区| 欧美精品v日韩精品v韩国精品v| 男人操女人的视频在线观看欧美| 亚洲精品一区二区在线观看| 懂色av一区二区三区蜜臀| 亚洲欧美日韩小说| 在线不卡欧美精品一区二区三区| 蜜臀av在线播放一区二区三区| 久久一夜天堂av一区二区三区| 高清久久久久久| 亚洲成人av电影在线| 欧美成人激情免费网| www.欧美日韩| 日韩高清在线电影| 国产精品情趣视频| 在线不卡中文字幕播放| av成人动漫在线观看| 午夜欧美2019年伦理| 蓝色福利精品导航| 国产精品入口麻豆原神| 欧美色电影在线| 国产成人久久精品77777最新版本 国产成人鲁色资源国产91色综 | 国产精品电影一区二区| 欧美影院一区二区三区| 国产一区二区精品久久91| 一区二区三区国产精华| 精品处破学生在线二十三| 在线视频国内一区二区| 国产毛片精品视频| 日韩中文字幕区一区有砖一区 | 日韩一区二区三区电影在线观看| 丰满白嫩尤物一区二区| 亚洲第一电影网| 国产精品视频一二| 日韩欧美电影一二三| 91国在线观看| jlzzjlzz欧美大全| 国产一区二区三区久久悠悠色av| 亚洲国产精品一区二区www| 久久久久久久久久久99999| 91精品国产色综合久久不卡电影| 91在线看国产| 成人黄色在线网站| 久久疯狂做爰流白浆xx| 午夜欧美在线一二页| 一区二区三区**美女毛片| 久久精品视频网| 日韩一区二区三区观看| 欧美久久久久久久久| 91久久精品一区二区| av不卡免费在线观看| 国产精品88888| 极品少妇xxxx精品少妇| 青青草国产成人av片免费| 五月婷婷欧美视频| 亚洲综合久久av| 亚洲自拍欧美精品| 一区二区三区日韩精品| 亚洲视频每日更新| 国产精品久久网站| 国产精品美日韩| 国产精品剧情在线亚洲| 中文字幕一区二区三区在线不卡| 国产蜜臀97一区二区三区| 久久久久久久久久久99999| 欧美精品一区二区三| 精品国产髙清在线看国产毛片| 91精品国产综合久久小美女| 91.成人天堂一区| 51精品视频一区二区三区| 欧美日本一道本在线视频| 欧美日韩色一区| 欧美日韩亚洲综合在线 欧美亚洲特黄一级| 色婷婷综合久久久久中文一区二区 | 国产欧美一区二区精品性色| 国产肉丝袜一区二区| 中文字幕欧美激情| 亚洲天堂av老司机| 亚洲欧美区自拍先锋| 亚洲综合色在线| 日产精品久久久久久久性色| 麻豆高清免费国产一区| 国内一区二区在线| 成人午夜激情影院| 91丨porny丨在线| 欧美日韩一卡二卡三卡 | 99热精品一区二区| 欧美在线999| 91麻豆精品国产综合久久久久久 | 日韩欧美一级在线播放| 26uuu精品一区二区三区四区在线| 国产午夜精品一区二区| 一区二区中文视频| 婷婷开心激情综合| 国产另类ts人妖一区二区| 99九九99九九九视频精品| 欧美日产国产精品| 国产视频一区在线播放| 亚洲国产综合色| 激情丁香综合五月| 91麻豆国产福利精品| 在线播放欧美女士性生活| 久久一夜天堂av一区二区三区| 亚洲男人的天堂一区二区| 日本欧美肥老太交大片| 成人中文字幕合集| 欧美日韩二区三区| 国产精品理论片在线观看| 天天操天天干天天综合网| 国产成人99久久亚洲综合精品| 在线看日本不卡| 国产日韩欧美在线一区| 亚洲风情在线资源站| 国产成人鲁色资源国产91色综 | 日韩欧美专区在线| 成人欧美一区二区三区白人| 日韩在线一区二区| 91尤物视频在线观看| 日韩网站在线看片你懂的| 亚洲美女视频在线| 国产又黄又大久久| 在线电影国产精品| 亚洲欧洲综合另类| 国产精品一区二区无线| 欧美日韩亚洲丝袜制服| 日韩毛片精品高清免费| 国产一区二区调教| 欧美一二三区在线观看| 一区二区三区波多野结衣在线观看| 国产在线视频不卡二| 欧美精品在欧美一区二区少妇| 国产精品成人免费| 国产精品影视天天线| 欧美一区二区三区不卡| 亚洲电影视频在线| 色呦呦国产精品| 国产精品久久久久天堂| 国产乱码精品一区二区三区五月婷 | 欧美日韩在线一区二区| 亚洲欧洲日韩综合一区二区| 国产成人亚洲综合a∨猫咪| 日韩一级黄色片| 香蕉成人伊视频在线观看| 91在线观看视频| 最新不卡av在线| av在线不卡观看免费观看| 国产日韩欧美电影| 国产成人免费高清| 中文av一区二区| 国产高清在线精品| 国产亚洲1区2区3区| 精品一区二区三区蜜桃| 欧美电影免费观看高清完整版在| 日韩av午夜在线观看| 欧美丰满一区二区免费视频 | 国产91精品免费| 久久久久久久久久久久电影| 国产麻豆精品一区二区| 欧美精品一区二区三区蜜桃 | 中文字幕一区二区三区四区不卡 | 日本精品视频一区二区| 一区二区三区在线视频观看58| 91在线视频播放| 夜夜嗨av一区二区三区中文字幕 | 成人动漫一区二区在线| 国产欧美日韩一区二区三区在线观看| 国产麻豆欧美日韩一区| 欧美国产一区二区在线观看| 成人av免费观看| 亚洲欧美色图小说| 欧美日韩小视频| 免费在线观看不卡| 国产亚洲综合av| 粉嫩av亚洲一区二区图片| 亚洲私人影院在线观看| 欧美日韩一区二区三区在线 | 久久品道一品道久久精品| 国产精品系列在线播放| 国产精品蜜臀av| 精品视频在线免费观看| 日韩成人午夜电影| 久久综合久久鬼色| 91丝袜美女网| 偷窥少妇高潮呻吟av久久免费| 欧美成人性福生活免费看| 波多野结衣精品在线|