403Webshell
Server IP : 82.208.35.60  /  Your IP : 216.73.216.238
Web Server : Apache/2.4.55 (FreeBSD) OpenSSL/1.1.1q-freebsd PHP/7.3.31
System : FreeBSD server7.d2m.cz 12.4-RELEASE-p9 FreeBSD 12.4-RELEASE-p9 GENERIC amd64
User : studiokobylisy_cz ( 1008)
PHP Version : 7.3.31
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : OFF  |  Perl : OFF  |  Python : OFF  |  Sudo : OFF  |  Pkexec : OFF
Directory :  /usr/ports/security/cryptopp/files/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /usr/ports/security/cryptopp/files/patch-misc.h
This fixes a warning triggered by testing an unsigned parameter
against 0.  The patch solves this by creating a different template
for signed case. (PR: 178827)

--- misc.h.orig	2022-08-07 19:52:03 UTC
+++ misc.h
@@ -720,8 +720,10 @@ inline bool SafeConvert(T1 from, T2 &to)
 /// \param value the value to convert
 /// \param base the base to use during the conversion
 /// \return the string representation of value in base.
+template<bool> struct IsUnsigned {};
+
 template <class T>
-std::string IntToString(T value, unsigned int base = 10)
+std::string IntToStringImpl(T value, unsigned int base, IsUnsigned<true>)
 {
 	// Hack... set the high bit for uppercase.
 	const unsigned int HIGH_BIT = (1U << 31);
@@ -732,12 +734,6 @@ std::string IntToString(T value, unsigned int base = 1
 	if (value == 0)
 		return "0";
 
-	bool negate = false;
-	if (value < 0)
-	{
-		negate = true;
-		value = 0-value;	// VC .NET does not like -a
-	}
 	std::string result;
 	while (value > 0)
 	{
@@ -745,9 +741,28 @@ std::string IntToString(T value, unsigned int base = 1
 		result = char((digit < 10 ? '0' : (CH - 10)) + digit) + result;
 		value /= base;
 	}
+	return result;
+}
+
+template <class T>
+std::string IntToStringImpl(T value, unsigned int base, IsUnsigned<false>)
+{
+	bool negate = false;
+	if (value < 0)
+	{
+		negate = true;
+		value = 0-value;	// VC .NET does not like -a
+	}
+	std::string result = IntToStringImpl(value, base, IsUnsigned<true>());
 	if (negate)
 		result = "-" + result;
 	return result;
+}
+
+template <class T>
+std::string IntToString(T value, unsigned int base = 10)
+{
+	return IntToStringImpl(value, base, IsUnsigned<(static_cast<T>(-1) > 0)>());
 }
 
 /// \brief Converts an unsigned value to a string

Youez - 2016 - github.com/yon3zu
LinuXploit